Search code examples
jsf-2weblogicshared-librariesfacelets

Access Facelets files from shared library in WebLogic


We are trying the main application to access the common Facelets files from shared library deployed in WebLogic.

The common Facelets files are in the below path in shared library:

META-INF->resources->common-ac->HelloWorld.xhtml

We access this in main application page as:

<ui:include src="/common-ac/HelloWorld.xhtml" /> 

However, this didn't work, it throws the following exception:

javax.faces.view.facelets.TagAttributeException: /....public/Home.xhtml @47,50 <ui:include src="/common-ac/HelloWorld.xhtml"> Invalid path : /common-ac/HelloWorld.xhtml
    at com.sun.faces.facelets.tag.ui.IncludeHandler.apply(IncludeHandler.java:125)

How is this caused and how can I solve it?


Solution

  • Using JAR's /META-INF/resources as a shared webapp resource is only supported since Servlet 3.0. So as long as you deploy your webapp to a Servlet 3.0 compatible container (e.g. WebLogic 12) with a web.xml which is declared conform Servlet 3.0 specification, then it should just work out the box.

    If you're however deploying your webapp to a non-Servlet 3.0 container (e.g. WebLogic 11 or older), or somehow can't declare your web.xml conform Servlet 3.0 spec, or the target container exposes a bug as to resource resolving from JARs (e.g. early JBoss 6 versions), then you'd need to create a custom Facelets resource resolver as detailed in this answer: How to create a modular JSF 2.0 application?