7 Replies Latest reply on Aug 25, 2009 1:10 AM by Alexey Loubyansky

    @EJB injection after redeploy

    Vadim Lotarev Newbie

      I am trying deploy simple application: two stateless EJB3 beans packaged in one ejb module that, in turn, is packaged as EAR application. One EJB injects aonther by simple @EJB annotation (via local inteface):

      @EJB
       private SwServiceLocal swService;
      


      Everything works just fine after first deployment but fails after re-deployment (the first access to injected EJB) injection fails with the following exception:

      java.lang.RuntimeException: Non matching type for inject of field: private com.foo.service.SwService com.foo.service.SV2ServiceBean.swService for type: $Proxy433 of jndiName env/com.foo.service.SV2ServiceBean/swService intfs: , com.foo.service.SwServiceLocal, org.jboss.ejb3.JBossProxy 12:03:11,589 ERROR [STDERR] at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:128)
       at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:106)
       at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:63)
       at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
       at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:49)
       at org.jboss.ejb3.ThreadlocalPool.create(ThreadlocalPool.java:50)
       at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:90)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy431.processAllOperations(Unknown Source)
       at fr.sncm.sgi.service.batchmanager.ServiceBatchManager.executeConnecteurInterface(ServiceBatchManager.java:789)
       at fr.sncm.sgi.service.batchmanager.ServiceBatchManager.programmeInterface(ServiceBatchManager.java:612)
       at fr.sncm.sgi.service.batchmanager.ServiceBatchManager.processPerformBatch(ServiceBatchManager.java:300)
       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:597)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at fr.sncm.sgi.interceptors.LogInterceptor.logThisMethod(LogInterceptor.java:31)
       at sun.reflect.GeneratedMethodAccessor191.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
       at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
       at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
       at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
       at $Proxy324.processPerformBatch(Unknown Source)
       at fr.sncm.sgi.mdb.GenericTopicMessageBean.onMessage(GenericTopicMessageBean.java:87)
       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:597)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249)
       at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
       at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
       at $Proxy347.onMessage(Unknown Source)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
       at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:906)
       at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
       at org.jboss.mq.SpySession.run(SpySession.java:323)
       at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
       at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
       at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
       at java.lang.Thread.run(Thread.java:619)
       Caused by: java.lang.IllegalArgumentException: Can not set com.foo.service.SwService field com.foo.service.SV2ServiceBean.swService to $Proxy433
       at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
       at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
       at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
       at java.lang.reflect.Field.set(Field.java:657)
       at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:116)
       ... 88 more


      Do I do something wrong? Can anybody help me?

      Thanks in advance,
      Vadim

        • 1. Re: @EJB injection after redeploy
          jaikiran pai Master

           

          "vlotarev" wrote:
          but fails after re-deployment (the first access to injected EJB)


          How do you redeploy? Do those beans belong to the same application (jar)? Can you post the console logs from the point you do a redeploy? Do you access these beans from a standalone client?


          • 2. Re: @EJB injection after redeploy
            jaikiran pai Master

            Which version of JBoss AS do you use?

            • 3. Re: @EJB injection after redeploy
              Vadim Lotarev Newbie

              JBoss version is 4.2.3GA

              I am making hot-deploy just copying corresponding EAR file in the server/deploy folder. Deployment itself went well except several warnings (I removed log entries related to entity beans deployment since as far as I guess the are out of interest).

              INFO [EARDeployer] Init J2EE application: file:/C:/jboss-4.2.3.GA/server/default/deploy/SV2Interface.ear
              ....
              WARN [EJBHandler] IGNORING DEPENDENCY: unable to find @EJB from interface only com.foo.service.SwService in ejb-jar.xml of SV2Servicenot used by any EJBs
              WARN [EJBHandler] IGNORING DEPENDENCY: unable to find @EJB from interface only com.foo.aaa.service.serviceRejet.IServiceRejetEnterprisein ejb-jar.xml of SV2Servicenot used by any EJBs
              WARN [EJBHandler] IGNORING DEPENDENCY: unable to find @EJB from interface only com.bar.bbb.service.SessionService in ejb-jar.xml ofSwServicenot used by any EJBs
              WARN [EJBHandler] IGNORING DEPENDENCY: unable to find @EJB from interface only com.bar.bbb.service.DbSearchService in ejb-jar.xml of SwServicenot used by any EJBs
              INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,name=ShipService,service=EJB3 with dependencies:
              INFO [JmxKernelAbstraction] persistence.units:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,unitName=SV2_Ship_Casa
              INFO [JmxKernelAbstraction] persistence.units:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,unitName=SV2_Reference
              INFO [JmxKernelAbstraction] persistence.units:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,unitName=SV2_Ship_Moro
              INFO [EJBContainer] STARTED EJB: com.foo.service.ShipServiceBean ejbName: ShipService
              INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,name=SV2Service,service=EJB3 with dependencies:
              INFO [JmxKernelAbstraction] jboss.j2ee:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,name=ShipService,service=EJB3
              INFO [EJBContainer] STARTED EJB: com.foo.service.SV2ServiceBean ejbName: SV2Service
              INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
              INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=SV2Interface.ear,jar=SV2InterfaceEJBModule.jar,name=SwService,service=EJB3 with dependencies:
              INFO [EJBContainer] STARTED EJB: com.foo.service.SwServiceBean ejbName: SwService
              INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.2.3.GA/server/default/tmp/deploy/tmp5596106466848300323SV2Interface.ear-contents/SV2InterfaceEJBModule.jar
              INFO [EARDeployer] Started J2EE application: file:/C:/jboss-4.2.3.GA/server/default/deploy/SV2Interface.ear
              


              As I mentioned in my first post all EJB's are located in the same jar (ejb module) that, in turn, is packaged in EAR application. I am accesing one EJB from another EJB (both of them are located in the same JAR).

              Thanks,
              Vadim

              • 4. Re: @EJB injection after redeploy
                Vadim Lotarev Newbie

                I did some testing: replaced @EJB dependency injection by direct JNDI lookup but this didn't solve the problem. I noticed that the same $Proxy object is returned in response to JNDI lookup after several application re-deployments. Though JNDIView MBean shows different $Proxy objects after each re-deployment.
                I think that this is a reason - JNDI lookup invoked from application returns an old $Proxy object that was created during the first deployment. Looks like a bug ... Does anybody can suggest any workaround?

                • 5. Re: @EJB injection after redeploy
                  Vadim Lotarev Newbie

                  It's interesting that

                  new InitialContext().list()


                  returns right bound proxy classes but direct lookup invoked on the same context

                  new InitialContext().lookup(name)


                  returns old proxy class ...

                  It looks like InitialContext implementation caches bound objects somewhere (in static variable?) and this cache is not cleared during re-deployment.

                  • 6. Re: @EJB injection after redeploy
                    jaikiran pai Master

                    Are you sure this is happening? I haven't heard of similar caching issues. Is there any caching involved within your application for objects returned from lookup?

                    Also, can you try this on JBossAS-5.1.0 CR1?

                    • 7. Re: @EJB injection after redeploy
                      Alexey Loubyansky Master

                      So, any response to Jaikiran? Do you have a sample deployment that you can make available for us to reproduce the issue?