Apache MyFaces CODI PageBean: "Argument bean must not be null"
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开发者_如何学Python 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
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 ;)
精彩评论