1

I have a modular JSF application. Facelets are stored in the module in META-INF/resources. I added a custom FaceletsResourceResolver (as demonstrated in this post How to create a modular JSF 2.0 application?) and all of this works well with .xhtml - Files. Now I am trying to add other resources in the same fashion and it's not working.

Let's say I have this structure in the module:

/META-INF/resources
/META-INF/resources/foo
/META-INF/resources/foo/bar.xhtml
/META-INF/resources/foo/bar.js

Now the application resolves /foo/bar.xhtml just fine. But attempts to fetch /foo/bar.js simply fail with 404. I tried using

<h:outputScript library="modulename" name="foo/bar.js" />

as well as direct reference

<script language="text/javascript" src="/context/foo/bar.js"/>

both to no avail. I feel I am missing something. Can someone help me?

PS: using Apache Tomcat 6 and Eclipse-Juno for development.

Community
  • 1
  • 1
Jürgen Simon
  • 876
  • 1
  • 12
  • 35

1 Answers1

0

I'll ignore the fact that the mentioned versions in your question in its current form is confusing. JSF 2.2 (as you tagged) requires a minimum of Servlet 3.0. Tomcat 6 (as you mentioned) is a Servlet 2.5 container (and a quite old one either). This is not going to work together. Also noted should be that the FaceletsResourceResolver which you found there is only necessary when you're using Servlet 2.5 or are using a very early JBoss AS 6 version.


The library name does here not represent the JAR file name, but the subfolder where all of those resources commonly belong to. So when you have a

<h:outputScript library="modulename" name="foo/bar.js" />

then the following structure is expected in the JAR:

/META-INF/resources/modulename
/META-INF/resources/modulename/foo
/META-INF/resources/modulename/foo/bar.xhtml
/META-INF/resources/modulename/foo/bar.js

Alternatively, you can keep your original structure and use

<h:outputScript library="foo" name="bar.js" />

depending on the meaning of the actual value of foo.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555