【问题标题】:Apache MyFaces CODI PageBean: "Argument bean must not be null"Apache MyFaces CODI PageBean:“参数 bean 不能为空”
【发布时间】:2011-08-13 19:03:37
【问题描述】:

我目前正在对 Apache MyFaces CODI 进行一些试验。我设法使用@Page 和一个返回类的操作方法创建了一个简单的工作类型安全导航。

但是,当我添加 @PageBean-Annotation 时,例如MyPageBean.class,当我尝试导航到页面时抛出以下异常:

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 {

}

还有我的 Page-Bean:

public class MyPageBean implements Serializable {
    @InitView
    protected void initView() { }

    @PrePageAction
    protected void prePageAction() { }

    @PreRenderView
    protected void preRenderView() { }
}

以及 Facelets 页面调用的 Action-Method:

public Class<? extends ViewConfig> nextPage() {
    return MyPage.class;
}

pageBean-Class(MyPageBean)是否需要有特定的注解或接口?我已经尝试过使用@Model,但这并没有改变任何东西。

我的配置:

  • 带有 Weld 的 Jave EE6(使用焊接原型创建)
  • Glassfish 3.1 社区版(Netbeans 7 附带的版本)
  • JSF2.0 (Mojarra 2.1)
  • EJB 3.1
  • MyFaces CODI 0.9.4
  • RichFaces 4.0.0.Final

感谢您的任何建议!

最好的问候, 罗伯特

【问题讨论】:

  • 对我来说,如果我使用 Weld 1.1.1 而不是出厂版本,它可以工作。

标签: jsf-2 cdi myfaces jboss-weld codi


【解决方案1】:

如果你不使用任何特定的范围,它将最终成为@Dependent。

我建议至少使用@RequestScoped(注意,不要使用 javax.faces.bean.RequestScoped,而是来自 CDI 的注释!)


Oki,现在与 Gerhard 进行了交谈,因为他对 Weld 上的 CODI 有更多的经验。

显然,这似乎是您使用的 Weld 版本中的错误。这应该在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.1.jar /opt/sun/glassfish/glassfish/modules/weld-osgi-bundle.jar

如果可行:学分转到 os890 ;)

【讨论】:

  • 感谢您的回答!但是,将@RequestScoped 添加到 MyPage 类或 MyPageBean 类并不能解决问题。动作方法在@Named、@ConversationScoped(Myfaces CODI one)bean 中。
猜你喜欢
  • 2013-06-08
  • 2011-12-09
  • 1970-01-01
  • 2014-01-29
  • 2012-11-11
  • 2014-07-10
  • 1970-01-01
  • 1970-01-01
  • 2013-04-20
相关资源
最近更新 更多