All of these patches are against the jakarta-tomcat-4.0-b1.tar.gz distribution, since it gave me a stable(?) place from which to work. If I have commited a faux pas by doing this, just let me know. Bug 1002 is in regard to the SecurityException: sealing violation. The comments and javadoc explain in detail, but the brief idea is that there is a HIGH likelyhood that the sealing exception is caused by a user's WEB-INF entry, thus, to circumvent the SecurityException just catch it and delegate to the parent classloader (who has a HIGH likelyhood of containing the real jar, otherwise we wouldn't have gotten the SecurityException). This patch also fixes a NullPointerException (I hate those) because our WebApp (deployed from our filesystem) did not contain a Manifest. This is a double patch, since the Extension class did not return empty Lists like the javadoc said it would, and the StandardClassLoader didn't check for there not being a Manifest before calling Extension. I saw that someone else in the mailing list called this out, but it was still broken in 4.0-b1. Also included in this patch (for continutity) is the RequestBase returning -1 as the server port, which IMHO is extremely bad. Above and beyond the moral implications of a port being -1, when used with my Warp connection it was returning "Location: http://localhost:-1/index.jsp" headers. Further included in this patch is a WarpEngine correction with regard to the HostID not being initialized. I realize that this is a touch "kludgy", but that's why it's OpenSource, right? :-) In the separate file, I patched the JikesJavaCompiler to work to my liking. :-) Seriously, on the Linux Sun 1.3.0_02 vm (and prior ones), the java.class.path does not contain rt.jar, which jikes will not work without. I saw that someone had already included a workaround for MicrosoftVM, so I just updated it. In the last patch, I found it a thousand times more useful to use the Ant support for property files rather than trying to monkey with your build.sh and the 100 environmental variables. I think including this patch in the standard distribution is a Good Thing(tm) because if the user wants to use build.properties, great, and if not Ant will /silently/ ignore the entry. I also know how to make a WebApp talk to Inprise Application Server using only the WebApp (contra starting Catalina using vbj), if anyone is interested in such a trick. I hope these help you as much as they help me. -- /v\atthew -- Matthew L Daniel Discovery is seeing what everybody Internet Developer, else has seen, and thinking what Still Current Development, Inc. nobody else has thought. [EMAIL PROTECTED] -- Albert, Szent-Gyorgi
diff -Nru src_orig/catalina/src/share/org/apache/catalina/connector/RequestBase.java src/catalina/src/share/org/apache/catalina/connector/RequestBase.java --- src_orig/catalina/src/share/org/apache/catalina/connector/RequestBase.java Sat Dec 23 22:40:15 2000 +++ src/catalina/src/share/org/apache/catalina/connector/RequestBase.java Wed +Mar 21 19:13:51 2001 @@ -97,6 +97,7 @@ * be used for the Request implementation required by most Connectors. Only * the connector-specific methods need to be implemented. * + * @author Matthew L Daniel <[EMAIL PROTECTED]> * @author Craig R. McClanahan * @version $Revision: 1.9 $ $Date: 2000/12/22 18:58:00 $ */ @@ -929,6 +930,19 @@ * Return the server port responding to this Request. */ public int getServerPort() { + if( serverPort == -1 ) { + // If they didn't say, presume the worst. + serverPort = secure ? 443 : 80; + // This is only to print the stack trace to the output so + // someone smarter than me can REALLY fix this. + try { + throw new IllegalArgumentException( + "ServerPort is -1; secure is "+secure + +", so I am returning "+serverPort); + } catch( IllegalArgumentException iae ) { + iae.printStackTrace(System.out); + } + } return (this.serverPort); diff -Nru src_orig/catalina/src/share/org/apache/catalina/connector/warp/WarpEngine.java src/catalina/src/share/org/apache/catalina/connector/warp/WarpEngine.java --- src_orig/catalina/src/share/org/apache/catalina/connector/warp/WarpEngine.java Sat Dec 23 22:40:15 2000 +++ src/catalina/src/share/org/apache/catalina/connector/warp/WarpEngine.java Wed +Mar 21 19:15:00 2001 @@ -72,6 +72,7 @@ /** * * + * @author Matthew L Daniel <[EMAIL PROTECTED]> * @author <a href="mailto:[EMAIL PROTECTED]">Pier Fumagalli</a> * @author Copyright © 1999, 2000 <a href="http://www.apache.org">The * Apache Software Foundation. @@ -176,6 +177,11 @@ this.log(e); return(null); } + } + if (host.getHostID() == -1) { + // This host was specified by server.xml's <Host> tag, and has the + // default id, so we should assign it one of ours + host.setHostID(this.hostid++); } return(host); } diff -Nru src_orig/catalina/src/share/org/apache/catalina/loader/Extension.java src/catalina/src/share/org/apache/catalina/loader/Extension.java --- src_orig/catalina/src/share/org/apache/catalina/loader/Extension.java Sat Dec 23 22:40:21 2000 +++ src/catalina/src/share/org/apache/catalina/loader/Extension.java Wed Mar 21 +19:15:06 2001 @@ -66,6 +66,7 @@ import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -90,6 +91,7 @@ * Java2 Standard Edition package, in file * <code>guide/extensions/versioning.html</code>. * + * @author Matthew L Daniel <[EMAIL PROTECTED]> * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2000/09/29 20:44:07 $ */ @@ -293,6 +295,7 @@ * @param manifest Manifest to be parsed */ public static List getAvailable(Manifest manifest) { + if( manifest == null ) return Collections.EMPTY_LIST; ArrayList results = new ArrayList(); Extension extension = null; @@ -328,6 +331,7 @@ * @param manifest Manifest to be parsed */ public static List getRequired(Manifest manifest) { + if( manifest == null ) return Collections.EMPTY_LIST; ArrayList results = new ArrayList(); diff -Nru src_orig/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java src/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java --- src_orig/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java Sat Dec 23 22:40:18 2000 +++ src/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java Thu +Mar 22 11:28:52 2001 @@ -98,6 +99,7 @@ * from this class to any other Catalina class, so that it could be used * independently. * + * @author Matthew L Daniel <[EMAIL PROTECTED]> * @author Craig R. McClanahan * @version $Revision: 1.5 $ $Date: 2000/10/09 21:04:02 $ */ @@ -927,6 +929,17 @@ * If the class was found using the above steps, and the * <code>resolve</code> flag is <code>true</code>, this method will then * call <code>resolveClass(Class)</code> on the resulting Class object. + * <p> + * <strong>IMPLEMENTATION NOTE</strong> + * There exists the case where we can have a Sealed jar in the system + * classpath, and a class from that Sealed jar found in a user's WEB-INF. + * This will cause us (as the classloader for the user's WEB-INF) to throw + * a <code>java.lang.SecurityException</code> if we try and load that one + * class from the non-sealed jar. Therefore, to circumvent this problem, + * if we encounter a SecurityException, we delegate to our parent + * classloader, since the SecurityException is indication that someone + * already owns that class (and is sure isn't us). + * </p> * * @param name Name of the class to be loaded * @param resolve If <code>true</code> then resolve the class @@ -992,6 +1005,13 @@ resolveClass(clazz); return (clazz); } + } catch (SecurityException se) { + // Most likely, the a jar was sealed but our friend's put a + // class from the sealed jar into their WEB-INF. So, pretend + // we didn't find it. + // Q.V. Bugzilla ID # 1002 + log("SecurityException "+se.getMessage()+" is being eaten."); + // This will fall through to the parent classloader below. } catch (ClassNotFoundException e) { ; } @@ -1060,14 +1080,16 @@ repository + "'"); } Manifest manifest = jarFile.getManifest(); - Iterator extensions = - Extension.getAvailable(manifest).iterator(); - while (extensions.hasNext()) - available.add(extensions.next()); - extensions = - Extension.getRequired(manifest).iterator(); - while (extensions.hasNext()) - required.add(extensions.next()); + if (manifest != null) { + Iterator extensions = + Extension.getAvailable(manifest).iterator(); + while (extensions.hasNext()) + available.add(extensions.next()); + extensions = + Extension.getRequired(manifest).iterator(); + while (extensions.hasNext()) + required.add(extensions.next()); + } jarFile.close(); } catch (Throwable t) { throw new IllegalArgumentException("addRepositoryInternal: " + t);
diff -Nru src_orig/jasper/src/share/org/apache/jasper/compiler/JikesJavaCompiler.java src/jasper/src/share/org/apache/jasper/compiler/JikesJavaCompiler.java --- src_orig/jasper/src/share/org/apache/jasper/compiler/JikesJavaCompiler.java Sat Dec 23 22:40:31 2000 +++ src/jasper/src/share/org/apache/jasper/compiler/JikesJavaCompiler.java Wed +Mar 21 19:15:16 2001 @@ -67,9 +67,15 @@ import java.io.File; import java.io.ByteArrayOutputStream; +import org.apache.jasper.Constants; +import org.apache.jasper.logging.Logger; + /** * A Plug-in class for specifying a 'jikes' compile. + * Logs the command it uses to the JASPER_LOG if logging is set to + * <code>Logging.DEBUG</code>. * + * @author Matthew L Daniel <[EMAIL PROTECTED]> * @author Jeffrey Chiu * @author Hans Bergsten <[EMAIL PROTECTED]> */ @@ -79,12 +85,13 @@ static final int BUFFER_SIZE = 512; /* - * Contains extra classpath for Jikes use from Microsoft systems: + * Contains extra classpath for Jikes use in buggy VM implementations. + * (Internal classpath with other JVMs contains, for instance, rt.jar). * Microsoft does not report it's internal classpath in * System.getProperty(java.class.path) which results in jikes to fail. - * (Internal classpath with other JVMs contains for instance rt.jar). + * Sun's VM on Linux is the same way. */ - static StringBuffer MicrosoftClasspath = null; + static StringBuffer vendorBootClassPath = null; String encoding; String classpath; @@ -138,8 +145,8 @@ // Used to dynamically load classpath if using Microsoft // virtual machine - if (MicrosoftClasspath==null) { - MicrosoftClasspath = new StringBuffer(200); + if (vendorBootClassPath==null) { + vendorBootClassPath = new StringBuffer(200); if (System.getProperty("java.vendor").startsWith("Microsoft")) { quote = "\""; //Get Microsoft classpath @@ -148,19 +155,40 @@ File libDir=new File(javaHome); String[] zips=libDir.list(); for(int i=0;i<zips.length;i++) { - MicrosoftClasspath.append(";" + javaHome + "\\" + zips[i]); + vendorBootClassPath.append( + File.pathSeparator + javaHome + "\\" + zips[i]); } } + String sunBootClassPath = System.getProperty("sun.boot.class.path"); + // If we are not running on a Sun VM, just ignore it. + if (null != sunBootClassPath) { + vendorBootClassPath.append( + File.pathSeparator + sunBootClassPath); + } } + String[] compilerCmd = new String[] { quote + compilerPath + quote, //XXX - add encoding once Jikes supports it - "-classpath", quote + classpath + MicrosoftClasspath + quote, + "-classpath", quote + classpath + vendorBootClassPath + quote, "-d", quote + outdir + quote, "-nowarn", quote + source + quote }; + + Logger jasperLog = Constants.jasperLog; + if (null == jasperLog) jasperLog = Logger.getLogger("JASPER_LOG"); + if (null == jasperLog) jasperLog = Logger.getDefaultLogger(); + if (null != jasperLog && jasperLog.getVerbosityLevel() >= Logger.DEBUG) { + StringBuffer sb = new StringBuffer(); + sb.append("JikesJavaCompiler.compilerCmd:="); + for(int i = 0; i < compilerCmd.length; i++) { + sb.append(compilerCmd[i]); + sb.append(' '); + } + jasperLog.log(sb.toString(), Logger.DEBUG); + } ByteArrayOutputStream tmpErr = new ByteArrayOutputStream(OUTPUT_BUFFER_SIZE); try {
diff -Nru src_orig/build.xml src/build.xml --- src_orig/build.xml Sat Dec 23 22:40:18 2000 +++ src/build.xml Wed Mar 21 18:31:11 2001 @@ -2,6 +2,7 @@ <!-- ===================== Initialize Property Values =================== --> + <property file="build.properties"/> <property name="catalina.build" value="${basedir}/../build/catalina"/> <property name="jasper.build" value="${basedir}/../build/jasper"/> <property name="tomcat.build" value="${basedir}/../build/tomcat-4.0"/>