tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nlif <naa...@dbnet.co.il>
Subject Problem serializing JDK dynamic proxies
Date Thu, 03 Apr 2008 11:28:06 GMT

Hi all,

I am using Java 1.6, Tomcat 6, and running in a cluster, with
session-replication.
When I put in the http-session a JDK dynamic proxy, the serialization fails,
like so:

Apr 3, 2008 2:09:24 PM org.apache.catalina.ha.session.DeltaManager
messageReceived
SEVERE: Manager [localhost#/users]: Unable to receive message through TCP
channel
java.lang.ClassNotFoundException: app.web.user.TestBean
        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.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.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)

Here is the relevant code:

The servlet:

        TestBean    testBean          = new TestBeanImpl();
        Class[]     proxiedInterfaces = testBean.getClass().getInterfaces();
        ClassLoader classLoader       =
Thread.currentThread().getContextClassLoader();
        TestProxy   proxy             = new TestProxy(testBean);
        TestBean    proxiedBean       = (TestBean)
Proxy.newProxyInstance(classLoader, proxiedInterfaces, proxy);

        request.getSession().setAttribute("testBean", proxiedBean);

The TestBean interface:

        public interface TestBean {
	     public void op1();
        }

The TestBeanImpl class:

    public class TestBeanImpl implements TestBean, Serializable
    {
        public void op1()
        {
            System.out.println("doing op1");
        }
    }

The TestProxy class:

   public class TestProxy implements InvocationHandler, Serializable
    {
        private static final long serialVersionUID = 1L;
        private Object target;

        public TestProxy(Object target)
        {
            this.target                            = target;
        }

        public Object invoke(Object proxy, Method method, Object[] args)
            throws Throwable
        {
            System.out.println("proxy invoked");
            return method.invoke(target, args);
        }
    }

My application is deployed as a WAR file.

Has anyone been able to put proxies in the HttpSession and replicate
successfully?
Is this a Tomcat bug?
Is this a problem in my implementation?

Thanks
Naaman


-- 
View this message in context: http://www.nabble.com/Problem-serializing-JDK-dynamic-proxies-tp16467407p16467407.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message