Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Solved][XPand+MWE] Execute MWE(v1.2.1) programmatically
[Solved][XPand+MWE] Execute MWE(v1.2.1) programmatically [message #1707549] Mon, 07 September 2015 09:17 Go to next message
Zheng Cheng is currently offline Zheng ChengFriend
Messages: 15
Registered: February 2012
Junior Member
Hello,

My question is how to properly register a metamodel that contains multiple EPackage in MWE?

Everything is fine when I work with XPand+MWE inside Eclipse. But not after I have this simple Java code to execute my XPand+MWE file outside Eclipse.
File f = new File(file);
URI fileURI = URI.createFileURI(f.getAbsolutePath());

Map<String, String> properties = new HashMap<String, String>();
properties.put("model", fileURI.toString());
properties.put("src-gen",srcGenPath);
WorkflowRunner wr = new WorkflowRunner();
wr.run(workflowName, null, properties, null);


Here is the MWE file I execute:
<?xml version="1.0"?>
<workflow>
	<!-- set up EMF for standalone execution -->
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
		<RegisterEcoreFile value="ATL.ecore"/>
	</bean>
	
	<!-- instantiate metamodel -->
	<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>


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

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


The error trace I got at runtime like this:
90   INFO  WorkflowEngine     - running workflow: apply.mwe
91   INFO  WorkflowEngine     - 
297  INFO  StandaloneSetup    - Registering platform uri 'E:\NEW'
328  WARN  StandaloneSetup    - No projects found in platform location '..'
because there are no '.project' files.
Please use explicit project mappings:
    projectMapping = { projectName = 'com.acme' path = '../path/com.acme' }.
510  INFO  StandaloneSetup    - Adding dynamic EPackage 'http://www.eclipse.org/gmt/2005/ATL' from 'ATL.ecore'
510  INFO  StandaloneSetup    - Adding dynamic EPackage 'http://www.eclipse.org/gmt/2005/OCL' from 'ATL.ecore'
510  INFO  StandaloneSetup    - Adding dynamic EPackage 'http://www.eclipse.org/gmt/2005/ATL-PrimitiveTypes' from 'ATL.ecore'
600  INFO  CompositeComponent - Reader: Loading model from ER2REL.xmi
627  INFO  CompositeComponent - Generator: generating 'template::atlApply2boogie::main FOR model' => /gen/
658  ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component  of type org.eclipse.xpand2.Generator: 
	EvaluationException : No Definition 'template::atlApply2boogie::main for ATL::Module' found!
	[23,48] on line 1 'EXPAND template::atlApply2boogie::main FOR model'

658  ERROR WorkflowEngine     - Workflow interrupted. Reason: No Definition 'template::atlApply2boogie::main for ATL::Module' found!
658  ERROR WorkflowEngine     - [ERROR]: No Definition 'template::atlApply2boogie::main for ATL::Module' found!(Element: EXPAND template::atlApply2boogie::main FOR model; Reported by: Generator: generating 'template::atlApply2boogie::main FOR model' => /gen/)


[510] indicates the EPackages of my ATL metamodel are registered. However, it seems not match with my XPand template. Here is my template::atlApply2boogie::main:
«IMPORT ATL»
«IMPORT OCL»

«REM» «DEFINE main FOR ATL::Module-» NOT WORK EITHER «ENDREM» 
«DEFINE main FOR Module-»
«FILE "ATL_apply_single.bpl"-»

«EXPAND printApplyerForMatchRule FOREACH elements-»

«ENDFILE-»
«ENDDEFINE»
...


I wonder what is the problem here. Any suggestions are welcome. Thanks a lot.

Zheng
  • Attachment: ATL.ecore
    (Size: 32.48KB, Downloaded 234 times)

[Updated on: Fri, 25 September 2015 15:39]

Report message to a moderator

Re: [XPand+MWE] Execute MWE(v1.2.1) programmatically [message #1707557 is a reply to message #1707549] Mon, 07 September 2015 11:10 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Looks for me as if your template is not on the classpath. The metamodel is detected fine, but Xpand does not find the template. Please make sure that the classpath contains the "template" folder at its root.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: [XPand+MWE] Execute MWE(v1.2.1) programmatically [message #1707561 is a reply to message #1707557] Mon, 07 September 2015 11:31 Go to previous messageGo to next message
Zheng Cheng is currently offline Zheng ChengFriend
Messages: 15
Registered: February 2012
Junior Member
Hi Karsten, thank you for your reply.

Not sure it's the classpath. The Java snippet I shown is actually export with other XPAND tempaltes as a jar.

Thus, they should be included when I do java -jar xxx.jar, Right?

Besides, the bizarre thing is that this jar is executable to my other templates whose metamodel is load by default. It only fails when I load ecore metamodel that contains multiple EPackages.
Re: [XPand+MWE] Execute MWE(v1.2.1) programmatically [message #1707972 is a reply to message #1707561] Fri, 11 September 2015 06:11 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Debug into org.eclipse.xtend.expression.ResourceManagerDefaultImpl, there the Xpand resource will be loaded. This fails for your case. By default, resources are loaded from the classpath, and I guess you are using defaults.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: [XPand+MWE] Execute MWE(v1.2.1) programmatically [message #1709284 is a reply to message #1707972] Fri, 25 September 2015 15:39 Go to previous message
Zheng Cheng is currently offline Zheng ChengFriend
Messages: 15
Registered: February 2012
Junior Member
Thank you Karsten. I found the problem, it is actually caused by my careless. The template name referred by mwe file is actually case sensitive.
I have no template named atlApply2boogie, it should be atlApply2Boogie
Previous Topic:Xtend files compile in plugin environment
Next Topic:[ACCELEO] Maven generate Standalone not able to access applied profile
Goto Forum:
  


Current Time: Mon Oct 07 06:08:22 GMT 2024

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

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

Back to the top