Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] StandAlone generation
[Acceleo] StandAlone generation [message #685269] Fri, 17 June 2011 06:57 Go to next message
Thibaut   is currently offline Thibaut Friend
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 #685436 is a reply to message #685269] Fri, 17 June 2011 14:08 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

From this error message, I think that you should override the method "createTemplateURI(AbstractAcceleoGenerator.java:639)" to trim the protocol "rsrc:" in the Java launcher generated by Acceleo.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo] StandAlone generation [message #685463 is a reply to message #685436] Fri, 17 June 2011 14:50 Go to previous messageGo to next message
Thibaut   is currently offline Thibaut Friend
Messages: 3
Registered: June 2011
Junior Member
Hello,

Thank you for your help. It works, but now I have another exception.
I try to resolve it by myself because I don't think that it's due to Acceleo.

Thank you again
Re: [Acceleo] StandAlone generation [message #685882 is a reply to message #685463] Mon, 20 June 2011 13:57 Go to previous messageGo to next message
Thibaut   is currently offline Thibaut Friend
Messages: 3
Registered: June 2011
Junior Member
Hello.
As you have suggested, I have implemented an overriding "createTemplateURI" method. However, path to my emtl file is absolute (C:\\myApp\\....) because of the removing of "rsrc:" String of the uri.
Could you tell me how to override the "createTemplateURI" method to keep the portability of the application?

Thanks for your answers.
Re: [Acceleo] StandAlone generation [message #687904 is a reply to message #685882] Thu, 23 June 2011 13:41 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Thibaut,

You can try to use an URIConverter in the resource set of the module by overriding the method createURIConverter(). When EMF will try to load <my_resource_path>, you can then changed it by <rsrc:myresource_path>.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo] StandAlone generation [message #687997 is a reply to message #687904] Thu, 23 June 2011 16:35 Go to previous messageGo to next message
smaoui asma is currently offline smaoui asmaFriend
Messages: 50
Registered: July 2009
Location: Paris Saclay, France
Member
Hello,

I tried to do the same thing (running an acceleo generator using a shell command)
the first error that I have was this:

$ java -jar AcceleoGen.jar
Arguments not valid : {model, folder}.

when I specified the model and the folder I get this error

$ java -jar AcceleoGen.jar "/export/home/charfi/Documents/workspace_acceleo/model_test/model.uml" "/export/home/charfi/Documents/workspace_acceleo/model_test"
java.io.IOException: '/test_marte/common/generate.emtl' not found
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:409)
at test_marte.common.Generate.<init>(Generate.java:92)
at test_marte.common.Generate.main(Generate.java:139)

how can Thibaut run his jar file without specifying the 2 main arguments ? did you (Thibaut) use the initialize method of the Generate class?

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/])

thank you very much

Asma
Re: [Acceleo] StandAlone generation [message #689061 is a reply to message #687997] Sun, 26 June 2011 17:13 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

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 #689259 is a reply to message #689061] Mon, 27 June 2011 09:23 Go to previous messageGo to next message
smaoui asma is currently offline smaoui asmaFriend
Messages: 50
Registered: July 2009
Location: Paris Saclay, France
Member
Hello Stephane,

the generate.emtl exists in the bin directiry of my acceleo project but running the .jar still generate the same error. "java.io.IOException: '/test_marte/common/generate.emtl' not found"
the .jar file did not contains the generate.emtl, is there a special export command to export properly an acceleo project to a .jar or should I add manually the .emtl to my .jar ?


thank you very much

Asma

Re: [Acceleo] StandAlone generation [message #689270 is a reply to message #689259] Mon, 27 June 2011 09:58 Go to previous messageGo to next message
smaoui asma is currently offline smaoui asmaFriend
Messages: 50
Registered: July 2009
Location: Paris Saclay, France
Member
Hello,
I added the bin directory to the jar file by modifying the java build path.
and now I get a new error:

Exception in thread "main" java.lang.RuntimeException: Cannot create a resource for 'jar:file:/export/home/charfi/Bureau/AcceleoGen3.jar!/test_marte/common/generate.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:348)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:413)
at test_marte.common.Generate.<init>(Generate.java:93)
at test_marte.common.Generate.main(Generate.java:140)

Before exporting to .jar I run my acceleo project as a java application (run as java application and not acceleo application) and it works (I already add the UML package and the UML factory as follow:

resourceSet.getPackageRegistry().put(UMLPackage.eINSTANCE.getNsURI(), UMLPackage.eINSTANCE); // added to the registerPackages method of my generate class
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); // added to the registerResourceFactories method of my generate class

did I miss something

thank you very much

Asma

Re: [Acceleo] StandAlone generation [message #689298 is a reply to message #689270] Mon, 27 June 2011 11:35 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

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 #689319 is a reply to message #689298] Mon, 27 June 2011 12:40 Go to previous messageGo to next message
smaoui asma is currently offline smaoui asmaFriend
Messages: 50
Registered: July 2009
Location: Paris Saclay, France
Member
Hi Stephane,

the super.registerResourceFactory is not removed, I added the other resource as you suggest in your reply but I get the same error

could you please reproduce the error in your machine, I am creating a new acceleo project with reference to UML metamodel and my model contains only a class.

I am using mandriva 2010, Helios Service Release 2
Build id: 20110218-0911 and Acceleo 3.1.0. should I use instead Indigo ?

thank you very much

Asma
Re: [Acceleo] StandAlone generation [message #886394 is a reply to message #685269] Thu, 14 June 2012 21:04 Go to previous messageGo to next message
Raj Govindasamy is currently offline Raj GovindasamyFriend
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 #886397 is a reply to message #886394] Thu, 14 June 2012 21:16 Go to previous messageGo to next message
Raj Govindasamy is currently offline Raj GovindasamyFriend
Messages: 2
Registered: June 2012
Junior Member
Hi Stephane,

Adding more info...

I am using the following jars for running in standalone mode.

org.eclipse.core.runtime_3.7.0.v20110110.jar
org.eclipse.osgi_3.7.2.v20120110-1415.jar
org.eclipse.equinox.common_3.6.0.v20110523.jar
org.eclipse.core.jobs_3.5.101.v20120113-1953.jar
org.eclipse.core.runtime.compatibility.registry_3.5.0.v20110505/runtime_registry_compatibility.jar
org.eclipse.equinox.registry_3.5.101.R37x_v20110810-1611.jar
org.eclipse.equinox.preferences_3.4.2.v20120111-2020.jar
org.eclipse.core.contenttype_3.4.100.v20110423-0524.jar
org.eclipse.equinox.app_1.3.100.v20110321.jar
org.eclipse.emf.ecore_2.7.0.v20120127-1122.jar
org.eclipse.emf.common_2.7.0.v20120127-1122.jar
org.eclipse.emf.ecore.xmi_2.7.0.v20120127-1122.jar
org.eclipse.ocl_3.1.0.v20120206-0606.jar
lpg.runtime.java_2.0.17.v201004271640.jar
org.eclipse.ocl.ecore_3.1.2.v20111015-2027.jar
org.eclipse.acceleo.common_3.3.0.v20120529-1042.jar
org.eclipse.acceleo.model_3.3.0.v20120529-1042.jar
org.eclipse.acceleo.profiler_3.3.0.v20120529-1042.jar
org.eclipse.acceleo.engine_3.3.0.v20120529-1042.jar
org.eclipse.emf.codegen.ecore_2.7.0.v20120130-0943.jar
org.eclipse.emf.codegen_2.6.0.v20120130-0943.jar
com.google.guava_10.0.1.v201203051515.jar


Thanks in advance,

Raj
Re: [Acceleo] StandAlone generation [message #890129 is a reply to message #886397] Thu, 21 June 2012 08:41 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

If you know that you have XMI based emtl files (if you open one and it is a XML file), you could go directly for:

resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emtl", new EMtlResourceFactoryImpl());


in registerResourceFactories()


Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo] StandAlone generation [message #1092917 is a reply to message #890129] Fri, 23 August 2013 10:23 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 346
Registered: August 2013
Senior Member
I have exactly the same problem...

After adding this line
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emtl", new EMtlResourceFactoryImpl());

I get another exception:
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 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.io.FileNotFoundException: C:\Work\workspace\org.eclipse.acceleo.module.sample\rsrc%3Aorg\eclipse\acceleo\module\sample\main\example.emtl (Системе не удается найти указанный путь)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
	at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:361)
	at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:454)
	at org.eclipse.acceleo.module.sample.main.Example.<init>(Example.java:95)
	at org.eclipse.acceleo.module.sample.main.Example.main(Example.java:149)
	... 5 more
Caused by: java.io.FileNotFoundException: C:\Work\workspace\org.eclipse.acceleo.module.sample\rsrc%3Aorg\eclipse\acceleo\module\sample\main\example.emtl (Системе не удается найти указанный путь)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at org.eclipse.emf.ecore.resource.impl.FileURIHandlerImpl.createInputStream(FileURIHandlerImpl.java:99)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 10 more
Re: [Acceleo] StandAlone generation [message #1092918 is a reply to message #890129] Fri, 23 August 2013 10:23 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 346
Registered: August 2013
Senior Member
I have exactly the same problem...

After adding this line
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emtl", new EMtlResourceFactoryImpl());

I get another exception:
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 org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.io.FileNotFoundException: C:\Work\workspace\org.eclipse.acceleo.module.sample\rsrc%3Aorg\eclipse\acceleo\module\sample\main\example.emtl (Системе не удается найти указанный путь)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
	at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:361)
	at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.initialize(AbstractAcceleoGenerator.java:454)
	at org.eclipse.acceleo.module.sample.main.Example.<init>(Example.java:95)
	at org.eclipse.acceleo.module.sample.main.Example.main(Example.java:149)
	... 5 more
Caused by: java.io.FileNotFoundException: C:\Work\workspace\org.eclipse.acceleo.module.sample\rsrc%3Aorg\eclipse\acceleo\module\sample\main\example.emtl (Системе не удается найти указанный путь)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at org.eclipse.emf.ecore.resource.impl.FileURIHandlerImpl.createInputStream(FileURIHandlerImpl.java:99)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 10 more
Re: [Acceleo] StandAlone generation [message #1671735 is a reply to message #1092918] Fri, 13 March 2015 18:39 Go to previous message
Khdev Khdev is currently offline Khdev KhdevFriend
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

Previous Topic:Flatten Sequence(String) to String
Next Topic:Declaration Generation
Goto Forum:
  


Current Time: Mon Oct 07 11:13:56 GMT 2024

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

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

Back to the top