1

I have created a composite component in JSF2. I works great.

I would like to create it as JAR for future use.

I followed the instructions here.

However, when it comes to CSS the browser refers to the location relatively to the project that uses the jar and not to the Jar location!

I defined it like this:

<h:outputStylesheet library="css" name="component.css" target="head" />

and I get this exception: GET http://localhost:8080/MY_APPLICATION/resources/component.css 404 (Not Found)

It's looking for it relatively to the projects, and not to the Jar project!

How can I make it relative to the JAR project?

EDITED

The JAR tree is:

META-INF
 --resource
   -- components
      myComp.xhtml
      components.css
   -- img
   -- scripts 
 --components.taglib.xml
 --faces.config.xml

The war is a regular dynamic project:

WEB-INF
--lib
  myJar.jar
-- web.xml
-- faces-config.xml
testComp.xhtml
1
  • Can you post the structure of your JAR file, and the WAR file that contains it? I have a feeling that either the JAR file doesn't contain the CSS stylesheet, or something else is amiss. Also, consider reading this answer posted a few hours back. I hope it will help you understand how resources are located at runtime. Commented Jul 28, 2011 at 10:46

2 Answers 2

7

Your JAR directory structure should be:

META-INF
 --resources
   -- components
        myComp.xhtml
   -- css                <-- The library defined in the stylesheet
        components.css   <-- A stylesheet resource in the library
   -- img
   -- scripts 
 --components.taglib.xml
 --faces.config.xml

Since, you are specifying the library name as css in the h:outputStylesheet tag with the resource name as component.css, the file should be present in a directory named css located in META-INF/resources directory of the JAR file.

Also, consider using a library name that is not bound to conflict with other names, if you intend to allow other developers to use your JAR.

Sign up to request clarification or add additional context in comments.

Comments

1

AFAIK, the resource needs to be located in the same directory as the composite component. Have you tried to put the css in the same library?

1 Comment

I put it in the same directory but it didn't help:(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.