Bug 42662

Summary: Classloader issue for replicated sessions and dynamic proxies
Product: Tomcat 6 Reporter: Michael Wyraz <michael>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: critical    
Priority: P2    
Version: unspecified   
Target Milestone: default   
Hardware: Other   
OS: Linux   
Attachments: Webapp to reproduce the problem

Description Michael Wyraz 2007-06-14 06:37:49 UTC
We use 2 tomcats (tomcat 6.0.13) as Cluster with default tcp session
replication. Some webapps contains complex session information including dynamic
generated proxies.

The problem is that the classloader used to deserialize the proxy cannot load
any of the proxy interfaces during initialisation. The result is a
"ClassNotFoundException" but the interface class is pressent.

I will attach a minimal webapp to reproduce the problem. The exception thrown is
below. The exception is thrown, when both tomcats are running and the servlet is
called on one of them (the other tomcat throws the exception).

java.lang.ClassNotFoundException: proxytest.TestProxyInterface
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at java.io.ObjectInputStream.resolveProxyClass(ObjectInputStream.java:676)
        at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at
org.apache.catalina.ha.session.DeltaRequest$AttributeInfo.readExternal(DeltaRequest.java:361)
        at
org.apache.catalina.ha.session.DeltaRequest.readExternal(DeltaRequest.java:255)
        at
org.apache.catalina.ha.session.DeltaManager.deserializeDeltaRequest(DeltaManager.java:619)
        at
org.apache.catalina.ha.session.DeltaManager.handleSESSION_DELTA(DeltaManager.java:1363)
        at
org.apache.catalina.ha.session.DeltaManager.messageReceived(DeltaManager.java:1320)
        at
org.apache.catalina.ha.session.DeltaManager.messageDataReceived(DeltaManager.java:1083)
        at
org.apache.catalina.ha.session.ClusterSessionListener.messageReceived(ClusterSessionListener.java:87)
        at
org.apache.catalina.ha.tcp.SimpleTcpCluster.messageReceived(SimpleTcpCluster.java:916)
        at
org.apache.catalina.ha.tcp.SimpleTcpCluster.messageReceived(SimpleTcpCluster.java:897)
        at
org.apache.catalina.tribes.group.GroupChannel.messageReceived(GroupChannel.java:264)
        at
org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at
org.apache.catalina.tribes.group.interceptors.TcpFailureDetector.messageReceived(TcpFailureDetector.java:110)
        at
org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at
org.apache.catalina.tribes.group.ChannelInterceptorBase.messageReceived(ChannelInterceptorBase.java:79)
        at
org.apache.catalina.tribes.group.ChannelCoordinator.messageReceived(ChannelCoordinator.java:241)
        at
org.apache.catalina.tribes.transport.ReceiverBase.messageDataReceived(ReceiverBase.java:225)
        at
org.apache.catalina.tribes.transport.nio.NioReplicationTask.drainChannel(NioReplicationTask.java:185)
        at
org.apache.catalina.tribes.transport.nio.NioReplicationTask.run(NioReplicationTask.java:88)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Comment 1 Michael Wyraz 2007-06-14 06:39:14 UTC
Created attachment 20347 [details]
Webapp to reproduce the problem

Deploy the webapp on a cluster of at least 2 nodes (distributable context,
replicated session). Call one node's url and watch the log of the other.
Comment 2 Naaman Lifshitz 2008-04-03 06:35:08 UTC
I have encountered the same problem. Here is my post in the support forum, that includes details, as well as code that can help reproduce the problem.

http://www.nabble.com/Problem-serializing-JDK-dynamic-proxies-td16467407.html

Hope this helps,
Naaman

Comment 3 Filip Hanik 2008-04-05 15:02:58 UTC
Fixed in trunk
http://svn.apache.org/viewvc?view=rev&revision=645184
Will propose backport for 6.0.x branch

Filip
Comment 4 Filip Hanik 2008-05-15 08:20:06 UTC
patch applied to 6.0.x branch, will be available 6.0.17