Hmm, you are right...
I see that we only set context classloader at
DeltaManager.loadDeltaRequest at deserialize information
Loader loader = null;
ClassLoader classLoader = null;
//fix to be able to run the DeltaManager
//stand alone without a container.
//use the Threads context class loader
if (container != null)
loader = container.getLoader();
if (loader != null)
classLoader = loader.getClassLoader();
else
classLoader = Thread.currentThread
().getContextClassLoader();
//end fix
fis = new ByteArrayInputStream(data);
ois = new ReplicationStream(fis, classLoader);
but we not set thread context class loader for listeners :-(
see. DeltaManager.handle_SESSION_XXX
Peter
Am 21.05.2006 um 13:58 schrieb Filip Hanik - Dev Lists:
what does line ClusterAppSessionListener.java:47 do?
can you send us a test case, could be possible that the context
classloader isn't set, hence the loading is failing.
java.lang.ClassCastException: com.package1.subpackage1.GW
at common.listeners.ClusterAppSessionListener.printSessionInfo
(ClusterAppSessionListener.java:47)
at common.listeners.ClusterAppSessionListener.attributeAdded
(ClusterAppSessionListener.java:26)
at
org.apache.catalina.cluster.session.DeltaSession.setAttribute
(DeltaSession.java:1310)
Filip
Jean-Christophe Praud wrote:
No. This a specific class for my webapp. It is located in the
webapp's /classes tree, and is instantiated only once per session.
Tim Lucia wrote:
Are there multiple copies of this class in scope (loaded by
different class
loaders)? I know if you have some Oracle classes in WEB-INF/lib
AND in
common/lib, you can get a CCE casting from a oracle.X to an
oracle.X as they
come from different class loaders.
Tim
-----Original Message-----
From: Jean-Christophe Praud [mailto:[EMAIL PROTECTED] Sent: Thursday,
May 18, 2006 11:02 AM
To: users@tomcat.apache.org
Subject: ClassCastException on cluster deserialization
Hi all,
I'm setting up a Tomcat cluster on two servers, and I keep
getting a ClassCastException on a session variable (GW). The
server which handles the request works well, but the other one
can't get the session data.
Its GW object seems to be instantiated, valueBound
(HttpSessionBindingEvent event) is called, the object is added to
the session, then I get the Exception.
I tried with Tomcat 5.5.16 and 5.5.17, with several <Sender>
replicationMode.
My session variable com.package1.subpackage1.GW implements the
Serializable interface and contains some classes which are also
Serializable. I don't see any Exception from the writeObject or
readObject methods on any server.
My config :
<Cluster
className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
<Membership
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
<Receiver
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
<Sender
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="synchronous"
autoConnect="true"
keepAliveTimeout="-1"
ackTimeout="15000"/>
<Valve
className="org.apache.catalina.cluster.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*
\.htm;.*\.html;.*\.css;.*\.txt;"/>
<Deployer
className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener
className="org.apache.catalina.cluster.session.ClusterSessionListene
r"/>
</Cluster>
The Exception's log :
18 mai 2006 16:48:28
org.apache.catalina.cluster.session.DeltaSession setAttribute
GRAVE: Session attribute event listener threw exception
java.lang.ClassCastException: com.package1.subpackage1.GW
at
common.listeners.ClusterAppSessionListener.printSessionInfo
(ClusterAppSessio
nListener.java:47)
at
common.listeners.ClusterAppSessionListener.attributeAdded
(ClusterAppSessionL
istener.java:26)
at
org.apache.catalina.cluster.session.DeltaSession.setAttribute
(DeltaSession.j
ava:1310)
at org.apache.catalina.cluster.session.DeltaRequest.execute
(DeltaRequest.java:1
59)
at
org.apache.catalina.cluster.session.DeltaManager.handleSESSION_DELTA
(DeltaMa
nager.java:1565)
at
org.apache.catalina.cluster.session.DeltaManager.messageReceived
(DeltaManage
r.java:1516)
at
org.apache.catalina.cluster.session.DeltaManager.messageDataReceived
(DeltaMa
nager.java:1268)
at
org.apache.catalina.cluster.session.ClusterSessionListener.messageRe
ceived(C
lusterSessionListener.java:85)
at org.apache.catalina.cluster.tcp.SimpleTcpCluster.receive
(SimpleTcpCluster.ja
va:1163)
at
org.apache.catalina.cluster.tcp.ClusterReceiverBase.messageDataRecei
ved(Clus
terReceiverBase.java:418)
at org.apache.catalina.cluster.io.ObjectReader.execute
(ObjectReader.java:107)
at
org.apache.catalina.cluster.tcp.TcpReplicationThread.drainChannel
(TcpReplica
tionThread.java:138)
at org.apache.catalina.cluster.tcp.TcpReplicationThread.run
(TcpReplicationThrea
d.java:69)
What did I miss ?
Regards,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]