将带有@Inject 的无状态 EJB 注入 CDI Weld ManagedBean(jboss 6 AS 上的 JSF 1.2 EJB 应用程序) [英] Inject a stateless EJB with @Inject into CDI Weld ManagedBean (JSF 1.2 EJB Application on jboss 6 AS)
问题描述
目前我正在尝试将无状态 EJB 注入 Jboss 6 AS Final 上的 CDI 托管控制器.控制器在可从 JSF 页面访问的上下文中进行管理.如果我用 @EJB
注入无状态 bean,它就可以工作.如果我使用 @Inject
注入无状态 EJB,则会出现以下异常:
Currently I am trying to inject a stateless EJB into a CDI managed controller on Jboss 6 AS Final. The controller is managed in the context an accessible from the JSF pages. If I inject the stateless bean with @EJB
it is working. If I inject the stateless EJB with @Inject
I get the following Exception:
我的控制器:
@Named("TestController")
public class TestController {
@Inject
private TestManagerLocal myTestManager;
...
}
}
我的无状态 bean:
My stateless bean:
@SuppressWarnings("unchecked")
@Stateless
public class TestManagerBean implements TestManagerLocal {
@PersistenceContext
private EntityManager em;
...
}
Bean 的接口用@Local 注释.
The Interface of the Bean is annotated with @Local.
如果我尝试调用 myTestManager 我得到以下异常:
If I try to call myTestManager I get the following exception:
WELD-000079 在 JNDI 中找不到 EJB:类de.crud.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$usr$local$jboss$server$default$deploy$test$ear"-SessionBean-TestManagerBean_$$_WeldProxy
WELD-000079 Could not find the EJB in JNDI: class de.crud.org$jboss$weld$bean-jboss$classloader:id="vfs:$$$usr$local$jboss$server$default$deploy$test$ear"-SessionBean-TestManagerBean_$$_WeldProxy
非常感谢.
推荐答案
问题是,我像耳朵一样构建和部署了我的应用程序.当我将应用程序部署为包含所有 EJB 的 war 时,Weld 正在工作.
The problem was, that I built and deployed my application as an ear. Weld is working when I deploy my application as an war including all EJBs.
这篇关于将带有@Inject 的无状态 EJB 注入 CDI Weld ManagedBean(jboss 6 AS 上的 JSF 1.2 EJB 应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!