JSF 配置注释未处理
我正在 JBoss AS 6 上运行 JSF 2 应用程序
。不知何故,容器不会处理注释,例如 @FacesComponent 或 @FacesValidator 等。如果我用 @FacesValidator("fooValidator")
注释 Bean 并尝试将某些组件上的 validatorId
设置为 "fooValidator"
我得到:
Caused by: javax.faces.FacesException: Expression Error: Named Object: fooValidator not found.
at com.sun.faces.application.ApplicationImpl.createValidator(ApplicationImpl.java:1530) [:2.0.3-]
...
但是,如果我添加
<validator>
<validator-id>fooValidator</validator-id>
<validator-class>foo.MyClass</validator-class>
</validator>
到我的faces-config.xml,一切都会按预期工作。组件和转换器也是如此。
知道为什么注释没有被处理吗?我没有主意...
提前谢谢...
I am running a JSF 2 application on JBoss AS 6.
Somehow the Annotations, like @FacesComponent or @FacesValidator, etc are not processed by the container. If I annotate a Bean with @FacesValidator("fooValidator")
and try to set the validatorId
on some component to "fooValidator"
I get:
Caused by: javax.faces.FacesException: Expression Error: Named Object: fooValidator not found.
at com.sun.faces.application.ApplicationImpl.createValidator(ApplicationImpl.java:1530) [:2.0.3-]
...
However, If I add
<validator>
<validator-id>fooValidator</validator-id>
<validator-class>foo.MyClass</validator-class>
</validator>
To my faces-config.xml
everything works as expected. Same goes for components and converters.
Any idea why the annotations are not processed? I am out of ideas...
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
知道了。它与此非常相似: 为什么不“JSF 2.0 RI (Mojarra) 扫描我的类”注释吗?
我的项目使用 skinny war,所以war中的lib文件夹为空/不存在。更糟糕的是,控制器豆并不位于战争中,而是位于一个单独的罐子中。由于此 jar 不在 war 中,因此 jsf 注释处理器不会扫描它。
我想,我会重组这个项目,并可能放弃这场瘦身战争。那应该解决它。
Got it. It is very similar to this one: Why doesn't JSF 2.0 RI (Mojarra) scan my class' annotations?
My project uses a skinny war, so the lib folder in the war is empty/nonexistent. And to make it worse, the Controller Beans are not located in the war but in a seperate jar. As this jar is not in the war, the jsf annotation processor does not scan it.
I guess, I will restructure the project and likely throw out the skinny war. That should fix it.
那么,您在托管 bean 上使用的是
@Named
而不是@ManagedBean
吗? :)如果
faces-config.xml
未声明为符合 JSF 2.0 规范,则可能会发生这种情况。确保根声明如下所示:So, you were using
@Named
instead of@ManagedBean
on your managed beans? :)This can happen if the
faces-config.xml
is not declared conform JSF 2.0 spec. Ensure that the root declaration look like this: