Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Referenced metamodel workflow
[Xpand] Referenced metamodel workflow [message #510081] Tue, 26 January 2010 13:45 Go to next message
Marcel  is currently offline Marcel Friend
Messages: 54
Registered: July 2009
Member
I am trying to generate code from a model using Xpand.
The model conforms to a metamodel that references another metamodel.

When I run the workflow I normally use for generating code with Xpand, I get a java.lang.NullPointerException.

The workflow is as follows:
<workflow>
  <property name="model" value="TemporalLogicPrettyPrinter/src/My.temporallogic"/>
  <property name="src-gen" value="src-gen"/>

  <!-- set up EMF for standalone execution -->
  <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup">
    <platformUri value=".."/>
    <registerEcoreFile value="platform:/resource/TemporalLogicPrettyPrinter/src/metamodel/temporallogic.ecore"/>
    <registerEcoreFile value="platform:/resource/TemporalLogicPrettyPrinter/src/metamodel/slco.ecore"/>
  </bean>

  <!-- load model and store it in slot 'model' -->
  <component class="org.eclipse.emf.mwe.utils.Reader">
    <uri value="platform:/resource/${model}"/>
    <modelSlot value="model"/>
  </component>

  <!--  generate code -->
  <component class="org.eclipse.xpand2.Generator">
    <metaModel id="mm" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
    <expand value="template::TemporalLogicPrettyPrinter::generateprettyPrint FOR model"/>
    <outlet path="${src-gen}"/>
  </component>
</workflow>


The metamodel temporallogic.ecore references the slco.ecore metamodel.

The complete error message I get is as follows:
Quote:

0 INFO WorkflowRunner - ------------------------------------------------------------ --------------------------
0 INFO WorkflowRunner - EMF Modeling Workflow Engine 0.7.2, Build v200908120417
0 INFO WorkflowRunner - (c) 2005-2009 openarchitectureware.org and contributors
0 INFO WorkflowRunner - ------------------------------------------------------------ --------------------------
0 INFO WorkflowRunner - running workflow: D:/Eclipse Workspaces/NQC_project/mm-runtime/TemporalLogicPrettyPrinter /src/workflow/TemporalLogicPrettyPrinter.mwe
0 INFO WorkflowRunner -
297 INFO StandaloneSetup - Registering platform uri 'D:\Eclipse Workspaces\NQC_project\mm-runtime'
406 INFO StandaloneSetup - Adding dynamic EPackage 'temporallogic' from 'platform:/resource/TemporalLogicPrettyPrinter/src/metamodel /temporallogic.ecore'
421 INFO StandaloneSetup - Adding dynamic EPackage 'slco' from 'platform:/resource/TemporalLogicPrettyPrinter/src/metamodel /slco.ecore'
499 INFO CompositeComponent - Reader: Loading model from platform:/resource/TemporalLogicPrettyPrinter/src/My.tempora llogic
515 ERROR WorkflowRunner -
java.lang.NullPointerException
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:2156)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2034)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHa ndler.java:134)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1839)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:169)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at org.eclipse.emf.mwe.utils.Reader.load(Reader.java:54)
at org.eclipse.emf.mwe.utils.Reader.invokeInternal(Reader.java: 37)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invok e(AbstractWorkflowComponent.java:124)
at org.eclipse.emf.mwe.core.container.CompositeComponent.intern alInvoke(CompositeComponent.java:101)
at org.eclipse.emf.mwe.core.container.CompositeComponent.invoke (CompositeComponent.java:86)
at org.eclipse.emf.mwe.core.WorkflowRunner.executeWorkflow(Work flowRunner.java:412)
at org.eclipse.emf.mwe.core.WorkflowRunner.run(WorkflowRunner.j ava:292)
at org.eclipse.emf.mwe.core.WorkflowRunner.main(WorkflowRunner. java:239)




Does anybody have an idea what I am doing wrong?
Re: [Xpand] Referenced metamodel workflow [message #510100 is a reply to message #510081] Tue, 26 January 2010 09:36 Go to previous messageGo to next message
Erhard Weinell is currently offline Erhard WeinellFriend
Messages: 39
Registered: January 2010
Location: Kassel, Germany
Member
Hello Marcel,

Am 26.01.2010 14:45, schrieb Marcel:

> Does anybody have an idea what I am doing wrong?

given your stacktrace, EMF seems to have trouble in finding your
metamodels. Did you try to open the instance model in the reflective
editor and have it validated? Maybe the resource URLs are broken.

Best regards,
Erhard Weinell
Re: [Xpand] Referenced metamodel workflow [message #510107 is a reply to message #510100] Tue, 26 January 2010 14:49 Go to previous messageGo to next message
Marcel  is currently offline Marcel Friend
Messages: 54
Registered: July 2009
Member
Hello Erhard,

Validation reports no errors or warnings.
I exported my metamodels as plugins.

Regards,

Marcel
Re: [Xpand] Referenced metamodel workflow [message #510171 is a reply to message #510081] Tue, 26 January 2010 10:46 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Marcel schrieb:
> <registerEcoreFile
> value=" platform:/resource/TemporalLogicPrettyPrinter/src/metamodel/ temporallogic.ecore "/>
>
> <registerEcoreFile
> value=" platform:/resource/TemporalLogicPrettyPrinter/src/metamodel/ slco.ecore "/>
>

I assume that one ecore references the other?
How does the reference look like, i.e. can you post the URI?

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xpand] Referenced metamodel workflow [message #510334 is a reply to message #510171] Wed, 27 January 2010 10:09 Go to previous message
Marcel  is currently offline Marcel Friend
Messages: 54
Registered: July 2009
Member
Hi,

The metamodel part where the reference is used is as follows:

<eClassifiers xsi:type="ecore:EClass" name="AtomicProposition" eSuperTypes="#//PathFormula">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="ComparisonOperator" lowerBound="1" eType="#//ComparisonOperators"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="Variable" lowerBound="1" eType="ecore:EClass platform:/plugin/slco.emf/model/slco.ecore#//Variable"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="Value" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
  </eClassifiers>


I managed to get it to work using a totally different workflow:
<workflow>
  <property name="model" value="My.temporallogic"/>
  <property name="targetdir" value="src-gen"/>

  <component class="org.eclipse.emf.mwe.utils.Reader">
    <uri value="src/${model}"/>
    <modelSlot value="LTLFormula"/>
  </component>

  <component class='org.eclipse.xpand2.Generator'>
    <metaModel id="temporallogic" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
      <metaModelPackage value="temporallogic.TemporallogicPackage"/>
    </metaModel>
    <metaModel id="slco" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
      <metaModelPackage value="slco.SlcoPackage"/>
    </metaModel>
    <expand value='template::TemporalLogicPrettyPrinter::prettyPrint FOR LTLFormula'/>
    <genPath value='${targetdir}'/>
  </component>

</workflow>


Thanks for your help!
Re: [Xpand] Referenced metamodel workflow [message #510407 is a reply to message #510334] Wed, 27 January 2010 08:12 Go to previous message
Erhard Weinell is currently offline Erhard WeinellFriend
Messages: 39
Registered: January 2010
Location: Kassel, Germany
Member
Am 27.01.2010 11:09, schrieb Marcel:
> Hi,
>
> The metamodel part where the reference is used is as follows:
[...]

Have you tried the org.eclipse.emf.ecore.dynamic_package extension point
to register your metamodel in the EMF registry? Might be more robust.
Currently, your referencing metamodel will break if source paths in the
referenced metamodel are changed. This may as well solve your initial
problem.

>
> I managed to get it to work using a totally different workflow:
>
> <workflow>
> <property name="model" value="My.temporallogic"/>
> <property name="targetdir" value="src-gen"/>
>
> <component class="org.eclipse.emf.mwe.utils.Reader">
> <uri value="src/${model}"/>
> <modelSlot value="LTLFormula"/>
> </component>

For curiosity, could you try this directory schema ("src/${model}") in
your previous workflow? There you used the platform/resource schema.

Best regards,
Erhard Weinell
Previous Topic:Is XSD adapter compatible with Xpand2 0.8M4?
Next Topic:[XTEND] Reference to imported model not resolved
Goto Forum:
  


Current Time: Thu Oct 03 23:33:30 GMT 2024

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

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

Back to the top