I've JAR with EJB 3.1 that I need to use in WAR. Both JAR and WAR are deployed separately on same JBoss (AS 7.1). When I inject EJB in one of the CDI beans in WAR I got this error:
16:45:19,003 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."TEST_WEB.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."TEST_WEB.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [TestSessionEJBLocal] with qualifiers [@Default] at injection point [[field] @Inject cz.pfreiberg.test.view.portlet.ViewPortlet.testBean]
at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_79]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [TestSessionEJBLocal] with qualifiers [@Default] at injection point [[field] @Inject cz.pfreiberg.test.view.portlet.ViewPortlet.testBean]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:275)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:244)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:107)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:127)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:346)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:331)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:366)
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)
at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)
From my current point of view the @Inject doesn’t see the EJB, but if I use manual JNDI lookup (from WAR) is possible for me to get instance of this bean. Is possible to inject EJB from another JAR with @Inject annotation?
Class in WAR (CDI Bean) which @Inject EJB from JAR:
@Model
public class ViewPortlet implements Serializable {
@Inject
TestSessionEJBLocal testBean;
}
EJB class in JAR which I'm trying to @Inject with local and remote interface:
@Stateless
public class TestSessionEJBBean implements TestSessionEJB, TestSessionEJBLocal
Thanks for any ideas.
@EJB
annotations or just for CDI with@Inject
? – LenglBoy