I would have a question concerning JavaEE Beans. I have developed a long time with Spring and Hibernate and now I change to JavaEE - so therefore sorry if it is a very simple question but currently I have no idea how to handle my problem.
I have two Beans which are registered in JNDI (on JBoss - see above). - that is ok so far. If I use @EJB as dependency injection in my Servlet than it works fine:
@EJB(name = "jndi/TestClassBean")
public TestClass testClass;
@EJB(name = "jndi/OtherBean")
public OtherBean otherBean;
If I change @EJB with @Resource, than I get a NullPointerException:
@Resource(name = "jndi/TestClassBean")
public TestClass testClass;
@Resource(name = "jndi/OtherBean")
public OtherBean otherBean;
Does enyone know what to do in order to get it done with @Resource? I have nothing declared in deplyment descriptior - is it mandatory for @Resource to declare it in DD? Thanks!
16:39:51,482 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named OtherBean in deployment unit deployment ...
java:global/salzburgag-javaeetest-frontend/OtherBean!at.maxqu.test.OtherBeanLocal
java:app/...-javaeetest-frontend/OtherBean!at.maxqu.test.OtherBeanLocal
java:module/OtherBean!at.....test.OtherBeanLocal
java:global/...-javaeetest-frontend/OtherBean!at.....test.OtherBean
java:app/...-javaeetest-frontend/OtherBean!at.....test.OtherBean
java:module/OtherBean!at.maxqu.test.OtherBean
16:39:51,490 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named TestClassBean in deployment unit deployment ...
java:global/...-javaeetest-frontend/TestClassBean!at.....javaeesimpletest.TestClass
java:app/...-javaeetest-frontend/TestClassBean!at.....javaeesimpletest.TestClass
java:module/TestClassBean!at.maxqu.javaeesimpletest.TestClass
java:global/...-javaeetest-frontend/TestClassBean!at.....javaeesimpletest.TestClassBean
java:app/...-javaeetest-frontend/TestClassBean!at.....javaeesimpletest.TestClassBean
java:module/TestClassBean!at.....javaeesimpletest.TestClassBean
16:39:52,272 INFORMATION [javax.enterprise.resource.webcontainer.jsf.config] (MS