Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » NullPointerException after transformation
NullPointerException after transformation [message #1782888] Sat, 03 March 2018 13:19 Go to next message
Gonzalo López is currently offline Gonzalo LópezFriend
Messages: 14
Registered: February 2018
Junior Member
I'm having trouble making a simple transformation.
What I'm trying to do is copy a bpmn model.
I created a simple bpmn model using the bpmn2-modeler plugin, here is the model (I removed the Diagram part to make it simpler):

<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:ext="http://org.eclipse.bpmn2/ext" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.4.2.Final-v20171109-1930-B1" targetNamespace="http://org.eclipse.bpmn2/default/process">
  <bpmn2:process id="simple1" name="Default Process" isExecutable="false">
    <bpmn2:startEvent id="StartEvent_1" name="Start Event 1">
      <bpmn2:extensionElements>
        <ext:style/>
      </bpmn2:extensionElements>
      <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
    </bpmn2:startEvent>
    <bpmn2:sequenceFlow id="SequenceFlow_1" name="Sequence Flow 1" sourceRef="StartEvent_1" targetRef="EndEvent_1"/>
    <bpmn2:endEvent id="EndEvent_1" name="End Event 1">
      <bpmn2:extensionElements>
        <ext:style/>
      </bpmn2:extensionElements>
      <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
    </bpmn2:endEvent>
  </bpmn2:process>
</bpmn2:definitions>


Once I run my transformation it fails, this is the error I get:

java.lang.NullPointerException
	at org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerResourceImpl$Bpmn2ModelerXMLSave.addNamespaceDeclarations(Bpmn2ModelerResourceImpl.java:1062)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:607)
	at org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerResourceImpl$Bpmn2ModelerXMLSave.traverse(Bpmn2ModelerResourceImpl.java:1493)
	at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:251)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:389)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
	at org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerResourceImpl.save(Bpmn2ModelerResourceImpl.java:296)
	at org.eclipse.m2m.atl.core.emf.EMFExtractor.extract(EMFExtractor.java:65)
	at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:141)
	at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
	at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)


I checked the code of that class, it seems that definitions is null:

line 1061 Definitions definitions = ModelUtil.getDefinitions(helper.getResource());
line 1062 String typeLanguage = definitions.getTypeLanguage();

I debug the rule "copyDefinitions" and I see it is copying elements correctly (see debug uploadad image).

Here is my transformation, I'd appreciate help to realize what I'm doing wrong.

-- @atlcompiler atl2010
-- @nsURI bpmn=http://www.omg.org/spec/BPMN/20100524/MODEL


module simpleCopy;
create out: bpmn from base: bpmn;

rule copyStartEvent {
	from
		se: bpmn!StartEvent in base
	to
		seOut: bpmn!StartEvent (
			id <- se.id,
			name <- se.name
		)
	do {
		se.debug('copySE ' + se.anyAttribute); 
	}
}

rule copyEndEvent {
	from
		ee: bpmn!EndEvent in base
	to
		eeOut: bpmn!EndEvent (
			id <- ee.id,
			name <- ee.name
		)
	do {
		ee.debug('copyEE ' + ee.anyAttribute); 
	}
}

rule copySequenceFlow {
	from
		sf: bpmn!SequenceFlow in base
	to
		sfOut: bpmn!SequenceFlow (
			id <- sf.id,
			name <- sf.name,
			sourceRef <- thisModule.resolveTemp(sf.sourceRef, 'seOut'),
			targetRef <- thisModule.resolveTemp(sf.targetRef, 'eeOut')
		)
	do {
		sf.debug('copySF ' + sf.anyAttribute); 
	}
}

rule copyProcess {
	from
		process: bpmn!Process in base
	to
		prOut: bpmn!Process (
			id <- process.id,
			name <- process.name,
			flowElements <- process.flowElements 
		)
	do {
		process.debug('copyProcess ' + process.anyAttribute); 
	}
}

--
rule copyDefinitions {
	from
		definition: bpmn!Definitions in base
	to
		defiOut: bpmn!Definitions (
			name <- definition.name,
			exporter <- definition.exporter,
			exporterVersion <- definition.exporterVersion,
			expressionLanguage <- definition.expressionLanguage,
			targetNamespace <- definition.targetNamespace,
			typeLanguage <- definition.typeLanguage,
			id <- definition.id,
			rootElements <- definition.rootElements
		)
	do {
		definition.debug('copyDefinitions ' + definition.rootElements); 
	}
}
  • Attachment: process.PNG
    (Size: 6.26KB, Downloaded 14 times)
  • Attachment: debug.PNG
    (Size: 32.39KB, Downloaded 16 times)
Re: NullPointerException after transformation [message #1782908 is a reply to message #1782888] Sun, 04 March 2018 20:01 Go to previous message
Gonzalo López is currently offline Gonzalo LópezFriend
Messages: 14
Registered: February 2018
Junior Member
I downloaded the source code and started debugging.

The NullPointerException is because the ModelUtil.getDefinitions method (org.eclipse.bpmn2.modeler.core.utils.ModelUtil) gets info from eContents and it is empty (attached image "eContents").
However, in the same breakpoint I can see that "contents" has the info (attached image "contents")

Is this because of something I'm doing wrong or the model creation never sets that field (eContents)?

Any ideas to make it work?

Thanks
  • Attachment: eContents.PNG
    (Size: 51.10KB, Downloaded 21 times)
  • Attachment: contents.PNG
    (Size: 54.47KB, Downloaded 20 times)
Previous Topic:Example TCS for OWL to RDF/XML serialization
Next Topic:[EMFTVM] generate model
Goto Forum:
  


Current Time: Tue Sep 25 14:34:20 GMT 2018

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

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

Back to the top