Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Rule inheritance gives nullpointer exception ?
icon5.gif  [ATL] Rule inheritance gives nullpointer exception ? [message #647917] Mon, 10 January 2011 13:15 Go to next message
Marten Sijtema is currently offline Marten SijtemaFriend
Messages: 67
Registered: November 2009
Member
Hello, I am trying to transform a ecore model into a custom metamodel of mine. This snippet below gives me a Nullpointer exception when running the transformation.

Now, I can fix the Nullpointer by uncommenting the two guards in the from-clauses. However, if I do that, the resulting ModelEnumLiterals are not tied to the ModelEnums. In fact, the ModelEnum is never generated, every instance of EEnum will just be treated as were it a normal EDataType.

Why is this the case?

(FYI: EEnum is a subclass of EDataType, and also, in the target metamodel, ModelEnum is a subtype of ModelDataType, so we're looking at a one-to-one mapping here).

Anybody any idea what goes wrong here?

rule EDataType2ModelDataType {
	from
		edt : ecore!EDataType --(not edt.oclIsKindOf(ecore!EEnum))   
	to
		gattype : gwt!ModelPrimitiveType ( 
			name <- edt.name
		)
}
rule EEnum2ModelEnum extends EDataType2ModelDataType {
 from
  	  edt : ecore!EEnum --( edt.oclIsKindOf(ecore!EEnum))  
 to
	  gattype : gwt!ModelEnum (
	   name <- edt.name + 'Enum',
	   enumLiterals <- edt.eLiterals
	  )
}

rule EEnumLiteral2ModelEnumLiteral {
 from
  elt : ecore!EEnumLiteral 
 to
  glt : gwt!ModelEnumLiteral (
    name <- elt.name,
    value <- elt.value
  )
}




My company: Sytematic, building business software from models.
Re: [ATL] Rule inheritance gives nullpointer exception ? [message #648293 is a reply to message #647917] Wed, 12 January 2011 10:10 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
Try using different guards as follows...

Instead of:
edt : ecore!EDataType --(not edt.oclIsKindOf(ecore!EEnum))
Try:
edt : ecore!EDataType (edt.oclIsTypeOf(ecore!EDataType))

Instead of:
edt : ecore!EEnum --( edt.oclIsKindOf(ecore!EEnum))
Try:
edt : ecore!EEnum ( edt.oclIsTypeOf(ecore!EEnum))

and maybe add
elt : ecore!EEnumLiteral(elt.oclIsTypeOf(ecore!EEnumLiteral))

I think you problem is that EEnum is both a EEnum and a EDataType. Using oclIsKindOf will return true for both. oclIsTypeOf is stricter in that it won't check the parent types of the classifier for compatibility.

Regards,
Ronan
Re: [ATL] Rule inheritance gives nullpointer exception ? [message #648298 is a reply to message #648293] Wed, 12 January 2011 10:19 Go to previous messageGo to next message
Marten Sijtema is currently offline Marten SijtemaFriend
Messages: 67
Registered: November 2009
Member
Thanks for the suggestion.

I tried it, but it doesn't work. The results are the same as when I used the oclIsKindOf. I think it is a bug, the transformation is actually crashing with a NullpointerException, which shouldn't happen of course...



My company: Sytematic, building business software from models.
Re: [ATL] Rule inheritance gives nullpointer exception ? [message #648302 is a reply to message #648298] Wed, 12 January 2011 10:30 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Do you get the exception if you just run the first 2 rules? Also please provide the full error message.

[Updated on: Wed, 12 January 2011 10:31]

Report message to a moderator

Re: [ATL] Rule inheritance gives nullpointer exception ? [message #648307 is a reply to message #648302] Wed, 12 January 2011 10:50 Go to previous messageGo to next message
Marten Sijtema is currently offline Marten SijtemaFriend
Messages: 67
Registered: November 2009
Member
I just realize something. Could the nullpointer be generated because the resulting model does not conform to the (target) meta model?

Because, if I remove some rules, and leave only one in (even when I just leave correct ones in, stripping them to the bone so they ought to work), I also get the same nullpointer. What do nullpointers like the one below usually indicate? I might have been a bit premature by saying it's an ATL bug Smile



java.lang.NullPointerException
	at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSettingDelegate(EStructuralFeatureImpl.java:814)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate(BasicEObjectImpl.java:1542)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicIsSet(BasicEObjectImpl.java:1273)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1255)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObjectImpl.java:1239)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.shouldSaveFeature(XMLSaveImpl.java:1194)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1232)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2667)
	at org.eclipse.emf.ecore.xmi.impl.XMISaveImpl.writeTopObjects(XMISaveImpl.java:90)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:592)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:256)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:206)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)
	at org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader.realSave(EMFModelLoader.java:354)
	at org.eclipse.m2m.atl.engine.vm.ModelLoader.save(ModelLoader.java:232)
	at org.eclipse.m2m.atl.core.ui.vm.asm.ASMExtractor.extract(ASMExtractor.java:52)
	at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:140)
	at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:222)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:866)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1069)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)



My company: Sytematic, building business software from models.

[Updated on: Wed, 12 January 2011 10:51]

Report message to a moderator

Re: [ATL] Rule inheritance gives nullpointer exception ? [SOLVED] [message #648310 is a reply to message #648302] Wed, 12 January 2011 11:32 Go to previous messageGo to next message
Marten Sijtema is currently offline Marten SijtemaFriend
Messages: 67
Registered: November 2009
Member
I fixed it! It was a problem with the target metamodel, which had a EOpposite relation wrongly put.

Wow this costed me quite some time...

Thanks for your replies!


My company: Sytematic, building business software from models.
Re: [ATL] Rule inheritance gives nullpointer exception ? [message #648320 is a reply to message #648307] Wed, 12 January 2011 12:00 Go to previous message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 12/01/2011 11:50, Marten Sijtema a écrit :
> I just realize something. Could the nullpointer be generated because the
> resulting model does not conform to the (target) meta model?
>
> Because, if I remove some rules, and leave only one in, I also get the
> same nullpointer. What do nullpointers like the one below usually
> indicate? I might have been a bit premature by saying it's an ATL bug :)
>
May be the EMF list could be the best place to answer your question....

>
>
>
> java.lang.NullPointerException
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.getSetting Delegate(EStructuralFeatureImpl.java:814)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate (BasicEObjectImpl.java:1542)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicIsSet(Ba sicEObjectImpl.java:1273)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:1255)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eIsSet(BasicEObj ectImpl.java:1239)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.shouldSaveFeature (XMLSaveImpl.java:1194)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1232)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2667)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMISaveImpl.writeTopObjects(X MISaveImpl.java:90)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:592)
> at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:206)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1406)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:993)
>
> at
> org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader.realSave( EMFModelLoader.java:354)
>
> at org.eclipse.m2m.atl.engine.vm.ModelLoader.save(ModelLoader.j ava:232)
> at
> org.eclipse.m2m.atl.core.ui.vm.asm.ASMExtractor.extract(ASME xtractor.java:52)
>
> at
> org.eclipse.m2m.atl.core.service.LauncherService.launch(Laun cherService.java:140)
>
> at
> org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDel egate.launch(AtlLaunchConfigurationDelegate.java:222)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:853)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:703)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>
>


--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Previous Topic:[ATL]Are there any APIs in ATL for java development?
Next Topic:[QVTO] Early mapping of metamodel elements
Goto Forum:
  


Current Time: Sat Jun 15 21:00:28 GMT 2019

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

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

Back to the top