cancel
Showing results for 
Search instead for 
Did you mean: 

Locating resources

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

NikiD
Employee
Employee
0 Kudos

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

Answers (0)