Revision: 15218
Author: [email protected]
Date: Mon Nov 15 08:02:30 2010
Log: Update Issue 1873

Fixing the Classloading issue
http://code.google.com/p/mobicents/source/detail?r=15218

Modified:
/trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/JBossCacheSipManager.java

=======================================
--- /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/JBossCacheSipManager.java Mon Nov 15 03:34:52 2010 +++ /trunk/servers/sip-servlets/sip-servlets-jboss5/src/main/java/org/jboss/web/tomcat/service/session/JBossCacheSipManager.java Mon Nov 15 08:02:30 2010
@@ -2482,30 +2482,36 @@
                        if(session == null) {
                                initialLoad = true;
                        }
- IncomingDistributableSessionData data = getDistributedCacheConvergedSipManager().getSipSessionData(applicationSessionKey.getId(), SessionManagerUtil.getSipSessionHaKey(key), initialLoad);
-            if (data != null)
-            {
-               if(logger.isDebugEnabled()) {
- logger.debug("data for sip session " + key + " found in the distributed cache");
-                       }
-               if (session == null && sipApplicationSessionImpl != null) {
-                               // This is either the first time we've seen 
this session on this
-                               // server, or we previously expired it and have 
since gotten
-                               // a replication message from another server
-                               mustAdd = true;
-                               initialLoad = true;
- session = (ClusteredSipSession<? extends OutgoingDistributableSessionData>) sipManagerDelegate.getSipSession(key, true, sipFactory, sipApplicationSessionImpl);
-                               OwnedSessionUpdate osu = 
unloadedSipSessions_.get(key);
-                       passivated = (osu != null && osu.passivated);
-                       }
-               if(session != null) {
-                       session.update(data);
-               }
-            } else {
-               if(logger.isDebugEnabled()) {
- logger.debug("no data for sip session " + key + " in the distributed cache");
-                       }
-            }
+                       // Swap in/out the webapp classloader so we can 
deserialize
+                // attributes whose classes are only available to the webapp
+                       ClassLoader prevTCL = 
Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(getApplicationClassLoader());
+                       try {
+ IncomingDistributableSessionData data = getDistributedCacheConvergedSipManager().getSipSessionData(applicationSessionKey.getId(), SessionManagerUtil.getSipSessionHaKey(key), initialLoad);
+                   if (data != null)
+                   {
+                       if(logger.isDebugEnabled()) {
+ logger.debug("data for sip session " + key + " found in the distributed cache");
+                               }
+                       if (session == null && sipApplicationSessionImpl != 
null) {
+ // This is either the first time we've seen this session on this
+                                       // server, or we previously expired it 
and have since gotten
+                                       // a replication message from another 
server
+                                       mustAdd = true;
+                                       initialLoad = true;
+ session = (ClusteredSipSession<? extends OutgoingDistributableSessionData>) sipManagerDelegate.getSipSession(key, true, sipFactory, sipApplicationSessionImpl);
+                                       OwnedSessionUpdate osu = 
unloadedSipSessions_.get(key);
+                               passivated = (osu != null && osu.passivated);
+                               }
+                       if(session != null) {
+                                               session.update(data);
+                       }
+                   } else if(logger.isDebugEnabled()) {
+ logger.debug("no data for sip session " + key + " in the distributed cache");
+                   }
+                       } finally {
+                               
Thread.currentThread().setContextClassLoader(prevTCL);
+                       }
 //            else if(mustAdd)
 //            {
 //               // Clunky; we set the session variable to null to indicate
@@ -2615,25 +2621,35 @@
                        if(session == null) {
                                initialLoad = true;
                        }
-                       IncomingDistributableSessionData data =
- getDistributedCacheConvergedSipManager().getSipApplicationSessionData(key.getId(), initialLoad);
-                       if (data != null) {
-                               if (session == null) {
-                                       // This is either the first time we've 
seen this session on
-                                       // this
-                                       // server, or we previously expired it 
and have since gotten
-                                       // a replication message from another 
server
-                                       mustAdd = true;
-                                       initialLoad = true;
-                                       session = 
(ClusteredSipApplicationSession)
-                                               
sipManagerDelegate.getSipApplicationSession(key, true);
-                                       OwnedSessionUpdate osu = 
unloadedSipApplicationSessions_.get(key);
-                                       passivated = (osu != null && 
osu.passivated);
-                               }
-                               if(session != null) {
-                                       session.update(data);
-                               }
-                       }
+                        // Swap in/out the webapp classloader so we can 
deserialize
+                // attributes whose classes are only available to the webapp
+                       ClassLoader prevTCL = 
Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(getApplicationClassLoader());
+                       try {
+                               IncomingDistributableSessionData data =
+ getDistributedCacheConvergedSipManager().getSipApplicationSessionData(key.getId(), initialLoad);
+                               if (data != null) {
+                                       if (session == null) {
+                                               // This is either the first 
time we've seen this session on
+                                               // this
+                                               // server, or we previously 
expired it and have since gotten
+                                               // a replication message from 
another server
+                                               mustAdd = true;
+                                               initialLoad = true;
+                                               session = 
(ClusteredSipApplicationSession)
+                                                       
sipManagerDelegate.getSipApplicationSession(key, true);
+                                               OwnedSessionUpdate osu = 
unloadedSipApplicationSessions_.get(key);
+                                               passivated = (osu != null && 
osu.passivated);
+                                       }
+                                       if(session != null) {
+                                               session.update(data);
+                                       }
+                               } else if(logger.isDebugEnabled()) {
+ logger.debug("no data for sip application session " + key + " in the distributed cache");
+                       }
+                       } finally {
+                               
Thread.currentThread().setContextClassLoader(prevTCL);
+                       }
 //                     else if (mustAdd) {
 //                             // Clunky; we set the session variable to null 
to indicate
 //                             // no data so move on

Reply via email to