[jboss-jira] [JBoss JIRA] Created: (JBAS-9445) JAXRS-EJB3-CDI bean injection failure (classloading issue?)

Florian Beaufume (JIRA) jira-events at lists.jboss.org
Mon Sep 5 10:37:28 EDT 2011


JAXRS-EJB3-CDI bean injection failure (classloading issue?)
-----------------------------------------------------------

                 Key: JBAS-9445
                 URL: https://issues.jboss.org/browse/JBAS-9445
             Project: Legacy JBoss Application Server 6 
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: EJB, Web Services, Weld/CDI
    Affects Versions: 6.1.0, 6.0.0.Final
         Environment: Windows XP, JDK 1.6.0_u24.
            Reporter: Florian Beaufume
            Assignee: Carlo de Wolf


Summary :
- In a JAX-RS resource implemented as a stateless session EJB, a CDI injection fails when the several applications are deployed.
- Both JBoss 6.0.0.Final and 6.1.0.Final fail, but with different results.

Description:
- We have two webapps, "mockup1.war" and "mockup2.war".
- Each webapp contains the same "SampleResource" JAX-RS resource class implemented as a stateless session EJB ("@Stateless").
- Each webapp contains the same "ApplicationResources" JAX-RS application resource class that registers "SampleResource".
- Each webapp contains the same "ServiceInterface" business interface.
- Each webapp contains its own implementation of the business service : "ServiceBean1" for "mockup1.war" and "ServiceBean2" for "mockup2.war".
- That implementation is used by the resource class, and only logs a text message to stdout.

Test scenario with JBoss 6.0.0.Final :
- (1) Deploy both war to JBoss 6.0.0.Final => no deployment problem.
- (2) Go to http://localhost:8080/mockup2/resource/, consult the app server logs, you see the "Hello from mockup2.war" line => that's ok.
- (3) Go to http://localhost:8080/mockup1/resource/, consult the app server logs, you see the "Hello from mockup2.war" line instead of "Hello from mockup1.war" => bug!

What happened with JBoss 6.0.0.Final :
- When the resource class is executed from "mockup2.war", the business service implementation is loaded from "mockup1.war" instead of "mockup2.war"!
- When the resource class is executed from "mockup1.war", no problem.

Other information for JBoss 6.0.0.Final :
- I tracked the issue using a debugger.
- If I use a servlet filter I can see that the filter classloader always correctly refers to the current web app, that's ok.
- But inside the JAX-RS resource class I can see that the resource class loader always point to "mockup2.war". This may explain why the wrong bean gets injected.
- If the JAX-Rs resource class is @ManagedBean instead of @Stateless, there is no bug.

Test scenario with JBoss 6.1.0.Final :
- Same (1) and (2) => eveything is ok.
- (3) go to the URL => server failure, you get a stack trace :
2011-09-05 16:26:25,421 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/mockup1].[default]] (http-127.0.0.1-8080-1) "Servlet.service()" pour la servlet default a généré une exception: org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalArgumentException: object is not an instance of declaring class
	at org.jboss.resteasy.core.SynchronousDispatcher.unwrapException(SynchronousDispatcher.java:345) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:321) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:534) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:155) [:6.1.0.Final]
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:212) [:6.1.0.Final]
	at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:59) [:6.1.0.Final]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
	at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [:6.1.0.Final]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274) [:6.1.0.Final]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242) [:6.1.0.Final]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [:6.1.0.Final]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [:6.1.0.Final]
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181) [:6.1.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.1.0.Final]
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100) [:6.1.0.Final]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159) [:6.1.0.Final]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [:6.1.0.Final]
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) [:6.1.0.Final]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [:6.1.0.Final]
	at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53) [:6.1.0.Final]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [:6.1.0.Final]
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [:6.1.0.Final]
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [:6.1.0.Final]
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [:6.1.0.Final]
	at java.lang.Thread.run(Thread.java:662) [:1.6.0_24]
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
	at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
	at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) [:6.1.0.Final]
	at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) [:6.1.0.Final]
	at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) [:6.1.0.Final]
	at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) [:6.1.0.Final]
	at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:125) [:6.1.0.Final]
	at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62) [:6.1.0.Final]
	at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125) [:6.1.0.Final]
	at com.beaufume.mockup.SampleResource$Proxy$_$$_Weld$Proxy$.getContent(SampleResource$Proxy$_$$_Weld$Proxy$.java) [:]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
	at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140) [:6.1.0.Final]
	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255) [:6.1.0.Final]
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220) [:6.1.0.Final]
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209) [:6.1.0.Final]
	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519) [:6.1.0.Final]
	... 26 more


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jboss-jira mailing list