我有一个包含JPA逻辑的EJB,我在我的Java EE项目中使用它。为了避免在每个项目中复制该类,我试图将其放在一个单独的jar文件中,因此我有以下结构:
我已经搜索过了,但似乎只有当一个接口有多个实现时才会出现这种错误,而这并不是这种情况:只有一个名为"JPALogic"的bean,并且在检查ear文件时,JPALogic.jar只出现一次。
我做错了什么吗?
- Java EE项目,其中包括EJB和WAR项目
- JPALogic:包含JPALogic类的JAR项目
- RemoteServices:包含bean接口的JAR项目
- Services:包含bean的EJB项目,包括JPALogic和RemoteServices作为库
- Frontend:包含前端的WAR项目,包括RemoteServices作为库。
@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,并且在检查ear文件时,JPALogic.jar只出现一次。
我做错了什么吗?