Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » java.lang.ClassCastException while transforming source EReference to Target ERefernce.
java.lang.ClassCastException while transforming source EReference to Target ERefernce. [message #1838523] Sat, 27 February 2021 09:56 Go to next message
houda houda is currently offline houda houdaFriend
Messages: 12
Registered: February 2021
Junior Member
Hello,

I am trying to achieve aM2M transformation using ATL. So I am transforming Source (first figure ) class named "part" and its properties to Target (second figure) class named "Parameter" and its properties.

index.php/fa/40052/0/
================================
index.php/fa/40053/0/

================================
I would like to transform part(partelement) property to Parameter(parametertypereference) so i wrote the following ATL transformation:
rule part2Parameter{
		from s: wsdl!part,  s1: wsdl!schema
		to 	t:gcsd!Parameter
			( 	sampleValues <- 'Param', 
				parametertypereference <- s.partelement ),
		       t2:gcsd!TypeReference 
                     (        unitSymbol<- s.type,
                            classificationSystemID <- s1.xmlns )
                                                }	


And i generated the following instance to run my transformation on :
<messageDefinition
      name="messagein">
       <part name="p1"
               partelement="//@typesDefinition/@schema.0/@elementSchema.0"
               type="strn"/>
  </messageDefinition>
  <messageDefinition
      name="messageout">
            <part name="p2"
             partelement="//@typesDefinition/@schema.0/@elementSchema.1"
            type="int"/>
  </messageDefinition>


However, when i run the transformation it donesn't seem to transform the Ereference "partelement" from "part" to "element" into "parametertypereference", which is from "Parameter" to "TypeReference" and i get the following error:
org.eclipse.m2m.atl.engine.emfvm.VMException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@32517953 (name: element) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@13a712f1 (name: TypeReference) (instanceClassName: null) (abstract: false, interface: false)'
	at __applypart2Parameter#39(wsdl2gcsd.atl[43:5-43:44])
		local variables: self=wsdl2gcsd : ASMModule, link=TransientLink {rule = part2Parameter, sourceElements = {s = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@6c405db1 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3d6c89b (name: part) (instanceClassName: null) (abstract: false, interface: false)), s1 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@26177b4d (eClass: org.eclipse.emf.ecore.impl.EClassImpl@23442127 (name: schema) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {t4 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1d67082d (eClass: org.eclipse.emf.ecore.impl.EClassImpl@381d3c7c (name: Description) (instanceClassName: null) (abstract: false, interface: false)), t = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@73a473e5 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@4540ab74 (name: Parameter) (instanceClassName: null) (abstract: false, interface: false)), t1 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5185be4f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@381d3c7c (name: Description) (instanceClassName: null) (abstract: false, interface: false)), t2 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@4cd56a21 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@13a712f1 (name: TypeReference) (instanceClassName: null) (abstract: false, interface: false)), t3 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@69d635f6 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@18294587 (name: Artifact) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}, s=IN!p1, s1=IN!<unnamed>, t=OUT!<unnamed>, t1=OUT!<unnamed>, t2=OUT!<unnamed>, t3=OUT!<unnamed>, t4=OUT!<unnamed>
	at __exec__#28(wsdl2gcsd.atl)
		local variables: self=wsdl2gcsd : ASMModule, e=TransientLink {rule = part2Parameter, sourceElements = {s = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@6c405db1 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3d6c89b (name: part) (instanceClassName: null) (abstract: false, interface: false)), s1 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@26177b4d (eClass: org.eclipse.emf.ecore.impl.EClassImpl@23442127 (name: schema) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {t4 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1d67082d (eClass: org.eclipse.emf.ecore.impl.EClassImpl@381d3c7c (name: Description) (instanceClassName: null) (abstract: false, interface: false)), t = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@73a473e5 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@4540ab74 (name: Parameter) (instanceClassName: null) (abstract: false, interface: false)), t1 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5185be4f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@381d3c7c (name: Description) (instanceClassName: null) (abstract: false, interface: false)), t2 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@4cd56a21 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@13a712f1 (name: TypeReference) (instanceClassName: null) (abstract: false, interface: false)), t3 = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@69d635f6 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@18294587 (name: Artifact) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}
	at main#24(wsdl2gcsd.atl)
		local variables: self=wsdl2gcsd : ASMModule
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@32517953 (name: element) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@13a712f1 (name: TypeReference) (instanceClassName: null) (abstract: false, interface: false)'
	at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.set(EMFModelAdapter.java:679)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:474)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
	at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
	at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:208)
	at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
	at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
	at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
	at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:307)
	at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:807)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:718)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1021)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1224)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.ClassCastException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@32517953 (name: element) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@13a712f1 (name: TypeReference) (instanceClassName: null) (abstract: false, interface: false)'
	at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleEObject.dynamicSet(EStructuralFeatureImpl.java:2658)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1166)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1140)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1110)
	at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.internalSet(EMFModelAdapter.java:718)
	at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.set(EMFModelAdapter.java:672)
	... 14 more


I tried to understand the reason behind the "java.lang.ClassCastException" error but couldn't find a proper response.
If anyone could help me I would be very thankful.

My best regards.
  • Attachment: source.png
    (Size: 21.16KB, Downloaded 221 times)
  • Attachment: target.png
    (Size: 9.89KB, Downloaded 211 times)
Re: java.lang.ClassCastException while transforming source EReference to Target ERefernce. [message #1838529 is a reply to message #1838523] Sat, 27 February 2021 20:14 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7679
Registered: July 2009
Senior Member
Hi

Very difficult to comment with such a scanty repro.

I see an unusual mix of PIvot / UML / SettingDelegate and use of the same spelling for a type and a property. The former suggests poor initialization for which you provide no clues at all. The latter might be a tooling bug.

The error messages although verbose seem quite forceful. Your types are wrong. I'm not an ATL expert but perhaps you have a missing type conversion rule.

Regards

Ed Willink
Previous Topic:[Acceleo] Where to get Acceleo 4?
Next Topic:[Acceleo] Map data type?
Goto Forum:
  


Current Time: Sat Nov 09 01:14:13 GMT 2024

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

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

Back to the top