开发者

Cannot find annotated custom JSF2 component in jar

开发者 https://www.devze.com 2023-03-08 22:54 出处:网络
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:

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">
    <namesp开发者_StackOverflow中文版ace>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?


  • 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号