on 11-03-2006 9:59 PM
I have a war application that I've deployed as part of an EE 5 project. When I try to load resources from my application's classloader (e.g., loader.getResource("my_resource")), the reosurces are only located if they exist in a jar in WEB-INF/lib or if they're in WEB-INF/lib. If the resources are located in a folder in the top level of the jar, they're not found. If I move the resource folder to WEB-INF/classes, then the resources can be found.
Is there any way to have the classloader in NetWeaver locate files contained in top level folders in a war? The application runs on other servers where we don't see this issue.
Thanks,
Jerry
Hi Jerry,
I am not sure that accessing the resources from jars located in top level directories is according the spec.
Servlet 2.5 specification has a section dedicated to application class loaders SRV 9.7.2 that says:
<i>The class loader that a container uses to load a servlet in a WAR must allow the
developer to load any resources contained in library JARs within the WAR
following normal J2SE semantics using getResource.
</i>
And in SRV 9.5:
"<i>The Web application class loader must load classes from the WEB-INF/ classes
directory first, and then from library JARs in the WEB-INF/lib directory.</i>"
Therefore if you want to have access a resource within a jar files, the jar files should be stored under WEB-INF/lib or the resources should be present in WEB-INF/classes with precedence of the latter.
Regards
Nikolai Dokovski
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.