[Helma-user] problems loading resources from within jars

Robert Gaggl robert at helma.org
Mon Jan 29 10:03:36 CET 2007


hi stefan,

> I just tried to update the version of rome [1] I'm using for a  
> project and ran into some problems.
> I'm placing my project specific jars in a special repository of my  
> application - this worked fine so far - but in this case I got  
> Exceptions when rome tried this:
> 
> private static final String MASTER_PLUGIN_FILE = "com/sun/syndication/ 
> rome.properties"
> private static final String EXTRA_PLUGIN_FILE = "rome.properties";
> ...
> PROPERTIES_LOADER = new PropertiesLoader 
> (MASTER_PLUGIN_FILE,EXTRA_PLUGIN_FILE);
> 
> Then I move rome.jar from the repositry directory to the lib/ext  
> directory and there it worked fine - so it seems using repositories  
> for jars has some classpath/resource loading problems

the reason for this is that afaik helma uses different classloaders: 
everything placed in lib/ext is using the default classloader, but 
applications have their own (you can get this one with 
app.getClassLoader()).

because of this you'll run into problems if the java-library uses eg. 
Class.forName() or the like. if the library has been placed in the 
app-dir, it will be initially loaded using the application classloader, 
but Class.forName() will use the default classloader if no other has 
been specified - and the default classloader doesn't know anything about 
the desired class.

afaik the only way to circumvent these problems is to put the jar into 
lib/ext.

robert


More information about the Helma-user mailing list