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

svn commit: r609569 - in /geronimo/server: branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/ trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/

Author: vamsic007
Date: Mon Jan  7 03:03:18 2008
New Revision: 609569

URL: http://svn.apache.org/viewvc?rev=609569&view=rev
Log:
GERONIMO-2503 Webapp classloader prefers WEB-INF/lib over WEB-INF/classes
 o The earlier fix from revs 465638 & 466311 did not go into Web 2.5 builder

Modified:
    geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java

Modified: geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=609569&r1=609568&r2=609569&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Mon Jan  7 03:03:18 2008
@@ -281,23 +281,34 @@
             // add the warfile's content to the configuration
             JarFile warFile = module.getModuleFile();
             Enumeration<JarEntry> entries = warFile.entries();
+            List<ZipEntry> libs = new ArrayList<ZipEntry>();
             while (entries.hasMoreElements()) {
                 ZipEntry entry = entries.nextElement();
                 URI targetPath = new URI(null, entry.getName(), null);
                 if (entry.getName().equals("WEB-INF/web.xml")) {
                     moduleContext.addFile(targetPath, module.getOriginalSpecDD());
                 } else if (entry.getName().startsWith("WEB-INF/lib") && entry.getName().endsWith(".jar")) {
-                    moduleContext.addInclude(targetPath, warFile, entry);
-                    manifestcp.add(entry.getName());
+                    // keep a collection of all libs in the war
+                    // libs must be installed after WEB-INF/classes which must be installed after this copy phase
+                    libs.add(entry);
                 } else {
                     moduleContext.addFile(targetPath, warFile, entry);
                 }
             }
 
-            //always add WEB-INF/classes to the classpath regardless of whether
-            //any classes exist
+            // always add WEB-INF/classes to the classpath regardless of whether
+            // any classes exist.  This must be searched BEFORE the WEB-INF/lib jar files,
+            // per the servlet specifications.
             moduleContext.getConfiguration().addToClassPath("WEB-INF/classes/");
             manifestcp.add("WEB-INF/classes/");
+
+            // install the libs
+            for (ZipEntry entry : libs) {
+                URI targetPath = new URI(null, entry.getName(), null);
+                moduleContext.addInclude(targetPath, warFile, entry);
+                manifestcp.add(entry.getName());
+            }
+
             // add the manifest classpath entries declared in the war to the class loader
             // we have to explicitly add these since we are unpacking the web module
             // and the url class loader will not pick up a manifest from an unpacked dir

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=609569&r1=609568&r2=609569&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Mon Jan  7 03:03:18 2008
@@ -281,23 +281,34 @@
             // add the warfile's content to the configuration
             JarFile warFile = module.getModuleFile();
             Enumeration<JarEntry> entries = warFile.entries();
+            List<ZipEntry> libs = new ArrayList<ZipEntry>();
             while (entries.hasMoreElements()) {
                 ZipEntry entry = entries.nextElement();
                 URI targetPath = new URI(null, entry.getName(), null);
                 if (entry.getName().equals("WEB-INF/web.xml")) {
                     moduleContext.addFile(targetPath, module.getOriginalSpecDD());
                 } else if (entry.getName().startsWith("WEB-INF/lib") && entry.getName().endsWith(".jar")) {
-                    moduleContext.addInclude(targetPath, warFile, entry);
-                    manifestcp.add(entry.getName());
+                    // keep a collection of all libs in the war
+                    // libs must be installed after WEB-INF/classes which must be installed after this copy phase
+                    libs.add(entry);
                 } else {
                     moduleContext.addFile(targetPath, warFile, entry);
                 }
             }
 
-            //always add WEB-INF/classes to the classpath regardless of whether
-            //any classes exist
+            // always add WEB-INF/classes to the classpath regardless of whether
+            // any classes exist.  This must be searched BEFORE the WEB-INF/lib jar files,
+            // per the servlet specifications.
             moduleContext.getConfiguration().addToClassPath("WEB-INF/classes/");
             manifestcp.add("WEB-INF/classes/");
+
+            // install the libs
+            for (ZipEntry entry : libs) {
+                URI targetPath = new URI(null, entry.getName(), null);
+                moduleContext.addInclude(targetPath, warFile, entry);
+                manifestcp.add(entry.getName());
+            }
+
             // add the manifest classpath entries declared in the war to the class loader
             // we have to explicitly add these since we are unpacking the web module
             // and the url class loader will not pick up a manifest from an unpacked dir