环境
- 两个具有远程接口的无状态 EJB。EJB1 被注入到 EJB2 中。
/// EJB1
package com.xxx.layer1;
@Remote
public interface EJB1Remote {
}
@Stateless (mappedNamed="com.xxx.EJB1")
public class EJB1 implements EJB1Remote {
}
/// EJB2
package com.xxx.layer2;
import com.xxx.layer1;
@Remote
public interface EJB2Remote {
}
@Stateless (mappedNamed="com.xxx.EJB2")
public class EJB2 implements EJB2Remote {
@EJB(mappedNamed="com.xxx.EJB1")
EJB1Remote ejb1;
}
EJB2 还使用了一些可选包(在其 MANIFEST 中声明)
WebLogic 应用服务器 (10.3.3)
两个 EJB 打包成两个单独的 JAR 文件
问题
如果将两个 JAR 文件打包到一个 EAR 文件中并进行部署,则依赖注入有效。但是,如果我单独部署它们,即使在我首先部署了 EJB1 并在 Weblogic ( com.xxx.EJB1#com.xxx.layer1.EJB1Remote ) 中验证了全局 JNDI 名称之后,EJB2 的部署也会失败并出现ClassNotFoundException: com.xxx.layer1。 EJB1远程