[Acceleo] StandAlone generation [message #685269] |
Fri, 17 June 2011 06:57 |
Thibaut Messages: 3 Registered: June 2011 |
Junior Member |
|
|
Hello,
I use Acceleo (SDK 3.1.0.v20110601-0321).
I want to use my generator without eclipse. In eclipse my generator works. I have exported my generator in a runnable jar file. My generator contains java services. When I launch the jar:
$ java -jar Gen2cpp.jar
I get the following exception :
java.lang.IllegalArgumentException: invalid relative pathName: rsrc:fr/cpp/generator/generate.emtl
at org.eclipse.emf.common.util.URI.createFileURI(URI.java:856)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.createTemplateURI(AbstractAcceleoGenerator.java:639)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:411)
at fr.cpp.generator.Generate.<init>(Generate.java:96)
at fr.cpp.generator.Generate.main(Generate.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
What does it mean? How can I fix it? Is there a good way to create a valid runnable jar file?
Thanks for your answers.
[Updated on: Fri, 17 June 2011 14:07] Report message to a moderator
|
|
|
|
|
|
|
|
Re: [Acceleo] StandAlone generation [message #689061 is a reply to message #687997] |
Sun, 26 June 2011 17:13 |
|
charfi asma wrote on Thu, 23 June 2011 18:35
how can Thibaut run his jar file without specifying the 2 main arguments ? did you (Thibaut) use the initialize method of the Generate class?
Have a look at the generated Java launcher class of your generator. The message is coming from the "main" method. If you want to always use those two parameters, feel free to modify the generated Java class.
charfi asma wrote on Thu, 23 June 2011 18:35
How can I fix this error ?
why Acceleo looks for generate.emtl, is this means that Acceleo Compiler can not parse my generate.mtl ? it is the template created by default (contains only [aclass.name/])
The Acceleo compiler is used by the Acceleo tooling to compiled Acceleo modules ("mtl" files) into "emtl" files. In order to run a generation, you need those mtl files. They should be in the "bin" folder of your Acceleo project. If you have exported your Acceleo project as a "jar", you should make sure that the "emtl" files are inside.
Regards,
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
|
|
|
|
|
Re: [Acceleo] StandAlone generation [message #689298 is a reply to message #689270] |
Mon, 27 June 2011 11:35 |
|
Hi,
In the generated Java launcher, the method "registerResourceFactory" should call "super.registerResourceFactory" to ensure that the necessary resource factories used by Acceleo are registered. Are you sur ethat the call to "super.registerResourceFactory" has not been removed ? Otherwise, you'll need to register the following resource factories:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(IAcceleoConstants.BINARY_CONTENT_TYPE, new EMtlBinaryResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(IAcceleoConstants.XMI_CONTENT_TYPE, new EMtlResourceFactoryImpl());
Acceleo compiled modules (emtl files) are the abstract syntax tree of the Acceleo module serialized as an EMF model so we need resource factories for those "models".
Regards,
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
[Updated on: Mon, 27 June 2011 11:37] Report message to a moderator
|
|
|
|
Re: [Acceleo] StandAlone generation [message #886394 is a reply to message #685269] |
Thu, 14 June 2012 21:04 |
Raj Govindasamy Messages: 2 Registered: June 2012 |
Junior Member |
|
|
Hi Stephane,
I am getting the similar exception while running an "One Jar" runnable jar.
I am using Acceleo 3.3.0 RC2 on Indigo. Initially I tried to use maven plugin and could not succeed, so I am falling back to running on commandline mode.
C:\ modelcodegen> java -jar build/modelcodegen.jar Datamodel-V01.rdl src-gen
modelcodegen main entry point, args=[ Datamodel-V01.rdl, src-gen]
modelcodegen main is running
Generating Code : Model = Datamodel-V01.rdl Target Dir = src-gen
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.simontuffs.onejar.Boot.run(Boot.java:342)
at com.simontuffs.onejar.Boot.main(Boot.java:168)
Caused by: java.lang.RuntimeException: Cannot create a resource for 'jar:file:/build/modelcodegen.jar!/lib/ model.codegen_1.0.0.jar! /model/codegen/main/DataModel.emtl'; a registered resource factory is needed
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:394)
at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:361)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:454)
at model.codegen.main.DataModel.<init>(DataModel.java:96)
at model.codegen.main.DataModel.main(DataModel.java:150)
at model.codegen.main.modelcodegenMain.run(modelcodegenMain.java:30)
at model.codegen.main.modelcodegenMain.main(modelcodegenMain.java:20)
... 6 more
It works fine before creating one-jar on a standalone mode. I have also registered the package and resource factories as follows :
super.registerPackages(resourceSet);
if (!isInWorkspace(Rdl.RdlPackage.class)) {
resourceSet.getPackageRegistry().put(Rdl.RdlPackage.eINSTANCE.getNsURI(), Rdl.RdlPackage.eINSTANCE);
}
super.registerResourceFactories(resourceSet);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(IAcceleoConstants.BINARY_CONTENT_TYPE, new EMtlBinaryResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getContentTypeToFactoryMap().put(IAcceleoConstants.XMI_CONTENT_TYPE, new EMtlResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("rdl", new RdlResourceFactoryImpl());
Any help in resolving either maven build or runnable jar would be highly appreciated.
Thanks,
Raj
|
|
|
|
|
|
|
Re: [Acceleo] StandAlone generation [message #1671735 is a reply to message #1092918] |
Fri, 13 March 2015 18:39 |
Khdev Khdev Messages: 2 Registered: March 2015 |
Junior Member |
|
|
Hello,
for me, I have resolved this problem by implementing an overriding createTemplateURI (defined in AbstractAcceleoGenerator.java) method. In this method, you need to return the path of your *.emtl file as following :
return URI.createURI(@Path + "/generate.emtl");
let me know if it works for you.
[Updated on: Fri, 13 March 2015 18:39] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.06623 seconds