Apache MyFaces CODI PageBean:“参数 bean 不得为空”
我目前正在尝试使用 Apache MyFaces CODI。我设法使用 @Page 和返回类的操作方法创建了一个简单的工作类型安全导航。
但是,当我使用例如 MyPageBean.class 添加 @PageBean-Annotation 时,当我尝试导航到该页面时,会引发以下异常:
exception
javax.servlet.ServletException: WELD-001324 Argument bean must not be null
root cause
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null
我的页面的代码是:
@Page
@PageBean(MyPageBean.class)
public final class MyPage implements ViewConfig, Serializable {
}
和我的页面 Bean:
public class MyPageBean implements Serializable {
@InitView
protected void initView() { }
@PrePageAction
protected void prePageAction() { }
@PreRenderView
protected void preRenderView() { }
}
以及操作方法由 Facelets 页面调用:
public Class<? extends ViewConfig> nextPage() {
return MyPage.class;
}
pageBean 类 (MyPageBean) 是否需要具有特定的注释或接口?我已经尝试过使用 @Model 但这并没有改变任何东西。
我的配置:
- Jave EE6 with Weld(使用焊接原型创建)
- Glassfish 3.1 Community Edition(Netbeans 7 附带的版本)
- JSF2.0 (Mojarra 2.1)
- EJB 3.1
- MyFaces CODI 0.9.4
- RichFaces 4.0.0.Final
感谢您的任何帮助意见!
此致, 罗伯特
I'm currently experimenting a little with Apache MyFaces CODI. I managed to create a simple working Typesafe-Navigation using @Page and an action Method which returns a Class.
However, when I'm adding an @PageBean-Annotation with e.g. MyPageBean.class, the following exception is thrown when I try to navigate to the page:
exception
javax.servlet.ServletException: WELD-001324 Argument bean must not be null
root cause
org.jboss.weld.exceptions.IllegalArgumentException: WELD-001324 Argument bean must not be null
The code of my page is:
@Page
@PageBean(MyPageBean.class)
public final class MyPage implements ViewConfig, Serializable {
}
and my Page-Bean:
public class MyPageBean implements Serializable {
@InitView
protected void initView() { }
@PrePageAction
protected void prePageAction() { }
@PreRenderView
protected void preRenderView() { }
}
And the Action-Method called by the Facelets Page:
public Class<? extends ViewConfig> nextPage() {
return MyPage.class;
}
Does the pageBean-Class (MyPageBean) need to have a specific annotation or interface? I already tried using @Model but this didn't change anything.
My Configuration:
- Jave EE6 with Weld (created using the weld-archetype)
- Glassfish 3.1 Community Edition (The one shipped with Netbeans 7)
- JSF2.0 (Mojarra 2.1)
- EJB 3.1
- MyFaces CODI 0.9.4
- RichFaces 4.0.0.Final
Thanks for any advices!
Best regards,
Robert
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不使用任何特定范围,它将最终成为@Dependent。
我建议至少使用@RequestScoped(注意,不要使用javax.faces.bean.RequestScoped,而是使用CDI 的注释!)
Oki,现在与Gerhard 进行了交谈,因为他对Weld 上的CODI 有更多的经验。
显然,这似乎是您使用的焊接版本中的错误。这应该在weld-1.1.1.Final https://github.com 中工作/weld/core/tree/1.1.1.Final
请尝试将 glassfish 中的weld-osgi-bundle 替换为weld 1.1.1.Final
cp target/weld-osgi-bundle-1.1 中的weld-osgi-bundle。 1.jar /opt/sun/glassfish/glassfish/modules/weld-osgi-bundle.jar
如果有效:积分转到 os890 ;)
If you don't use any specific scope, it will end up being @Dependent.
I suggest to at least use @RequestScoped (take care, don't use the javax.faces.bean.RequestScoped, but the annontation from CDI!)
Oki, talked with Gerhard now as he has more experience with CODI on Weld.
Apparently this seems to be an error in the Weld version you use. This should be working in weld-1.1.1.Final https://github.com/weld/core/tree/1.1.1.Final
Please try to replace the weld-osgi-bundle in your glassfish with the one from weld 1.1.1.Final
cp target/weld-osgi-bundle-1.1.1.jar /opt/sun/glassfish/glassfish/modules/weld-osgi-bundle.jar
if it works: credits go to os890 ;)