Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 861e2b043d0ec623da7c5df4181ecfa4 > files > 3

struts-1.2.9-6mdv2009.0.src.rpm

RequestUtils.applicationClass() uses the context classloader to find
the class, but for some reason it sometimes seems to be set to what
looks like the normal system classloader.  Possibly its something to
do with the fact that MessageResourcesFactory.createFactory() is
called from MessageResources.getMessageResources() which is usually
called from <clinit> methods.  Or, it could be because RequestUtils
itself calls getMessageResources(), so createFactory() reenters
itself.

--- jakarta-struts-1.1-src/src/share/org/apache/struts/util/MessageResourcesFactory.java.orig	2003-06-30 05:51:19.000000000 +0100
+++ jakarta-struts-1.1-src/src/share/org/apache/struts/util/MessageResourcesFactory.java	2005-05-09 13:36:32.000000000 +0100
@@ -188,8 +188,16 @@
 
         // Construct a new instance of the specified factory class
         try {
-            if (clazz == null)
-                clazz = RequestUtils.applicationClass(factoryClass);
+            if (clazz == null) {
+                if (System.getProperty("java.vm.name").equals("GNU libgcj")) {
+                    // XXX should use context class loader but it's wrong
+                    ClassLoader classLoader =
+                        MessageResourcesFactory.class.getClassLoader();
+                    clazz = classLoader.loadClass(factoryClass);
+                }
+                else
+                    clazz = RequestUtils.applicationClass(factoryClass);
+            }
             MessageResourcesFactory factory =
                 (MessageResourcesFactory) clazz.newInstance();
             return (factory);