【发布时间】:2015-05-08 18:26:16
【问题描述】:
我有一个带有一些 JPA 逻辑的 EJB,我在我的 java EE 项目中使用了这些逻辑。 我没有在每个项目中复制该类,而是尝试将它放在一个单独的 jar 中,所以我有这样的结构:
- 包含 EJB 和 WAR 项目的 Java EE 项目
- JPALogic:其中包含 JPALogic 类的 JAR 项目
- RemoteServices:带有 bean 接口的 JAR 项目
- 服务:带有 bean 的 EJB 项目,包括作为库的 JPALogic 和 RemoteServices
- 前端:带有前端的 WAR 项目,包括 RemoteServices 作为库。
JPALogic 仅在 EJB 项目中使用,在 Java EE 应用程序的其他部分中没有引用它。在 JPALogic 库中,我有我的 JPALogic bean:
@Stateless
@LocalBean
public class JPALogic {
@Resource
private EJBContext ejbContext;
@Inject @ShardedPersistenceContext
private EntityManager em;
public JPALogic() {
}
[...lots of methods...]
}
如果 JPALogic 代码直接在 EJB 项目中,它可以完美运行,但是当我将它放在外部库部署时变得非常不稳定(netbeans 8 + glassfish 4)并且几乎每次部署都失败并出现此错误:
Exception while deploying the app [app] : Cannot resolve reference [Remote ejb-ref name=com.my.autenticacion.services.AutRolBackendServices/jpa,Remote 3.x interface =com.my.infraestructura.jpa.JPALogic,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session] because there are [2] ejbs in the application with interface com.my.infraestructura.jpa.JPALogic.
我已经搜索过,但是当接口具有多个实现时,似乎会出现这种错误,但事实并非如此:只有一个名为“JPALogic”的bean,并且检查耳朵,JPALogic.jar 出现了一个只有时间。
我做错了什么?
【问题讨论】:
-
类似的部署时间错误可能是由 web.xml 描述符中的错误配置引起的。您可能需要检查 EJB 项目的 web.xml 中是否有可选的 ejb-ref 标记 (docs.oracle.com/cd/E14571_01/web.1111/e13712/…),该标记可能已由您的 IDE 在创建 EJB 期间添加。
标签: java jakarta-ee netbeans glassfish ejb