2

I'm using JSF 2 with my own built facelet tags and I have that tags defined in taglib files, named xxxx.taglib.xml. The project is divided in war modules, which are merged by Maven when it's built. So each project has his own taglibs and I want to have all of them in the resulting project. So that's the question, is there a way to use a wildcard to have access to every taglib files using a single expression in web.xml? Similar to that:

<context-param>
    <param-name>facelets.LIBRARIES</param-name>
    <param-value>classpath*:**/*.taglib.xml</param-value>
</context-param>

That should load every file which ends with .taglib.xml from /WEB-INF/classes directory, but it's not working. I'm using Tomcat 6. What am I missing?

Aritz
  • 30,971
  • 16
  • 136
  • 217

1 Answers1

4

This is not valid syntax. It has to be webcontent-relative paths, semicolonseparated. Your project and module/build setup is likely not entirely right.

Just create a standalone Java project which ends up as JAR in /WEB-INF/lib and put the taglib file in /META-INF folder. JSF will also scan every single JAR in /WEB-INF/lib if there's a /META-INF/*.taglib.xml and then auto-register it. You don't need a facelets.LIBRARIES context param for this. Put web resources like XHTML files in /META-INF/resources folder. Note that this is also exactly how component libraries like PrimeFaces works.

You may probably need to change Maven to fix the wrong build approach. It should build JARs of module projects and put them in /WEB-INF/lib of the target WAR file and absolutely not merge/overlay the loose files from separate projects in one big /WEB-INF/classes folder.

By the way, the facelets.LIBRARIES is Facelets 1.x specific and deprecated in JSF 2.x. Use instead javax.faces.FACELETS_LIBRARIES.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • BalusC, many thanks for the answer, I achieved to have it working putting the taglibs in a separate project which ends up in a JAR file. However I want to ask you, do you think that definitely it's better practice to put all my module projects in jar files? I mean, some of my modules will be bigger than the basic system itself, and I also build a war of them to maintain the structure of a web project. After I merge them with the basic system using Maven overlays. In this way I also get module's JSF annotations working with no more configuration. – Aritz Feb 05 '13 at 11:59
  • The size is not a valid concern whether it's a "best practice". Just do it the right way as recommended by the specification. – BalusC Feb 05 '13 at 12:00