1 Reply Latest reply on Oct 5, 2005 6:45 PM by Guilherme Melo e Maranhão

    Question on @EJB injection

    Luigi Putanesca Newbie

      I'm using JBoss 4.0.3 RC2 and EJB 3.0 RC2. I'm trying to inject a session bean into another session bean. I'm wonding if the following line should work:

      @EJB UserManagementFacadeRemote myEjb;

      When I try it. I get an exception. The alternate code below does however work for me.

      private UserManagementFacadeRemote myEjb;
      @EJB(businessInterface = UserManagementFacadeRemote.class)
      public void setFacade(UserManagementFacadeRemote myEjb) {
      this.myEjb = myEjb;
      }

      The stack track is:
      java.lang.RuntimeException: Unable to @Inject jndi dependency: java:comp.ejb3/env/ejb/Facade into method public void net.lgsystems.org.atest.TestEJB.setFacade(net.lgsystems.org.ejb.UserManagementFacadeLocal)
      at org.jboss.ejb3.injection.JndiMethodInjector.inject(JndiMethodInjector.java:43)
      at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:59)
      at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:33)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:36)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:148)
      at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:60)
      at $Proxy245.testMethod(Unknown Source)
      at net.lgsystems.access.test.TempTest.testEJB(TempTest.java:47)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at junit.framework.TestCase.runBare(TestCase.java:127)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at net.lgsystems.testutil.TestServiceBean.executeTest(TestServiceBean.java:66)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:99)
      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:53)
      at org.jboss.aspects.tx.TxInterceptor$NotSupported.invoke(TxInterceptor.java:79)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)
      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
      at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:566)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:436)
      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:239)
      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:277)
      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:168)
      Caused by: javax.naming.CannotProceedException; remaining name 'env/ejb/Facade'
      at javax.naming.spi.ContinuationContext.getTargetContext(ContinuationContext.java:43)
      at javax.naming.spi.NamingManager.getContinuationContext(NamingManager.java:770)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:700)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at org.jboss.ejb3.injection.JndiMethodInjector.inject(JndiMethodInjector.java:39)
      ... 51 more