2 Replies Latest reply on Jan 13, 2012 11:59 AM by tibi

    EJB injection fails in servlet

    tibi

      Hi,

       

       

      I am evaluating JBoss AS7 for a posible migration away from WebSphere7.

      The project is composed of an EJB3.0 module and a Web 2.5 module.

      In the web module I have a servlet that accesses the EJB module over the local interface by injection (using @EJB).

       

      I get the following error when the servlet is first accessed for both JBoss AS 7.0.2 and also JBoss 7.1.0 CR1.

       

      12:19:08,036 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/dmswebclient2].[mainpagedmsaccess]] (http--127.0.0.1-8080-8) Allocate exception for servlet mainpagedmsaccess: java.lang.IllegalArgumentException: Can not set com.uniqagroup.dmswebclient2.svc.DMSAccessLocal field com.uniqagroup.dmswebclient2.mainapp.server.MainpageDMSAccessRPC.services to com.uniqagroup.dmswebclient2.svc.DMSAccessLocal$$$view3

          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) [:1.6.0_25]

          at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) [:1.6.0_25]

          at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) [:1.6.0_25]

          at java.lang.reflect.Field.set(Field.java:657) [:1.6.0_25]

          at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:111) [jboss-as-ee-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:92) [jboss-as-ee-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]

          at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) [jboss-as-ee-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:85) [jboss-as-ee-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.as.web.deployment.component.WebComponentInstantiator$1.<init>(WebComponentInstantiator.java:57) [jboss-as-web-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.as.web.deployment.component.WebComponentInstantiator.getReference(WebComponentInstantiator.java:55) [jboss-as-web-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.as.web.deployment.WebInjectionContainer.instantiate(WebInjectionContainer.java:99) [jboss-as-web-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:78) [jboss-as-web-7.1.0.CR1.jar:7.1.0.CR1]

          at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:72) [jboss-as-web-7.1.0.CR1.jar:7.1.0.CR1]

          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1156) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:489) [jbossweb-7.0.7.Final.jar:]

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1.jar:7.1.0.CR1]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.7.Final.jar:]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.7.Final.jar:]

          at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.7.Final.jar:]

          at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.7.Final.jar:]

          at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.7.Final.jar:]

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]

       

      Did anybody faced anything similar, or has any ideas on what could cause this?

       

       

      With thanks,

      Tibi

        • 1. Re: EJB injection fails in servlet
          sfcoy

          Do you by any chance have a client jar in your WEB-INF/lib directory containing com.uniqagroup.dmswebclient2.svc.DMSAccessLocal?

           

          If so, remove it completely because it will clash (be in a different classloader and therefore be of a different type) with the one that should be in your EJB jar.

          1 of 1 people found this helpful
          • 2. Re: EJB injection fails in servlet
            tibi

            Thanks for the info. It was exactly so.

            On WAS7 we were using Application classloader as aposito to Module, that means that all modules (no matter if ejb or war share the same classloader). 

            The classloader setting on WAS7 hides the fact that the jar that holds the local interface is actually part also of the ejb module and the web module.

             

            I have deleted the jar with the local interface from the lib folder of the web module and now the injection works.