Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Compare FeatureNotFoundException
EMF Compare FeatureNotFoundException [message #1248834] Mon, 17 February 2014 18:03 Go to next message
Pey Max is currently offline Pey MaxFriend
Messages: 5
Registered: February 2014
Junior Member
Hi, I'm getting a

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Model' not found.

when I try to compare 2 xmi files with Emf Compare.

I'm kind of a beginner with this but I'm having a lot of trouble trying to fix this issue. Here's the code :


public static void compare() {

EPackage.Registry.INSTANCE.put(UmlPackage.eINSTANCE.getNsURI(), UmlPackage.eINSTANCE);


// Load the two input models
ResourceSet resourceSet1 = new ResourceSetImpl();
ResourceSet resourceSet2 = new ResourceSetImpl();
URI uri = URI.createFileURI(new File("xmi/test1.xmi").getAbsolutePath());
URI uri2 = URI.createFileURI(new File("xmi/test2.xmi").getAbsolutePath());

resourceSet1.getPackageRegistry().put(UmlPackage.eINSTANCE.getNsURI(), UmlPackage.eINSTANCE);
resourceSet2.getPackageRegistry().put(UmlPackage.eINSTANCE.getNsURI(), UmlPackage.eINSTANCE);
resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XmiResourceFactoryImpl());
resourceSet2.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XmiResourceFactoryImpl());


resourceSet1.getResource(uri, true);
resourceSet2.getResource(uri, true);


// Configure EMF Compare
IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
matchEngineFactory.setRanking(20);
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
matchEngineRegistry.add(matchEngineFactory);
EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();

// Compare the two models
IComparisonScope scope = EMFCompare.createDefaultScope(resourceSet1, resourceSet2);


ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(resourceSet1, resourceSet2, null);
AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
@SuppressWarnings("restriction")
CompareEditorInput input = new ComparisonScopeEditorInput(new CompareConfiguration(),
editingDomain, adapterFactory, comparator, scope);

CompareUI.openCompareDialog(input);

}




and the exception :

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Model' not found. (file:/C:/Users/Maxime/Documents/Documents/IUT/XMIGraph/xmi/test1.xmi, 6, 70)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at compare.Compare.compare(Compare.java:90)
at compare.Compare.main(Compare.java:70)
Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Model' not found. (file:/C:/Users/Maxime/Documents/Documents/IUT/XMIGraph/xmi/test1.xmi, 6, 70)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeature(XMLHandler.java:1998)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeature(XMLHandler.java:1962)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1906)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 3 more


I'd appreciate some help Smile Thanks !
Re: EMF Compare FeatureNotFoundException [message #1249263 is a reply to message #1248834] Tue, 18 February 2014 04:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30684
Registered: July 2009
Senior Member
Pey,

Comments below.

On 17/02/2014 10:02 PM, Pey Max wrote:
> Hi, I'm getting a
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Model'
> not found.
>
> when I try to compare 2 xmi files with Emf Compare.
>
> I'm kind of a beginner with this but I'm having a lot of trouble
> trying to fix this issue. Here's the code :
>
>
> public static void compare() {
>
> EPackage.Registry.INSTANCE.put(UmlPackage.eINSTANCE.getNsURI(),
> UmlPackage.eINSTANCE);
>
>
> // Load the two input models
> ResourceSet resourceSet1 = new ResourceSetImpl();
> ResourceSet resourceSet2 = new ResourceSetImpl();
> URI uri = URI.createFileURI(new
> File("xmi/test1.xmi").getAbsolutePath());
> URI uri2 = URI.createFileURI(new
> File("xmi/test2.xmi").getAbsolutePath());
>
> resourceSet1.getPackageRegistry().put(UmlPackage.eINSTANCE.getNsURI(),
> UmlPackage.eINSTANCE);
> resourceSet2.getPackageRegistry().put(UmlPackage.eINSTANCE.getNsURI(),
> UmlPackage.eINSTANCE);
> resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
> new XmiResourceFactoryImpl());
EMF provides XMIResourceFactoryImpl so what is XmiResourceFactoryImpl?
> resourceSet2.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
> new XmiResourceFactoryImpl());
>
> resourceSet1.getResource(uri, true);
> resourceSet2.getResource(uri, true);
>
> // Configure EMF Compare
> IEObjectMatcher matcher =
> DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
> IComparisonFactory comparisonFactory = new
> DefaultComparisonFactory(new DefaultEqualityHelperFactory());
> IMatchEngine.Factory matchEngineFactory = new
> MatchEngineFactoryImpl(matcher, comparisonFactory);
> matchEngineFactory.setRanking(20);
> IMatchEngine.Factory.Registry matchEngineRegistry = new
> MatchEngineFactoryRegistryImpl();
> matchEngineRegistry.add(matchEngineFactory);
> EMFCompare comparator =
> EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
> // Compare the two models
> IComparisonScope scope =
> EMFCompare.createDefaultScope(resourceSet1, resourceSet2);
>
>
> ICompareEditingDomain editingDomain =
> EMFCompareEditingDomain.create(resourceSet1, resourceSet2, null);
> AdapterFactory adapterFactory = new
> ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
> @SuppressWarnings("restriction")
> CompareEditorInput input = new ComparisonScopeEditorInput(new
> CompareConfiguration(), editingDomain, adapterFactory, comparator,
> scope);
> CompareUI.openCompareDialog(input);
>
> }
>
>
>
> and the exception :
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'Model'
> not found.
> (file:/C:/Users/Maxime/Documents/Documents/IUT/XMIGraph/xmi/test1.xmi,
> 6, 70)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
> at compare.Compare.compare(Compare.java:90)
> at compare.Compare.main(Compare.java:70)
> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'Model' not found.
> (file:/C:/Users/Maxime/Documents/Documents/IUT/XMIGraph/xmi/test1.xmi,
> 6, 70)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeature(XMLHandler.java:1998)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeature(XMLHandler.java:1962)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1906)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown
> Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:253)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
> ... 3 more
It's impossible to comment on why your unknown-to-me serialization
doesn't conform to your unknown-to-me model. Can you read and write
instance of your model with the generated editor?
>
>
> I'd appreciate some help :) Thanks !
Re: EMF Compare FeatureNotFoundException [message #1249841 is a reply to message #1249263] Tue, 18 February 2014 17:42 Go to previous messageGo to next message
Pey Max is currently offline Pey MaxFriend
Messages: 5
Registered: February 2014
Junior Member
Thanks but I'm gonna need some more help, because I'm really new to EMF and I don't have any idea how to do this :/
Re: EMF Compare FeatureNotFoundException [message #1249854 is a reply to message #1249841] Tue, 18 February 2014 17:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30684
Registered: July 2009
Senior Member
Pey,

Is this your own model you've developed yourself? Where did the
serialization you're trying to load come from?

On 18/02/2014 6:42 PM, Pey Max wrote:
> Thanks but I'm gonna need some more help, because I'm really new to
> EMF and I don't have any idea how to do this :/
Re: EMF Compare FeatureNotFoundException [message #1249867 is a reply to message #1249854] Tue, 18 February 2014 18:17 Go to previous messageGo to next message
Pey Max is currently offline Pey MaxFriend
Messages: 5
Registered: February 2014
Junior Member
Well I'm working on a project that was created by 4 students two years ago and they developed the model themselves. And the serialization is just something I found on the web.

[Updated on: Tue, 18 February 2014 18:20]

Report message to a moderator

Re: EMF Compare FeatureNotFoundException [message #1249876 is a reply to message #1249867] Tue, 18 February 2014 18:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30684
Registered: July 2009
Senior Member
Pey,

The serialization must correspond to a model, so if that's not the case
(which sounds like it), then you'll not be able to load it.

On 18/02/2014 7:17 PM, Pey Max wrote:
> Well I'm trying on a project that was created by 4 students two years
> ago and they developed the model themselves. And the serialization is
> just something I found on the web.
Re: EMF Compare FeatureNotFoundException [message #1252759 is a reply to message #1249876] Fri, 21 February 2014 15:23 Go to previous messageGo to next message
Pey Max is currently offline Pey MaxFriend
Messages: 5
Registered: February 2014
Junior Member
What do you mean by "serialization" ?
Re: EMF Compare FeatureNotFoundException [message #1252839 is a reply to message #1252759] Fri, 21 February 2014 16:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30684
Registered: July 2009
Senior Member
Pey,

You said "And the serialization is just something I found on the web."
What do you mean by "serialization"? I assumed you meant the XML/XMI
file you're trying to read; it must correspond to a model, e.g., this
UmlPackage model you seem to be using. That appears not to be the case.


On 21/02/2014 4:23 PM, Pey Max wrote:
> What do you mean by "serialization" ?
Re: EMF Compare FeatureNotFoundException [message #1253017 is a reply to message #1252839] Fri, 21 February 2014 21:29 Go to previous messageGo to next message
Pey Max is currently offline Pey MaxFriend
Messages: 5
Registered: February 2014
Junior Member
Well I actually don't know what is the package for the model I'm using. How do I found out ? I used UmlPackage because I saw a lot of people using it on the web but since the serialization is based on a custom metamodel, I should probably use another ... But I got no idea how to find it.
Re: EMF Compare FeatureNotFoundException [message #1253334 is a reply to message #1253017] Sat, 22 February 2014 05:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30684
Registered: July 2009
Senior Member
Pey,

Comments below.

On 21/02/2014 10:29 PM, Pey Max wrote:
> Well I actually don't know what is the package for the model I'm
> using. How do I found out ?
From the namespace. Top level element(s) in the XMI. There must be an
EPackage with an nsURI that corresponds and then the rest of the
serialization must conform the EClasses defined in that model.
> I used UmlPackage because I saw a lot of people using it on the web
> but since the serialization is based on a custom metamodel, I should
> probably use another ... But I got no idea how to find it.
Nor do I.
Previous Topic:Model Migration
Next Topic:XSD Importer and FeatureMap
Goto Forum:
  


Current Time: Fri Dec 06 10:55:40 GMT 2019

Powered by FUDForum. Page generated in 0.05454 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top