You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by js...@apache.org on 2006/07/28 03:01:18 UTC

svn commit: r426346 - /geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java

Author: jsisson
Date: Thu Jul 27 18:01:17 2006
New Revision: 426346

URL: http://svn.apache.org/viewvc?rev=426346&view=rev
Log:
GERONIMO-2222 Application errors in static initialization blocks during serialization of configuration during deployment due to incorrect TCCL

Modified:
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=426346&r1=426345&r2=426346&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java (original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Thu Jul 27 18:01:17 2006
@@ -307,6 +307,15 @@
             if (configurations.isEmpty()) {
                 throw new DeploymentException("Deployer did not create any configurations");
             }
+
+            // Set TCCL to the classloader for the configuration being deployed
+            // so that any static blocks invoked during the loading of classes 
+            // during serialization of the configuration have the correct TCCL 
+            // ( a TCCL that is consistent with what is set when the same
+            // classes are loaded when the configuration is started.
+            Thread thread = Thread.currentThread();
+            ClassLoader oldCl = thread.getContextClassLoader();
+            thread.setContextClassLoader( context.getConfiguration().getConfigurationClassLoader());
             try {
                 if (targetFile != null) {
                     if (configurations.size() > 1) {
@@ -339,6 +348,7 @@
                 // unlikely as we just built this
                 throw new DeploymentException(e);
             } finally {
+                thread.setContextClassLoader(oldCl);
                 if (context != null) {
                     context.close();
                 }