DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23112>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23112 RMI does not work when web app docbase path contains spaces Summary: RMI does not work when web app docbase path contains spaces Product: Tomcat 4 Version: 4.1.24 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] If the file path of the web app document base (e.g. when <Context> elements are used to point to a docBase outside of Tomcat, for instance) contains spaces, then RMI from within this web app will not function properly. This turns out to be a bug in Tomcat 4.1.24 (and higher, i.e. Tomcat 4.1.x does not yet have a fix in HEAD), i.e. I have tracked down the offending code. Tomcat uses File.toURL() to produce the responses to its WebappClassLoader.getURLs() method. Since WebappClassLoader is a subclass of URLClassLoader, the results of getURLs() are concatenated into a space delimited string used in calls to RMIClassLoader.loadClass() as the 'codebase' argument (at least during normal RMI operation). If these URLs have spaces within them, then the RMIClassLoader generates MalformedURLExceptions here as the 'codebase' argument cannot be properly parsed. The Java 2 v1.4.x Javadoc states that File.toURL() cannot be relied upon to create properly escaped URLs (!) and that one should use File.toURI().toURL() instead. Unfortunately java.net.URI is specific to 1.4 and higher JVMs... I am already subclassing WebappClassLoader (to extend the intrinsic virtual classpath of web apps), so I just overrode WebappClassLoader.getURL(File) such that it now works properly. Essentially I load a helper class that uses java.net.URI to do what the 1.4 Javadocs suggest at static init time via reflection and create an instance of it, i.e. when I can. If this static field is non-null in getURL, then I use it, else (i.e. in Java 1.3.x) I replace all spaces with %20's manually. My fix works fine, but it should really be integrated into Tomcat in WebappClassLoader.getURL(File) rather than my subclass. Let me know if sources are desired, but the fix is quite simple. [Note that this does apply to all platforms to the best of my understanding in that while no one I know is stupid enough to put spaces in directory names on UNIX it can be done...] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]