[jbossws-issues] [JBoss JIRA] Issue Comment Edited: (JBWS-2810) UnifiedMetaData uses thread context loader to find classes, this can lead to javassist.NotFoundException

Alessio Soldano (JIRA) jira-events at lists.jboss.org
Mon Nov 23 12:16:30 EST 2009


    [ https://jira.jboss.org/jira/browse/JBWS-2810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12496116#action_12496116 ] 

Alessio Soldano edited comment on JBWS-2810 at 11/23/09 12:15 PM:
------------------------------------------------------------------

It's quite hard to me to come up with a test in jbossws sources for this, can you please work out a small testcase reproducing this? I tried changing the ServiceDelegateImpl to use the provided Service class' classloader and that does not seem to hurt the jbws testsuite (but I'd actually need to run the tck too...), anyway I'm most probably not going to commit this without at least a test, also considering this would not be a minor change.

Index: modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java
===================================================================
--- modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java (revisione 11133)
+++ modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java (copia locale)
@@ -85,6 +85,15 @@
       this.classLoader = SecurityActions.getContextClassLoader();
    }

+ public UnifiedMetaData(UnifiedVirtualFile vfsRoot, ClassLoader classLoader)
+ {
+ if (vfsRoot == null)
+ throw new IllegalArgumentException("VFS root cannot be null");
+
+ this.vfsRoot = vfsRoot;
+ this.classLoader = classLoader;
+ }
+
    public ClassLoader getClassLoader()
    {
       if (classLoader == null)
Index: modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
===================================================================
--- modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java (revisione 11133)
+++ modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java (copia locale)
@@ -66,9 +66,13 @@
  */
 public class JAXWSClientMetaDataBuilder extends JAXWSMetaDataBuilder
 {
-
    public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL, UnifiedVirtualFile vfsRoot)
    {
+ return this.buildMetaData(serviceName, wsdlURL, vfsRoot, null);
+ }
+
+ public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL, UnifiedVirtualFile vfsRoot, ClassLoader classLoader)
+ {
       if (wsdlURL == null)
          throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);

@@ -76,7 +80,7 @@
          log.debug("START buildMetaData: [service=" + serviceName + "]");
       try
       {
- UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot);
+ UnifiedMetaData wsMetaData = classLoader != null ? new UnifiedMetaData(vfsRoot, classLoader) : new UnifiedMetaData(vfsRoot);

          ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
          wsMetaData.addService(serviceMetaData);
Index: modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java (revisione 11133)
+++ modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java (copia locale)
@@ -147,7 +147,7 @@
       }
       else
       {
- UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot);
+ UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot, serviceClass.getClassLoader());
          serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
          wsMetaData.addService(serviceMetaData);
       } 

      was (Author: alessio.soldano at jboss.com):
    It's quite hard to be to come up with a test in jbossws sources for this, can you please work out a small testcase reproducing this? I tried changing the ServiceDelegateImpl to use the provided Service class' classloader and that does not seem to hurt the jbws testsuite (but I'd actually need to run the tck too...), anyway I'm most probably not going to commit this without at least a test, also considering this would not be a minor change.

Index: modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java
===================================================================
--- modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java (revisione 11133)
+++ modules/core/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java (copia locale)
@@ -85,6 +85,15 @@
       this.classLoader = SecurityActions.getContextClassLoader();
    }

+ public UnifiedMetaData(UnifiedVirtualFile vfsRoot, ClassLoader classLoader)
+ {
+ if (vfsRoot == null)
+ throw new IllegalArgumentException("VFS root cannot be null");
+
+ this.vfsRoot = vfsRoot;
+ this.classLoader = classLoader;
+ }
+
    public ClassLoader getClassLoader()
    {
       if (classLoader == null)
Index: modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
===================================================================
--- modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java (revisione 11133)
+++ modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java (copia locale)
@@ -66,9 +66,13 @@
  */
 public class JAXWSClientMetaDataBuilder extends JAXWSMetaDataBuilder
 {
-
    public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL, UnifiedVirtualFile vfsRoot)
    {
+ return this.buildMetaData(serviceName, wsdlURL, vfsRoot, null);
+ }
+
+ public ServiceMetaData buildMetaData(QName serviceName, URL wsdlURL, UnifiedVirtualFile vfsRoot, ClassLoader classLoader)
+ {
       if (wsdlURL == null)
          throw new IllegalArgumentException("Invalid wsdlURL: " + wsdlURL);

@@ -76,7 +80,7 @@
          log.debug("START buildMetaData: [service=" + serviceName + "]");
       try
       {
- UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot);
+ UnifiedMetaData wsMetaData = classLoader != null ? new UnifiedMetaData(vfsRoot, classLoader) : new UnifiedMetaData(vfsRoot);

          ServiceMetaData serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
          wsMetaData.addService(serviceMetaData);
Index: modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java (revisione 11133)
+++ modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java (copia locale)
@@ -147,7 +147,7 @@
       }
       else
       {
- UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot);
+ UnifiedMetaData wsMetaData = new UnifiedMetaData(vfsRoot, serviceClass.getClassLoader());
          serviceMetaData = new ServiceMetaData(wsMetaData, serviceName);
          wsMetaData.addService(serviceMetaData);
       } 
  
> UnifiedMetaData uses thread context loader to find classes, this can lead to javassist.NotFoundException
> --------------------------------------------------------------------------------------------------------
>
>                 Key: JBWS-2810
>                 URL: https://jira.jboss.org/jira/browse/JBWS-2810
>             Project: JBoss Web Services
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: jbossws-native
>    Affects Versions: jbossws-native-3.0.1
>            Reporter: Johannes Rudolph
>            Assignee: Alessio Soldano
>             Fix For:  jbossws-native-3.2.2
>
>
> See this description on the seam page:
> http://seamframework.org/Community/AsynchronousJavassistClassloadProblem
> or another stack trace here. [1]
> If you call Service.getPort from a Thread for which the context class loader is not set correctly, the call fails like shown.  This can happen, for example, when scheduled on another Thread. Wouldn't it be better to use a ClassLoader which is more likely to return the domain class? For example the ClassLoader of the Class object passed to the Service.getPort call?
> This gives rise to subtle bugs, where this occurs only after JBoss AS was freshly started. After a redeploy some ClassLoader magic has happened and everything is working as expected.
> [1] (I replaced some domain Class names with XXX)
> 15:05:37,582 ERROR [STDERR] org.jboss.ws.WSException: Could not generate wrapper type: XXX
> 15:05:37,582 ERROR [STDERR] at org.jboss.ws.core.jaxws.DynamicWrapperGenerator.generate(DynamicWrapperGenerator.java:124)
> 15:05:37,582 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.processWebMethod(JAXWSMetaDataBuilder.java:774)
> 15:05:37,582 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilder.processWebMethods(JAXWSMetaDataBuilder.java:891)
> 15:05:37,584 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxws.JAXWSClientMetaDataBuilder.rebuildEndpointMetaData(JAXWSClientMetaDataBuilder.java:300)
> 15:05:37,585 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPortInternal(ServiceDelegateImpl.java:271)
> 15:05:37,585 ERROR [STDERR] at org.jboss.ws.core.jaxws.spi.ServiceDelegateImpl.getPort(ServiceDelegateImpl.java:202)
> 15:05:37,585 ERROR [STDERR] at javax.xml.ws.Service.getPort(Service.java:143)
> [...]
> 15:05:37,585 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 15:05:37,585 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,585 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,585 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
> 15:05:37,585 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
> 15:05:37,585 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
> 15:05:37,585 ERROR [STDERR] at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
> 15:05:37,585 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
> 15:05:37,585 ERROR [STDERR] at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
> 15:05:37,585 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 15:05:37,585 ERROR [STDERR] at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:30)
> 15:05:37,586 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor255.invoke(Unknown Source)
> 15:05:37,586 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,586 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:187)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:72)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
> 15:05:37,586 ERROR [STDERR] at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
> 15:05:37,587 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 15:05:37,587 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,587 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,587 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
> 15:05:37,587 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
> 15:05:37,587 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
> 15:05:37,587 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,587 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
> 15:05:37,587 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,587 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
> 15:05:37,587 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,587 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
> 15:05:37,587 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
> 15:05:37,587 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
> 15:05:37,588 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
> 15:05:37,588 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
> 15:05:37,588 ERROR [STDERR] at $Proxy171.callUpdateContractConditions(Unknown Source)
> 15:05:37,588 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 15:05:37,588 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,588 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,588 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.async.AsynchronousInterceptor.aroundInvoke(AsynchronousInterceptor.java:52)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
> 15:05:37,588 ERROR [STDERR] at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
> 15:05:37,589 ERROR [STDERR] at org.javassist.tmp.java.lang.Object_$$_javassist_seam_13.callUpdateContractConditions(Object_$$_javassist_seam_13.java)
> 15:05:37,589 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 15:05:37,589 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,589 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 15:05:37,589 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
> 15:05:37,589 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
> 15:05:37,589 ERROR [STDERR] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
> 15:05:37,589 ERROR [STDERR] at org.jboss.seam.async.AsynchronousInvocation$1.process(AsynchronousInvocation.java:62)
> 15:05:37,589 ERROR [STDERR] at org.jboss.seam.async.Asynchronous$ContextualAsynchronousRequest.run(Asynchronous.java:80)
> 15:05:37,589 ERROR [STDERR] at org.jboss.seam.async.AsynchronousInvocation.execute(AsynchronousInvocation.java:44)
> 15:05:37,589 ERROR [STDERR] at org.jboss.seam.async.QuartzDispatcher$QuartzJob.execute(QuartzDispatcher.java:243)
> 15:05:37,589 ERROR [STDERR] at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
> 15:05:37,589 ERROR [STDERR] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
> 15:05:37,589 ERROR [STDERR] Caused by: javassist.NotFoundException: XXX
> 15:05:37,589 ERROR [STDERR] at javassist.ClassPool.get(ClassPool.java:436)
> 15:05:37,589 ERROR [STDERR] at org.jboss.ws.core.jaxws.DynamicWrapperGenerator.addProperty(DynamicWrapperGenerator.java:203)
> 15:05:37,589 ERROR [STDERR] at org.jboss.ws.core.jaxws.DynamicWrapperGenerator.generate(DynamicWrapperGenerator.java:111)
> 15:05:37,589 ERROR [STDERR] ... 87 more

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jbossws-issues mailing list