Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Edapt] Feature not found when migrating(Feature not found exception is thrown during migration or when loading the reasource)
[Edapt] Feature not found when migrating [message #1790345] Fri, 08 June 2018 13:00 Go to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi all!

I am still struggling with the integration of Edapt into my project.

I have 2 models, a base model and an extension that references the base model. I created a history only for the extension model. The base model resource is added to the extension model ecore file. The initial history release contains the full set of operations to create the base+extension model.

Now, as a change to the model, I changed a class name in the extension model, regenerated the genmodel, the model and edit code.

My editor detects the old model version when I load an old model instance from a file resource. But the migration process throws an exception like:

Caused by: org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'type' not found.
	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 org.eclipse.emf.edapt.internal.common.ResourceUtils.loadResourceSet(ResourceUtils.java:133)
	at org.eclipse.emf.edapt.internal.migration.internal.Persistency.loadModel(Persistency.java:110)
	at org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.loadRepository(MigrationReconstructor.java:189)
	at org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.endRelease(MigrationReconstructor.java:159)
	at org.eclipse.emf.edapt.history.reconstruction.CompositeReconstructorBase.endRelease(CompositeReconstructorBase.java:179)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:81)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:57)
	at org.eclipse.emf.edapt.history.reconstruction.CompositeReconstructorBase.reconstruct(CompositeReconstructorBase.java:74)
	at org.eclipse.emf.edapt.migration.execution.Migrator.migrate(Migrator.java:269)
	at org.eclipse.emf.edapt.migration.execution.Migrator.migrateAndLoad(Migrator.java:221)
	... 107 more
Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'type' not found.
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeature(XMLHandler.java:2027)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeature(XMLHandler.java:1991)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2743)
	at org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler.handleObjectAttribs(SAXXMLHandler.java:77)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2229)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1366)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1504)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
	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(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:745)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1289)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3132)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:852)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
	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)
	... 118 more


Obviously, when migrating the old model instance the migrator is not able to find model features from the (base) model.

The extension_model.history is registered as migrator to the org.eclipse.emf.edapt.migrators extension point. All plugin dependencies are added.

Do I miss something? Can anyone help, please?

Thanks,
Gernot.
Re: [Edapt] Feature not found when migrating [message #1790464 is a reply to message #1790345] Mon, 11 June 2018 12:18 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi,

Would it be possible to share a running example? Otherwise it is hard to tell what is going wrong.

I suppose you were using a rename operation from the operation browser, updated the NS-URI of the extension ecore, and created an edapt release for the initial history and after the change.

Just from the stacktrace and description I would suggest to check where an attribute called "type" is used in the migrated model file. And then check the ecores/and the history if this feature is actually present in the ecore/and history.
(Maybe this was never present there and not noticed because XMLResource.OPTION_RECORD_UNKNOWN_FEATURE is used)

Besides that I can only suggest to set a breakpoint in org.eclipse.emf.edapt.internal.common.ResourceUtils.loadResourceSet(List<URI>, List<EPackage>, IResourceSetFactory) and check the EPackage which should contain the type feature. Does this EPackage look like you would expect it in comparison to the model you want to load?

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] Feature not found when migrating [message #1790587 is a reply to message #1790464] Wed, 13 June 2018 09:48 Go to previous messageGo to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

Thanks for the help.

I attached a running example (edapt-example_before-migration.zip) of my model structure. There is a base.ecore model and an extension.ecore model that references the base model. Additionally, there is a history file for the extension model with an initial release.

I also created a simple E4 application which shows the content of an example file in a tree viewer. The example file is delivered as well (stored in the UI plugin's folder '/resources').

Then I migrated the extension model by using the rename operation on the 'note' attribute of class 'CustomerRequest'. I renamed the attribute to 'info'. Then I created a new release and renamed the nsURI to '.../1.1'.

The migrated plugins are also attached here (edapt-example_after-migration.zip).

Now the migration process throws an exception saying that the previous package of the extension model (version 1.0) was not found:

Caused by: org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.tonreg.net/emf/models/extension.ecore/1.0' not found. (platform:/plugin/net.tonreg.emf.edapt.example.ui/resources/data.extension, 2, 312)
	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 net.tonreg.emf.edapt.example.ui.parts.ContentPart.getData(ContentPart.java:79)
	at net.tonreg.emf.edapt.example.ui.parts.ContentPart.createComposite(ContentPart.java:61)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	... 112 more
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.tonreg.net/emf/models/extension.ecore/1.0' not found. (platform:/plugin/net.tonreg.emf.edapt.example.ui/resources/data.extension, 2, 312)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2625)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2458)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1335)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1504)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
	at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:78)
	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 org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:745)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1289)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3132)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:852)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
	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)
	... 120 more


I appreciate your help.

Thanks and regards,
Gernot.

Re: [Edapt] Feature not found when migrating [message #1790678 is a reply to message #1790587] Thu, 14 June 2018 10:41 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi,

thank you for the example code.

In ContentPart.performMigration(Migrator, URI, Release) you are using the migrateAndLoad method of the migrator.
This returns a ResourceSet which contains the migrated and loaded data. The migration is done in memory only, when you use this method. So in your getData() method you need to reuse the ResourceSet returned by the migrator. When I change the code accordingly, the migration is working.

The other option would be to use migrateAndSave. This would save the model after the migration, so loading it afterwards without Edapt will work as regularly.

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] Feature not found when migrating [message #1790752 is a reply to message #1790678] Fri, 15 June 2018 15:03 Go to previous messageGo to next message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

Thanks for looking into the code. With the proposed changes I was able to get the example running.

However, on my real case code it still does not work. I went done with the debugger and found that the method call resourceSet.getResource(modelURI, true) fails. This is called in ResourceUtils.loadResourceSet(...):

index.php/fa/33133/0/

Both, migrateAndLoad() and migrateAndSave() are ending up at this method and, thus, both fail. So migrateAndXXX() throws an exception that the package with the nsURI from the previous model (version 1.0) was not found.

Usually, in my code I use the createResource() method to return the resource:
final ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(modelURI);


The modelURI is exactly the same in both cases. When I try createResource() directly in my code the resource is returned without any exception. Interestingly, in ResourceUtils.loadResourceSet(...) the createResource() method was commented out. Any reasons for this?

Honestly, I am not sure what the difference between createResource() and getResource() actually is. The context help for getResource() says that: "...the package registry is used to resolve the namespace URI...". Can this be the root cause because the previous model package is not registered?

Thanks and regards,
Gernot.

Re: [Edapt] Feature not found when migrating [message #1790855 is a reply to message #1790752] Tue, 19 June 2018 07:16 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi,

Edapt works roughly like this:
1. It parses the text-file for the ns-uris. You can use this to get a migrator and find out the source release. So in your use case the source release should probably be the release at index 0 contained by the history. Is the right source release found on your side?
2. Than it goes to the actual package registry to get the latest version of your ecores. Are both of your emf models registered correctly at the extension point and part of the runtime?
3. Based on the source release it undoes all recorded changes from later releases to get a representation of the ecore which can be used to load the old text file. Here you could check if your history contains all changes, especially ns-uris changes (for earlier release).
4. The loaded file is mapped to a migration model and the miration is done.

I think that since we get an error during resource loading, I think that we have an error during steps 1-3. Could you maybe check that there are two EPackages passed to this loadResourceSet method (base+extension, both should have the original 1.0 ns-uris) and check above comments.
This may help to narrow the problem down.

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] Feature not found when migrating [message #1790875 is a reply to message #1790855] Tue, 19 June 2018 13:06 Go to previous message
Gernot Krause is currently offline Gernot KrauseFriend
Messages: 22
Registered: June 2014
Junior Member
Hi!

Thanks for the help. Now I got it running. The error was in my example text file but not obvious:

I added an optional attribute manually to test something. However, I did not remember that this attribute was configured as element (FeatureKind=element) in the ecore model. This caused a FeatureNotFoundException while loading that ended up in a PackageNotFoundException for the particular nsURI.

Now, as this is fixed the other problem (parsing my custom EDataType) pops up again, see: https://www.eclipse.org/forums/index.php?t=msg&th=1093606&goto=1790176&#msg_1790176

Thanks for your kind help!

Best regards,
Gernot.

Previous Topic:[EMF Forms] Changing visible columns and their order in a table
Next Topic:[EEF] Trouble getting custom properties view to update model
Goto Forum:
  


Current Time: Sat Apr 20 06:14:31 GMT 2024

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

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

Back to the top