Hi Chris,

Thanks for the link. I found the following workaround: instead of placing my
Proxy object in the HttpSession, I put it in a serializable wrapper class
first, and then put the wrapper in the HttpSession. The wrapper overrides
the default de-serialization to set a different class-loader as the
thread-local class-loader. Now, session replication completes without
throwing the exception. 

Here is the code of the Wrapper:

public class ProxyWrapper implements Serializable
{
    private Object Proxy;

    public ProxyWrapper(Object proxy)
    {
        Proxy = proxy;
    }

    public Object getProxy()
    {
        return Proxy;
    }

    private void readObject(java.io.ObjectInputStream in)
        throws IOException, ClassNotFoundException
    {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();

        try
        {
            ClassLoader myCl = this.getClass().getClassLoader();
            Thread.currentThread().setContextClassLoader(myCl);
            in.defaultReadObject();
        }
        finally
        {
            Thread.currentThread().setContextClassLoader(cl);
        }
    }
}

IMHO, this, as well as the dynamic-proxy documentation, implies there is a
problem in Tomcat's session-replication implementation.


Naaman
-- 
View this message in context: 
http://www.nabble.com/Problem-serializing-JDK-dynamic-proxies-tp16467407p16521737.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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to