FeatureNotFoundException [message #544259] |
Fri, 02 July 2010 07:48 |
|
Hello,
I am trying to read a sample model, the library model I found, but I get this exception
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'version' not found. (file:/O:/myWork/JAVA/EMFTest/model/library.ecore, 5, 94)
as far as I know I am not using any "version" and I'm not asking for it either. here is a copy of the library.ecore
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="library"
nsURI="http:///org/eclipse/example/library.ecore" nsPrefix="org.eclipse.example.library">
<eClassifiers xsi:type="ecore:EClass" name="Book">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="category" eType="#//BookCategory"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="author" lowerBound="1"
eType="#//Writer" eOpposite="#//Writer/books"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Library">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="writers" upperBound="-1"
eType="#//Writer" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
eType="#//Book" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Writer">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
eType="#//Book" eOpposite="#//Book/author"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="BookCategory">
<eLiterals name="Mystery"/>
<eLiterals name="ScienceFiction" value="1"/>
<eLiterals name="Biography" value="2"/>
</eClassifiers>
</ecore:EPackage>
and here is the code I'm using to read it:
ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI(modelPath);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMLResourceFactoryImpl());
Resource resource = resourceSet.getResource(fileURI, true);
the exception is thrown by the resourceSet.getResource(fileURI, true); method.
any ideas will be welcomed
cheers,
ehsan
|
|
|
|
Re: FeatureNotFoundException [message #544378 is a reply to message #544338] |
Fri, 02 July 2010 13:46 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------040104020106030606030101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Jan,
Yes, or better yet EcoreResourceFactoryImpl.
Jan Reimann wrote:
> Hi Ehsan,
>
>> ResourceSet resourceSet = new ResourceSetImpl();
>> URI fileURI = URI.createFileURI(modelPath);
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
>> new XMLResourceFactoryImpl());
>> Resource resource = resourceSet.getResource(fileURI, true);
>>
> what about the XMIResourceFactoryImpl? Does this work instead of the
> XMLResourceFactoryImpl?
>
--------------040104020106030606030101
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jan,<br>
<br>
Yes, or better yet EcoreResourceFactoryImpl.<br>
<br>
<br>
Jan Reimann wrote:
<blockquote cite="mid:i0kkro$s8h$1@build.eclipse.org" type="cite">
<pre wrap="">Hi Ehsan,
</pre>
<blockquote type="cite">
<pre wrap="">ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI(modelPath);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
new XMLResourceFactoryImpl());
Resource resource = resourceSet.getResource(fileURI, true);
</pre>
</blockquote>
<pre wrap=""><!---->what about the XMIResourceFactoryImpl? Does this work instead of the
XMLResourceFactoryImpl?
</pre>
</blockquote>
</body>
</html>
--------------040104020106030606030101--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: FeatureNotFoundException [message #544636 is a reply to message #544259] |
Mon, 05 July 2010 07:42 |
|
Hello,
Thanks a lot, both EcoreResourceFactoryImpl() and
XMIResourceFactoryImpl() work:-).
now if someone could explain why XMLResourceFactoryImpl() throws the exception but not the other two I would be grateful.
cheers,
Ehsan
|
|
|
Re: FeatureNotFoundException [message #544777 is a reply to message #544636] |
Mon, 05 July 2010 13:26 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Ehsan,
Because XMLResourceImpl knows nothing about XMI and expects any of the
"noise" that XMI introduces (i.e., the XMI version attribute) to be part
of the model.
Ehsan wrote:
> Hello,
>
> Thanks a lot, both EcoreResourceFactoryImpl() and
> XMIResourceFactoryImpl() work:-). now if someone could explain why
> XMLResourceFactoryImpl() throws the exception but not the other two I
> would be grateful.
>
> cheers,
> Ehsan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03290 seconds