Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo] unable to load JAR-packaged EMTLs on unix(works on Windows though)
[acceleo] unable to load JAR-packaged EMTLs on unix [message #869597] Thu, 03 May 2012 17:04 Go to next message
Joel Gluth is currently offline Joel GluthFriend
Messages: 5
Registered: May 2012
Junior Member
(This is not urgent, I have a workaround, but it's worth mentioning).

I have an Acceleo project that functions as a Maven plugin, and when deployed on Windows, it works as expected.

On Linux, though, I get errors of the form:

[INFO] --- uml2whatever-maven-plugin:1.0.7-SNAPSHOT:generate-client (generate) @ whatever-client ---
java.lang.RuntimeException: Cannot create a resource for 'jar:file:/home/joel/.m2/repository/com/whatever/maven/plugin/uml2whatever-maven-plugin/1.0.7-SNAPSHOT/uml2whatever-maven-plugin-1.0.7-SNAPSHOT.jar!/com/whatever/api/client/clientGenerate.emtl'; a registered resource factory is needed
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(
	at org.eclipse.acceleo.common.utils.ModelUtils.load(

Some digging around reveals that I am falling back on a method in AcceleoResourceFactoryRegistry, called calculateFactory(). In particular, it attempts to derive a path to the JAR file from the URI, with code like this:

String jarPrefix = "jar:file:/"; //$NON-NLS-1$
String jarSeparator = "!/"; //$NON-NLS-1$

if (path.startsWith(jarPrefix) && path.contains(jarSeparator)) {
    String jarPath = path.substring(jarPrefix.length(), path.indexOf(jarSeparator));

Ie., it trims the leading slash after 'file:'.

This works on Windows, because you can trim the leading slash and end up with a path like "C:/home/joel/whatever...". On Unix and friends, it turns it into a relative path, which doesn't exist. It tries to find a JAR at "home/joel/.m2/repository/com/whatever/maven/plugin/uml2whatever-maven-plugin/1.0.7-SNAPSHOT/uml2whatever-maven-plugin-1.0.7-SNAPSHOT.jar", and, since I'm not building at the filesystem root, it doesn't.

What made this hard to find was

} catch (IOException e) {
    // do not log, the jar does not exists


My workaround has been to explicitly add

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

to my Generate classes' registerResourceFactories() methods, since I know in advance that I am using the XMI serialization format, but it's not ideal.

Is this worth adding to bugzilla? Non-portable Java code seems like a bug to me.

[Updated on: Thu, 03 May 2012 17:05]

Report message to a moderator

Re: [acceleo] unable to load JAR-packaged EMTLs on unix [message #869747 is a reply to message #869597] Fri, 04 May 2012 07:57 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member


Thanks for reporting this issue with that level of details, I have opened a bugzilla entry for it ( in order to track the work on this task and I'll look into it in the days to come.


Stephane Begaudeau, Obeo

Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Acceleo Documentation:
Previous Topic:[Acceleo] Problem when splitting templates into different plugins
Next Topic:[Galileo, XPAND] Loop using the expression FOREACH
Goto Forum:

Current Time: Wed Jul 06 15:28:51 GMT 2022

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

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

Back to the top