Mantis - Resin
Viewing Issue Advanced Details
1095 major always 05-11-06 06:38 05-11-06 12:20
closed 3.0.18  
none 3.0.19  
0001095: Resin class loader doesn't find resources from jar
Our application loads Hibernate mapping files using Spring PathMatchingResourcePatternResolver class, with a pattern like "com/example/package/**/*.hbm.xml". The Spring pattern resolver then calls ClassLoader.getResources("com/example/package/") to first find all the resources under that location and then apply the given pattern **/*.hbm.xml in order to get only the mapping files.

When running as a standalone application (using the Sun class loader), the ClassLoader.getResources() call works as Spring expects. But when running under Resin, no resources are returned by the call.

The problem seems to be that if the resources are in a jar file in the classpath, com.caucho.loader.DynamicClassLoader.findResources() only accepts resource names that resolve to real files in the jar. Indeed when loading a single mapping file with ClassLoader.getResources("com/example/package/subpackage/Class.hbm.xml") there is no problem under Resin.

The classpath to the jar is defined resin.conf:
(the jar containing the mapping files is under ${APP_HOME}/lib)

-- snip --
        <tree-loader path="${server.rootDirectory}/ext-webapp"/>
        <library-loader path="${APP_HOME}/lib"/>
-- snip --

If the jar is appended to global CLASSPATH environment variable before starting the Resin, there is no problem. I guess that's because the resources are loaded using the default JVM system class loader in that case.

05-11-06 12:20