| [news.eclipse.modeling.m2m] Re: [ATL] Copying one model with reference to another => ClassCastException |
Hello,
WHAT I WANT TO DO
I have two model files My.amodel and My.bmodel My.bmodel contains references to My.amodel
Now I want to use ATL to create a copy from My.bmodel to My_out.bmodel Preserving the references to My.amodel
THE PROBLEM
This works as long as I just copy the elements in My.bmodel without the refs to My.amodel.
As soon as I try to set the references to the corresponding elements in My.amodel the transformation fails with a java.lang.ClassCastException.
See the problematic line at ##### in the ATL file below.
Thanks for any hints, Goetz
See attachment with zip of project.
--------- ADDITIONAL INFOS ---------
I assume that the problem comes from the fact that ATL tries to handle elements in My.amodel and for some reason it has wrong information about the meta-model and the classes in it. Hence, it tries to do a cast. Whereas I would expect it to leave My.amodel untouched.
Could something be wrong with the "registration" or identification of EMF/Ecore meta models (with Namespace/URI) . Could I check something about that? I noticed that, despite the launch configuration, the transformation will only execute of the .ecore files are in certain folders in the workspace.
--------- copyBModelWithRefs.atl ---------
module copyBModelWithoutRefs; -- Module Template create bout : BMETA, aout : AMETA from bin : BMETA, ain : AMETA;
rule BModel {
from s : BMETA!BModel
to t : BMETA!BModel mapsTo s (
name <- s.name.debug('BModel'), elements <- s.elements
)
}
rule BElement {
from s : BMETA!BElement
to t : BMETA!BElement mapsTo s (
name <- s.name.debug('BElement'),
-- ##### THIS IS THE PROBLEMATIC LINE #####
correspondingAElement <- s.correspondingAElement
)
}
Best regards,
William
--------- Stacktrace ---------
INFO: BModel: 'BModel1'
INFO: BElement: 'BElement1'
SCHWERWIEGEND: ****** BEGIN Stack Trace
SCHWERWIEGEND: exception:
SCHWERWIEGEND: The value of type 'class org.eclipse.emf.ecore.impl.DynamicEObjectImpl' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@8558b7 (name: AElement) (instanceClassName: null) (abstract: false, interface: false)'
java.lang.ClassCastException: The value of type 'class org.eclipse.emf.ecore.impl.DynamicEObjectImpl' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@8558b7 (name: AElement) (instanceClassName: null) (abstract: false, interface: false)'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleEObject.dynamicGet(EStructuralFeatureImpl.java:2301)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1017)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1002)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:994)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:989)
at org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.get(ASMEMFModelElement.java:147)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:301)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:338)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:169)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:111)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:87)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:326)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:426)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlRegularVM.java:398)
at org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:42)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:759)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)
at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
SCHWERWIEGEND: A.main() : ??#24 null
SCHWERWIEGEND: local variables = {self=copyBModelWithoutRefs : ASMModule}
SCHWERWIEGEND: local stack = []
SCHWERWIEGEND: A.__exec__() : ??#18 null
SCHWERWIEGEND: local variables = {e=TransientLink {rule = 'BElement', sourceElements = {s = bin!BElement1}, targetElements = {t = bout!BElement1}, variables = {}}, self=copyBModelWithoutRefs : ASMModule}
SCHWERWIEGEND: local stack = []
SCHWERWIEGEND: A.__applyBElement(1 : NTransientLink;) : ??#20 18:28-18:51
SCHWERWIEGEND: local variables = {t=bout!BElement1, s=bin!BElement1, link=TransientLink {rule = 'BElement', sourceElements = {s = bin!BElement1}, targetElements = {t = bout!BElement1}, variables = {}}, self=copyBModelWithoutRefs : ASMModule}
SCHWERWIEGEND: local stack = [bout!BElement1, bout!BElement1, copyBModelWithoutRefs : ASMModule]
SCHWERWIEGEND: ****** END Stack Trace
INFO: Execution terminated due to error (see launch configuration to allow continuation after errors).
SCHWERWIEGEND: null
java.lang.RuntimeException
at org.eclipse.m2m.atl.engine.vm.SimpleDebugger.error(SimpleDebugger.java:195)
at org.eclipse.m2m.atl.engine.vm.StackFrame.printStackTrace(StackFrame.java:95)
at org.eclipse.m2m.atl.engine.vm.StackFrame.printStackTrace(StackFrame.java:87)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:173)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:338)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:169)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:111)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:87)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:326)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLauncher(AtlRegularVM.java:426)
at org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlRegularVM.java:398)
at org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:42)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:759)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)
at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.ClassCastException: The value of type 'class org.eclipse.emf.ecore.impl.DynamicEObjectImpl' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@8558b7 (name: AElement) (instanceClassName: null) (abstract: false, interface: false)'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleEObject.dynamicGet(EStructuralFeatureImpl.java:2301)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1017)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1002)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:994)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:989)
at org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.get(ASMEMFModelElement.java:147)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:301)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
... 22 more