【问题标题】:EJB @Singleton @WebListener annotated class cannot be deployed in WAR to JBoss 7.1EJB @Singleton @WebListener 注释类不能在 WAR 中部署到 JBoss 7.1
【发布时间】:2014-06-10 14:02:37
【问题描述】:

我正在使用 JBoss 7.1 在 Netbeans 8 中开发 EJB 3.1 的示例: https://netbeans.org/kb/docs/javaee/javaee-entapp-ejb.html

根据 EJB 3.1 的规范,应该可以在 web 模块中拥有企业 bean。我在 web 模块中有 Singleton 会话 bean,请参见示例的这一部分: https://netbeans.org/kb/docs/javaee/javaee-entapp-ejb.html#Exercise_3a

如果我使用@Singleton@LocalBean 注释,应用程序是可部署的。
如果我添加@WebListener,则无法部署,错误提示:

Caused by: java.lang.RuntimeException: JBAS018043: ejb.SessionManagerBean has the wrong component type, it cannot be used as a web component

有人可以帮忙吗?

注意:示例是在 Glassfish 服务器上演示的,我必须使用 JBoss 7.1。我在这里有什么遗漏吗?

【问题讨论】:

  • 不知道标准是否要求这些注释应该是可组合的,或者这是否是 Glassfish 扩展,但建议here 一种解决方法(引用:A web event listener is a different component type as opposed to an EJB. You can create a separate web event listener which injects the EJB.

标签: web-applications singleton ejb jboss7.x


【解决方案1】:

JBoss 似乎不允许 WebService 或 WebListener 也成为 EJB..

如上所述,解决方案是创建一个单独的 @RequestScoped @WebService@WebListener 来注入和调用 EJB 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多