【发布时间】:2014-10-07 10:06:23
【问题描述】:
我在 glassfish 上部署了两个应用程序 - 应用程序 A 和 B。
两者都部署为war包,应用程序B使用应用程序A的一些组件。
现在在应用程序 A 中我有一个接口:
public interface BusinessInterface() extends SomeOtherInterface {
void someAction();
}
我有这个接口的 3 个实现 - 两个在应用程序 A 中,一个在应用程序 B 中:BusinessInterfaceA1, BusinessInterfaceA2, BusinessInterfaceB
只要它们都是 CDIBean,一切都很好 - 我使用自定义 @Qualifier 注释(@BusinessInterfaceA1、@BusinessInterfaceA2)和 B 的实现的 @Default 注释来区分它们。
但是现在我需要两个应用程序的 A 实现都是有状态的 EJB,这就是它变得有趣的地方。
当我在两个实现上添加 @Statefull 注释时,我得到了这样的结果:
javax.servlet.ServletException: org.jboss.weld.exceptions.WeldException: WELD-000049
详情:
java.lang.IllegalStateException: Unable to convert ejbRef for ejb BusinessInterfaceA1 to a business object of type interface SomeOtherInterface
我该如何解决?我需要所有实现都以一种我可以注入它们的方式可用,就像
@Inject @SomeAnnotation private BusinessInterface businessInterface;
【问题讨论】:
标签: java dependency-injection ejb cdi glassfish-3