10 Replies Latest reply on Feb 14, 2011 2:36 AM by jaikiran pai

    AS6 Final EJB injection problem

    Michael Brackx Newbie

      EJB injection fails on Final. Same code is working on CR1.

      The injection is an @EJB field injection. From the error it seems setting it is tried trough a method with the same name as the field.

      A workaround is to rename the field or the method.

       

      code (stateless ejb):

       

        @EJB

                private CreateLocal create;

       

        ...

       

        public String create(...) {

          ...

        }

        • 1. AS6 Final EJB injection problem
          jaikiran pai Master

          So you were trying to inject an EJB into some method named "create"? Can you post the exact code which fails?

          • 2. AS6 Final EJB injection problem
            Michael Brackx Newbie

            No, the method is unrelated. As you can see from the arguments it does not take a CreateLocal.

            I assumed the injection in

             

            @EJB

            private CreateLocal create;

             

            failed, because that's the only place injecting a CreateLocal.

            The error seems to suggest that create method is a setter.

            • 3. AS6 Final EJB injection problem
              Michael Brackx Newbie

              a simple example showing the problem

               

              @Stateless

              public class BugResourceBean implements BugResourceLocal {

               

               

                        @EJB

                        private CreateLocal create;

               

               

                        public String create() {

                                  return "ok";

                        }

              }

               

              @Path("bug")

              public interface BugResourceLocal {

               

               

                        @GET

                        public String create();

              }

               

              2011-01-11 11:07:09,628 ERROR [com.unifiedpost.alexandria.rest.provider.EJBExceptionMapper] (http-127.0.0.1-8080-1:) EJBException: javax.ejb.EJBException: java.lang.IllegalArgumentException: failed to set value Proxy to jboss.j2ee:ear=alexandria-ear-0.3.4-SNAPSHOT.ear,jar=alexandria-ejb-0.3.4-SNAPSHOT.jar,name=CreateBean,service=EJB3 implementing [interface com.unifiedpost.alexandria.ejb.CreateLocal] with setter public java.lang.String com.unifiedpost.alexandria.rest.resource.service.BugResourceBean.create()

                        at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:183) [:0.0.1]

                        at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:251) [:0.0.1]

                        at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:349) [:0.0.1]

                        at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:209) [:0.0.1]

                        at org.jboss.ejb3.tx2.aop.CMTTxInterceptorWrapper.invoke(CMTTxInterceptorWrapper.java:52) [:0.0.1]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) [:1.0.0.GA]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42) [:1.0.3]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:182) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.interceptor.EJB3TCCLInterceptor.invoke(EJB3TCCLInterceptor.java:86) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:323) [:1.7.17]

                        at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:380) [:1.7.17]

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]

                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]

                        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]

                        at org.jboss.ejb3.proxy.impl.handler.session.SessionLocalProxyInvocationHandler$LocalContainerInvocation.invokeTarget(SessionLocalProxyInvocationHandler.java:184) [:1.0.11]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.async.impl.interceptor.AsynchronousClientInterceptor.invoke(AsynchronousClientInterceptor.java:143) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.proxy.impl.handler.session.SessionLocalProxyInvocationHandler$LocalInvokableContextHandler.invoke(SessionLocalProxyInvocationHandler.java:159) [:1.0.11]

                        at $Proxy208.invoke(Unknown Source)          at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:185) [:1.0.11]

                        at $Proxy249.create(Unknown Source)          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]

                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]

                        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]

                        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140) [:6.0.0.Final]

                        at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:252) [:6.0.0.Final]

                        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:217) [:6.0.0.Final]

                        at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:206) [:6.0.0.Final]

                        at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:503) [:6.0.0.Final]

                        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:480) [:6.0.0.Final]

                        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [:6.0.0.Final]

                        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:207) [:6.0.0.Final]

                        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [:6.0.0.Final]

                        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [:6.0.0.Final]

                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [:1.0.0.Final]

                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324) [:6.0.0.Final]

                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.0.0.Final]

                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.0.0.Final]

                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [:6.0.0.Final]

                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.0.0.Final]

                        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) [:6.0.0.Final]

                        at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285) [:1.1.0.Final]

                        at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261) [:1.1.0.Final]

                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88) [:6.0.0.Final]

                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.0.0.Final]

                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [:6.0.0.Final]

                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.0.0.Final]

                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.0.0.Final]

                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.0.0.Final]

                        at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.0.0.Final]

                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.0.0.Final]

                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.0.0.Final]

                        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.0.0.Final]

                        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.0.0.Final]

                        at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]

              Caused by: java.lang.IllegalArgumentException: failed to set value Proxy to jboss.j2ee:ear=alexandria-ear-0.3.4-SNAPSHOT.ear,jar=alexandria-ejb-0.3.4-SNAPSHOT.jar,name=CreateBean,service=EJB3 implementing [interface com.unifiedpost.alexandria.ejb.CreateLocal] with setter public java.lang.String com.unifiedpost.alexandria.rest.resource.service.BugResourceBean.create()

                        at org.jboss.injection.injector.util.MethodInjectionPoint.set(MethodInjectionPoint.java:66) [:1.0.0-alpha-6]

                        at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:159) [:1.0.0-alpha-6]

                        at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:134) [:1.0.0-alpha-6]

                        at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:82) [:1.0.0-alpha-6]

                        at org.jboss.injection.manager.core.DefaultInjectionContext.proceed(DefaultInjectionContext.java:58) [:1.0.0-alpha-6]

                        at org.jboss.weld.integration.injection.Jsr299InterceptorInjector.inject(Jsr299InterceptorInjector.java:73) [:6.0.0.Final]

                        at org.jboss.injection.manager.core.DefaultInjectionContext.proceed(DefaultInjectionContext.java:58) [:1.0.0-alpha-6]

                        at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:58) [:1.0.0-alpha-6]

                        at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:64) [:1.0.0-alpha-6]

                        at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:140) [:1.7.17]

                        at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:125) [:1.7.17]

                        at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.17]

                        at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116) [:1.7.17]

                        at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]

                        at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116) [:1.7.17]

                        at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1363) [:1.7.17]

                        at org.jboss.ejb3.stateless.StatelessContainer.createBeanContext(StatelessContainer.java:139) [:1.7.17]

                        at org.jboss.ejb3.pool.AbstractPool.createBeanContext(AbstractPool.java:94) [:1.7.17]

                        at org.jboss.ejb3.pool.AbstractPool.create(AbstractPool.java:81) [:1.7.17]

                        at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:62) [:1.7.17]

                        at org.jboss.ejb3.InfinitePool.get(InfinitePool.java:57) [:1.7.17]

                        at org.jboss.ejb3.pool.ThreadlocalPool.create(ThreadlocalPool.java:54) [:1.7.17]

                        at org.jboss.ejb3.pool.ThreadlocalPool.get(ThreadlocalPool.java:86) [:1.7.17]

                        at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:58) [:1.7.17]

                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]

                        at org.jboss.ejb3.core.context.SessionInvocationContextAdapter.proceed(SessionInvocationContextAdapter.java:95) [:1.7.17]

                        at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:247) [:0.0.1]

                        ... 69 more

              • 4. AS6 Final EJB injection problem
                jaikiran pai Master

                Okay, this is a bug then. Thanks for reporting. I'll create a JIRA (need to figure out where it goes).

                • 5. AS6 Final EJB injection problem
                  Johan Andersson Newbie

                  Hi, has a JIRA for this issue been create yet?

                   

                  I've run into something similar on JBoss AS 6 final.

                   

                  My app is deployed as a .ear file containing a .war file and some .jar files.

                   

                  Code for CDI of stateless session bean inside a JSF backing bean:

                   

                  @EJB(mappedName = "someApp/SomeSessionBean/remote")

                  private SomeSessionBeanRemote ssbr;

                   

                  A NPE is thrown at runtime when methods on "ssbr" are called.

                   

                  The stateless session bean and the JSF backing bean are contained in separate .jar files inside the .ear.

                   

                  NOTE: Using javax.naming.InitialContext for lookup works. The above CDI stuff was working fine in 4.2.3 GA.

                  • 6. AS6 Final EJB injection problem
                    Nicklas Karlsson Master

                    @Johan: could you start a separate thread for this, I'm note sure it's related. Add relevant code. And that's EJB injection and not CDI, otherwise you'll have to prove to me how you got CDI running on 4.x ;-)

                    • 7. AS6 Final EJB injection problem
                      David Heisterberg Newbie

                      Bumping this to ask if there is a jira item yet -- couldn't find one and the problem is still present as of a build a few days ago.  This is definitely of interest to scala developers.

                      • 8. AS6 Final EJB injection problem
                        jaikiran pai Master

                        Can you try these steps against AS 6.0 Final and let us know how it goes:

                         

                        1) Backup the JBOSS_HOME/common/lib/jboss-injection-injector.jar file to some place on your system

                        2) Replace that JBOSS_HOME/common/lib/jboss-injection-injector.jar file with this one https://repository.jboss.org/nexus/content/repositories/snapshots/org/jboss/injection/jboss-injection-injector/1.0.0-alpha-7-SNAPSHOT/jboss-injection-injector-1.0.0-alpha-7-20110213.172100-1.jar (Remember to rename that downloaded file to jboss-injection-injector.jar).

                        3) Start the server and test your application.

                         

                        Let us know how it goes. If it works, then I'll upgrade AS trunk with this fix.

                        • 9. AS6 Final EJB injection problem
                          David Heisterberg Newbie

                          Thanks, Jaikiran, that worked.  I tried this in an isolated instance, so I can't say I tested it thoroughly, but injection of EJBs looks OK!

                          • 10. AS6 Final EJB injection problem
                            jaikiran pai Master

                            David, thanks for trying the fix. Here's the JIRA for this issue https://issues.jboss.org/browse/JBAS-8868