Hi,
Could someone tell me how to make the following snippet
work?
Process bpelProcess = BPELFactory.eINSTANCE.createProcess();
Variables variables = BPELFactory.eINSTANCE.createVariables();
Variable variable = BPELFactory.eINSTANCE.createVariable();
variable.setName("foo");
XSDSimpleTypeDefinition type =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
type.setName("xsd:string");
variable.setType(type);
variables.getChildren().add(variable);
bpelProcess.setVariables(variables);
When executing to the second line from the bottom, I’d get
this exception:
Exception in thread "main" java.lang.NullPointerException
at org.eclipse.bpel.model.util.ReconciliationHelper.patchParentElement(ReconciliationHelper.java:481)
at
org.eclipse.bpel.model.impl.VariablesImpl.adoptContent(VariablesImpl.java:176)
at
org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl.eNotify(WSDLElementImpl.java:392)
at
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
at
org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:626)
It seems that ReconciliationHelper assumes that
“variables” has a container, which won’t be true until the
last line is called. But if I move the last line to the third, like this:
Process bpelProcess = BPELFactory.eINSTANCE.createProcess();
Variables variables = BPELFactory.eINSTANCE.createVariables();
bpelProcess.setVariables(variables);
Variable variable = BPELFactory.eINSTANCE.createVariable();
variable.setName("foo");
XSDSimpleTypeDefinition type =
XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
type.setName("xsd:string");
variable.setType(type);
variables.getChildren().add(variable);
ReconciliationHelper will throw
another exception:
Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.bpel.model.util.ReconciliationHelper.getBPELChildElementByLocalName(ReconciliationHelper.java:506)
at
org.eclipse.bpel.model.util.ReconciliationHelper.patchParentElement(ReconciliationHelper.java:481)
at
org.eclipse.bpel.model.impl.VariablesImpl.adoptContent(VariablesImpl.java:176)
at
org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl.eNotify(WSDLElementImpl.java:392)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:249)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
at
org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:626)
This time ReconciliationHelper
assumed that the BPEL model has an associated XML element, which is again not
correct in this case.
Maybe I’m just not using the
BPEL models correctly, but this code used to work with the M2 build. What would
I need to do to fix this? By the way, I’m not on this mailing list, so
please reply to me directly.
Thanks,
Hanyu