Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find annotated custom JSF2 component in jar

We are migrating JSF1.2 to JSF2 application and I have bumped into a problem with custom components. We have a seperate jar with components, and in that jar I have this:

@FacesComponent(value = "Panel2")
public class Panel2 extends UIOutput { ... }

In my taglib under META-INF I have this:

<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
    id="mw">
    <namespace>http://www.ssss.be/jsf/mw</namespace>
    <composite-library-name>mw</composite-library-name>
    <tag>
        <tag-name>panel2</tag-name>
        <component>
            <component-type>Panel2</component-type>
        </component>
    </tag>
</facelet-taglib>

After making a jar of this all and use it in my other project, I use the tag as follows:

xmlns:mw="http://www.ssss.be/jsf/mw"

And then:

<mw:panel2 />

But the result is unfortunately:

javax.faces.FacesException: Expression Error: Named Object: Panel2 not found. at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1858)
at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1129)

What am I doing wrong here?

like image 878
Steven De Groote Avatar asked May 27 '11 10:05

Steven De Groote


1 Answers

  • ensure that the JSF version in faces-config.xml is at least version 2
  • ensure there isn't a metadata-complete attribute in faces-config.xml set to true.
  • ensure that the class is either in WEB-INF/classes; or, if in a jar in WEB-INF/lib, that the jar contains a faces-config.xml (the spec doesn't require annotation scanning otherwise)
  • ensure there isn't a Panel2 component-type defined in an XML configuration file (this listing will take precedence)

See the JSF 2 spec; section 11.5.1.

like image 121
McDowell Avatar answered Nov 10 '22 11:11

McDowell