Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Edapt] Migrating cross reference classcast issue(CCE Eobject cannot cast to Eclassifier because they are in an unnamed model of loader)
[Edapt] Migrating cross reference classcast issue [message #1862345] Mon, 27 November 2023 10:18 Go to next message
Eclipse UserFriend
Hi,

i am trying to get started with Edapt on migrating models and i am stuck on this exception when loading reconstructing the original history:
(I am Testing migrating models by migrating a reusable rename operation)

java.lang.ClassCastException: class org.eclipse.emf.ecore.impl.EObjectImpl cannot be cast to class org.eclipse.emf.ecore.EClassifier (org.eclipse.emf.ecore.impl.EObjectImpl and org.eclipse.emf.ecore.EClassifier are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @602297ad)
	at org.eclipse.emf.ecore.impl.EReferenceImpl.eSet(EReferenceImpl.java:423)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1110)
	at org.eclipse.emf.edapt.history.reconstruction.EcoreReconstructorSwitchBase.set(EcoreReconstructorSwitchBase.java:82)
	at org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor$EcoreReconstructorSwitch.caseSet(EcoreForwardReconstructor.java:107)
	at org.eclipse.emf.edapt.spi.history.util.HistorySwitch.doSwitch(HistorySwitch.java:309)
	at org.eclipse.emf.edapt.spi.history.util.HistorySwitch.doSwitch(HistorySwitch.java:106)
	at org.eclipse.emf.edapt.spi.history.util.HistorySwitch.doSwitch(HistorySwitch.java:92)
	at org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor.startChange(EcoreForwardReconstructor.java:73)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:99)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:114)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:104)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:80)
	at org.eclipse.emf.edapt.history.reconstruction.ForwardReconstructorBase.doReconstruct(ForwardReconstructorBase.java:59)
	at org.eclipse.emf.edapt.history.reconstruction.CompositeReconstructorBase.reconstruct(CompositeReconstructorBase.java:76)
	at org.eclipse.emf.edapt.migration.execution.Migrator.migrate(Migrator.java:271)
	at org.eclipse.emf.edapt.migration.execution.Migrator.migrateAndLoad(Migrator.java:223)


After some debugging i realized that the problem involves an EReference which is located in another model.

So here is the setup:
3 ecore models:
designForX.ecore -> The overarching model where the history is located
a.ecore
b.ecore

Code From designForX.ecore:
<eClassifiers xsi:type="ecore:EClass" name="CustomD4XClass" eSuperTypes="../../bPlugin/b.ecore#//CustomBSuperclass">
      <eStructuralFeatures xsi:type="ecore:EReference" name="CustomAClass" eType="../../aPlugin/a.ecore#//CustomAPackage/CustomAClass"/>
</eClassifiers>


The models were already created and are quite big. I created the history and added the orther models as ressource. I see the history in all models and i can release the changes. The migrator detects when the saved XMI is of an old version and starts the migration.

Any idea where thi issue could be? I gladly atach more information. I am using 1.8 as execution environment with an Edapt version 1.5 and EMF 2.35.

Thanks in advance ;)

[Updated on: Mon, 27 November 2023 12:18] by Moderator

Re: [Edapt] Migrating cross reference classcast issue [message #1862353 is a reply to message #1862345] Tue, 28 November 2023 03:41 Go to previous messageGo to next message
Eclipse UserFriend
As always sleeping on it helps.
I think i solved this problem. designForX.ecore has references into A and into B, but A and B do not have references into designForX.ecore. Changing the order in which the metamodel composit changes were added may be solution to the problem.
Previously this was the initial history creation:
designForX.ecore -> The overarching model where the history is located
a.ecore
b.ecore

Now
b.ecore
a.ecore
designForX.ecore -> The overarching model where the history is located

I cannot know for sure if this is the fix, since i get now a different error and the previous error is not reached yet. But it feel right that the order in which the models are initially created matter.
Re: [Edapt] Migrating cross reference classcast issue [message #1862369 is a reply to message #1862345] Wed, 29 November 2023 04:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

so usually in these cases you will have to open designForX.ecore's context menu -> Edapt -> Add Metamodel to history -> Next -> Select "a.ecore" and "b.ecore" as Metamodel Resources -> Finish

This should make sure that all the changes in the initial release are in the right order and contains the changes from all three ecores.

If you still have issues, please try to attach a small reproducer. Otherwise it is really hard to diagnose issues with Edapt.
Re: [Edapt] Migrating cross reference classcast issue [message #1862460 is a reply to message #1862369] Wed, 06 December 2023 03:37 Go to previous message
Eclipse UserFriend
Thx for the answer.

Sadly it es very hard to make a functional example since i am trying to make an existing application migration ready and each ecore has 100+ classes. I am working through the issues i am having and hopefully at the end i can make a post with the problems i encountered. The main problem i am encountering is that EMF has not the same constraints as Edapt and it is not quite clear what the constraints of Edapt are.

The issue of this topic was definitely resolved by putting the initial composite change of the ecores in the right order. Not only that, but also the order matters in which the classes are initially added to the history. For EMF model generation it doesnt matter in which order the classes are designed in the ecore. EMF resolves the dependencies in the genmodel and sets the correct ID's in the Factory.
The Problem comes with Edapt Initial History generation. Here it seems that it does not resolve any class dependencies so when the migrator code reconstructs the Epackage the EclassifierList is out of order with the ID's that are set in the Factory. So i had to reorder all class definitions in the Edapt history to align it with how the genmodel does.

Cheers
Previous Topic:[Edapt] Adding a new EPackage cause NPE during Migration
Next Topic:EmfForms TreeMasterViewer Validate Icon Image
Goto Forum:
  


Current Time: Thu Jun 19 11:50:01 EDT 2025

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

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

Back to the top