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 13:04 Go to next message
Joel Gluth is currently offline Joel Gluth
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(ResourceSetImpl.java:394)
	at org.eclipse.acceleo.common.utils.ModelUtils.load(ModelUtils.java:358)



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
}


Razz

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 13: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 03:57 Go to previous message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

Thanks for reporting this issue with that level of details, I have opened a bugzilla entry for it (https://bugs.eclipse.org/bugs/show_bug.cgi?id=378443) in order to track the work on this task and I'll look into it in the days to come.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Previous Topic:[Acceleo] Problem when splitting templates into different plugins
Next Topic:[Galileo, XPAND] Loop using the expression FOREACH
Goto Forum:
  


Current Time: Sat Apr 19 00:34:22 EDT 2014

Powered by FUDForum. Page generated in 0.01491 seconds