Bug 22041 - Loading DynamicProxys from session
Summary: Loading DynamicProxys from session
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 4.1.18
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-01 07:46 UTC by Martin Harm
Modified: 2005-03-10 15:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Harm 2003-08-01 07:46:48 UTC
If you got a DynamicProxy inside the session, catalina fails to load this 
object.




Suggested fix: (tested just a little bit, not realy)


in: org.apache.catalina.util.CustomObjectInputStream 


overwrite the method 


protected Class resolveProxyClass(String[] interfaces)


with the implementation of java.io.ObjectInputStream except


the first line 


ClassLoader latestLoader = classLoader; 


  // instead of ClassLoader latestLoader = latestUserDefinedLoader();




this seams to work..
Comment 1 Mark Thomas 2004-06-16 19:50:45 UTC
I'd prefer something along the lines of the patch below. Could you test this 
(or attach a simple test case to this bug report). If it works, I'll commit it.

Index: catalina/src/share/org/apache/catalina/util/CustomObjectInputStream.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-
catalina/catalina/src/share/org/apache/catalina/util/Cu
stomObjectInputStream.java,v
retrieving revision 1.3
diff -u -r1.3 CustomObjectInputStream.java
--- catalina/src/share/org/apache/catalina/util/CustomObjectInputStream.java
27 Feb 2004 14:58:50 -0000      1.3
+++ catalina/src/share/org/apache/catalina/util/CustomObjectInputStream.java
16 May 2004 13:35:18 -0000
@@ -72,5 +72,27 @@
         return Class.forName(classDesc.getName(), false, classLoader);
     }

+    /**
+     * Return a proxy class that implements the interfaces named in a proxy
+     * class descriptor. Do this using the class loader assigned to this
+     * Context.
+     */
+    protected Class resolveProxyClass(String[] interfaces)
+        throws IOException, ClassNotFoundException {
+
+        ClassLoader originalClassLoader =
+            Thread.currentThread().getContextClassLoader();
+
+        // Set thread to use context class loader
+        Thread.currentThread().setContextClassLoader(classLoader);
+
+        // Use super class to do all the real work
+        Class clazz = super.resolveProxyClass(interfaces);
+
+        // Swap back to original class loader
+        Thread.currentThread().setContextClassLoader(originalClassLoader);
+
+        return clazz;
+    }

 } 
Comment 2 Mark Thomas 2005-03-11 00:56:28 UTC
My sugested patch above doesn't work. However, I have committed an alternative
patch that does.

The patch was also ported to TC5.5.x