Reputation: 321
I have a common shared Library (that is setup as a Shared Library in Websphere Application server).
The folder structure of that jar is:
UtilityJAR
----src
-com
-test
-TestClass.java
---- META-INF
-resources
-template.xhtml
-css
-style.css
In my web Project, I have a template client file called User.xhtml that uses the template file from the above Shared Library using
ui:composition template="/template.xhtml"
When I have the above jar file in the WEB-INF/lib folder of the Web application, the application works fine without any issues (template.xhtml is recognized). When I remove the jar from the Lib folder of this application and put it as a Shared Library in Websphere (because I need this jar file from more than 4 applications and I don't want to copy this jar in all the 4 applications), I get the following error message.
[9/24/14 14:09:17:936 EDT] 00000113 ServletWrappe E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0014E: Uncaught service() exception root cause Faces Servlet: java.io.FileNotFoundException: /template.xhtml Not Found in ExternalContext as a Resource
The Utility jar has faces-config in it and has @ManagedBean annotations that work when the jar is inside the application's WEB-INF/lib folder.
Anybody faced this problem before? thanks for your help.
Upvotes: 4
Views: 1628
Reputation: 1108742
Web fragment JARs containing webapp resources MUST be placed in webapp's /WEB-INF/lib
.
From Servlet 3.0 specification page 37 (emphasis mine):
4.6 Resources
...
The
getResource
andgetResourceAsStream
methods take a String with a leading“/”
as an argument that gives the path of the resource relative to the root of the context or relative to the META-INF/resources directory of a JAR file inside the web application’s WEB-INF/lib directory. These methods will first search the root of the web application context for the requested resource before looking at any of the JAR files in the WEB-INF/lib directory. The order in which the JAR files in the WEB-INF/lib directory are scanned is undefined. This hierarchy of documents may exist in the server’s file system, in a Web application archive file, on a remote server, or at some other location....
If you really want to place them elsewhere (bad idea!), then you'd need to homegrow a custom Facelets resource resolver. You can find a kickoff example here: How to create a modular JSF 2.0 application?
Upvotes: 5