在jar中找不到带注释的自定义JSF2组件 [英] Cannot find annotated custom JSF2 component in jar

查看:95
本文介绍了在jar中找不到带注释的自定义JSF2组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将JSF1.2迁移到JSF2应用程序,而我遇到了自定义组件的问题.我们有一个带有组件的单独的jar,在这个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 { ... }

在META-INF下的taglib中,我有这个:

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.sofico.be/jsf/mw"

然后:

<mw:panel2 />

但不幸的是结果是

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)

我在做什么错了?

推荐答案

  • 确保faces-config.xml中的JSF版本至少为版本2
  • 确保在faces-config.xml中没有设置为true的metadata-complete属性.
  • 确保该类位于WEB-INF/classes中;或者,如果在WEB-INF/lib中的jar中,则该jar中包含一个faces-config.xml(否则该规范不需要注释扫描)
  • 确保在XML配置文件中没有定义Panel2组件类型(此列表优先)
    • 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)
    • 请参见 JSF 2规范;第11.5.1节.

      See the JSF 2 spec; section 11.5.1.

      这篇关于在jar中找不到带注释的自定义JSF2组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆