[Edapt] Problem when migrating models that reference UML [message #1724723] |
Thu, 25 February 2016 10:23  |
Eclipse User |
|
|
|
Hi,
I have a problem when trying to migrate a model that itself references Sysml profiles.
platform:/plugin/org.eclipse.papyrus.sysml14/model/SysML.profile.uml
During the migration I get a ClassCastException:
java.lang.ClassCastException: The value of type 'class org.eclipse.emf.ecore.impl.EClassImpl' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@16af0251 (name: EClassifier) (instanceClassName: null) (abstract: true, interface: false)'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleEObject.dynamicGet(EStructuralFeatureImpl.java:2604)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1027)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:439)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveCrossReferences(EcoreUtil.java:304)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:298)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:283)
at org.eclipse.emf.edapt.internal.common.ResourceUtils.resolveAll(ResourceUtils.java:293)
at org.eclipse.emf.edapt.internal.common.ResourceUtils.loadResourceSet(ResourceUtils.java:149)
at org.eclipse.emf.edapt.internal.migration.internal.Persistency.loadModel(Persistency.java:106)
at org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.loadRepository(MigrationReconstructor.java:185)
at org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.endRelease(MigrationReconstructor.java:155)
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:265)
at org.eclipse.emf.edapt.migration.execution.Migrator.migrateAndLoad(Migrator.java:217)
Note that the SYSML Profile itself ist not part of the edapt history.
For short: does anyone has experiences with this kind of problem? Is it possible or is it known to be not possible to reference SYSML Model?
For those who are interesed in details:
I have spend hous investingating this issue but I am a little stuck.
I have an odd feeling because of this: In Persistency.loadMetamodel, the metamodelResource rootpackages are extended by all packages which have been loaded into the resourceSet.
One finds a package for:
http://www.eclipse.org/uml2/5.0.0/UML
The package is of type EPackage although I would expect it to be of type UMLPackage. This package is later on registered with the packageRegistry of the resourceSet into which the historic model is loaded. This happens in
ResourceUtils.loadResourceSet()
When a package for the above uri is later on requested, the EPackage is returned because it is directly contained in the package registry due to the registration in ResourceUtils. If it wouldn't be there, the request would be delegated to the delegate registry of the ResourceRegistry which is the global PackageRegistry and which would return an UMLPackage.
Any hints or help would be very much appreciated.
Regards
Thorsten
|
|
|
|
|
|
|
|
Re: [Edapt] Problem when migrating models that reference UML [message #1724985 is a reply to message #1724855] |
Sun, 28 February 2016 10:59   |
Eclipse User |
|
|
|
Hi,
I loaded all ecore files that are used in my model into the history.
I still get a ClassCast Exception:
java.lang.ClassCastException: The value of type 'class org.eclipse.emf.ecore.impl.DynamicEObjectImpl' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@35d0499b (name: Model) (instanceClassName: null) (abstract: false, interface: false)'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleEObject.dynamicGet(EStructuralFeatureImpl.java:2604)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1027)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:439)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveCrossReferences(EcoreUtil.java:304)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:294)
at org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:283)
at org.eclipse.emf.edapt.internal.common.ResourceUtils.resolveAll(ResourceUtils.java:297)
at org.eclipse.emf.edapt.internal.common.ResourceUtils.loadResourceSet(ResourceUtils.java:149)
at org.eclipse.emf.edapt.internal.migration.internal.Persistency.loadModel(Persistency.java:106)
at org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.loadRepository(MigrationReconstructor.java:185)
at org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.endRelease(MigrationReconstructor.java:155)
at org.eclipse.emf.edapt.history.reconstruction.CompositeReconstructorBase.endRelease(CompositeReconstructorBase.java:179)
The ClassCast is thrown here:
if (!eClass.isInstance(resolvedEObject))
{
throw new ClassCastException("The value of type '" + resolvedEObject.getClass() + "' must be of type '" + eClass + "'");
}
eClass is a Model (org.eclipse.uml2.uml.Model). The resolvedEObject is a DynamicEObject with an eClass which also represents a Model (org.eclipse.uml2.uml.Model) but is loaded in a different package.
If I check MetamodelUtils.createIndependentMetamodelCopy I see that some packages are registered twice. The UML package is one one them.
Registration happens here:
Thread [main] (Suspended (breakpoint at line 163 in ResourceUtils))
ResourceUtils.register(List<EPackage>, Registry) line: 163
ResourceUtils.loadResourceSet(List<URI>, List<EPackage>, IResourceSetFactory) line: 121
Persistency.loadModel(List<URI>, Metamodel, IResourceSetFactory) line: 106
MigrationReconstructor.loadRepository() line: 185
MigrationReconstructor.endRelease(Release) line: 155
EcoreForwardReconstructor(CompositeReconstructorBase).endRelease(Release) line: 179
EcoreForwardReconstructor(ForwardReconstructorBase).doReconstruct(Release) line: 81
EcoreForwardReconstructor(ForwardReconstructorBase).doReconstruct(EObject, History, boolean) line: 57
EcoreForwardReconstructor(CompositeReconstructorBase).reconstruct(Release, boolean) line: 74
Migrator.migrate(List<URI>, Release, Release, IProgressMonitor) line: 265
Migrator.migrateAndLoad(List<URI>, Release, Release, IProgressMonitor) line: 217
I think the first time is a registration from loading the history model. Second time comes from resolving the references between the root packages.
Any idea about this?
Thanks in advance.
Thorsten
|
|
|
Re: [Edapt] Problem when migrating models that reference UML [message #1724989 is a reply to message #1724985] |
Sun, 28 February 2016 12:43   |
Eclipse User |
|
|
|
Hi
Classic metamodel schizophrenia.
Do not load the 'same' model twice. Either correct ALL references to use
the same document URI spelling, or use an EPackageRegistry that
merges/re-uses models with same package URIs.
Regards
ed Willink
On 28/02/2016 15:59, Thorsten Schlathölter wrote:
> Hi,
> I loaded all ecore files that are used in my model into the history. I
> still get a ClassCast Exception:
>
>
> java.lang.ClassCastException: The value of type 'class
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl' must be of type
> 'org.eclipse.emf.ecore.impl.EClassImpl@35d0499b (name: Model)
> (instanceClassName: null) (abstract: false, interface: false)'
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleEObject.dynamicGet(EStructuralFeatureImpl.java:2604)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1027)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
> at
> org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:439)
> at
> org.eclipse.emf.ecore.util.EcoreUtil.resolveCrossReferences(EcoreUtil.java:304)
> at
> org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:294)
> at
> org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(EcoreUtil.java:283)
> at
> org.eclipse.emf.edapt.internal.common.ResourceUtils.resolveAll(ResourceUtils.java:297)
> at
> org.eclipse.emf.edapt.internal.common.ResourceUtils.loadResourceSet(ResourceUtils.java:149)
> at
> org.eclipse.emf.edapt.internal.migration.internal.Persistency.loadModel(Persistency.java:106)
> at
> org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.loadRepository(MigrationReconstructor.java:185)
> at
> org.eclipse.emf.edapt.internal.migration.execution.internal.MigrationReconstructor.endRelease(MigrationReconstructor.java:155)
> at
> org.eclipse.emf.edapt.history.reconstruction.CompositeReconstructorBase.endRelease(CompositeReconstructorBase.java:179)
>
>
> The ClassCast is thrown here:
>
>
> if (!eClass.isInstance(resolvedEObject))
> {
> throw new ClassCastException("The value of type '" +
> resolvedEObject.getClass() + "' must be of type '" + eClass + "'");
> }
>
>
> eClass is a Model (org.eclipse.uml2.uml.Model). The resolvedEObject is
> a DynamicEObject with an eClass which also represents a Model
> (org.eclipse.uml2.uml.Model) but is loaded in a different package.
>
> If I check MetamodelUtils.createIndependentMetamodelCopy I see that
> some packages are registered twice. The UML package is one one them.
> Registration happens here:
>
>
> Thread [main] (Suspended (breakpoint at line 163 in ResourceUtils))
> ResourceUtils.register(List<EPackage>, Registry) line: 163
> ResourceUtils.loadResourceSet(List<URI>, List<EPackage>,
> IResourceSetFactory) line: 121
> Persistency.loadModel(List<URI>, Metamodel, IResourceSetFactory)
> line: 106
> MigrationReconstructor.loadRepository() line: 185
> MigrationReconstructor.endRelease(Release) line: 155
> EcoreForwardReconstructor(CompositeReconstructorBase).endRelease(Release)
> line: 179
> EcoreForwardReconstructor(ForwardReconstructorBase).doReconstruct(Release)
> line: 81
> EcoreForwardReconstructor(ForwardReconstructorBase).doReconstruct(EObject,
> History, boolean) line: 57
> EcoreForwardReconstructor(CompositeReconstructorBase).reconstruct(Release,
> boolean) line: 74
> Migrator.migrate(List<URI>, Release, Release, IProgressMonitor)
> line: 265
> Migrator.migrateAndLoad(List<URI>, Release, Release,
> IProgressMonitor) line: 217
>
>
> I think the first time is a registration from loading the history
> model. Second time comes from resolving the references between the
> root packages.
>
> Any idea about this?
>
> Thanks in advance.
> Thorsten
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06563 seconds