Bug 42354 - Web App JAR's are not scanned for TLD's if a space in the path
Summary: Web App JAR's are not scanned for TLD's if a space in the path
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.23
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2007-05-08 07:47 UTC by Michael Fletcher
Modified: 2007-05-12 16:29 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Michael Fletcher 2007-05-08 07:47:48 UTC
TLD's are not processed if the webapp is in a folder that has a space in it.

Myspaces is failing using Tomcat 5.5 because its listener was not being 
invoked.  I traced the problem with the debugger and found the problem.  

JAR files in the WEB-INF/lib folder were supposed to be scanned for TLD's.  The 
method getJarPaths in startup/TldConfig.java[1] is supposed to return all the 
JAR files that have a TLD within them.  This method is not working correctly.

The problem is with how the path to the JAR files is locoated.  First all the 
classpath entries for the webapp are converted to URL's.  

  URL[] urls = ((URLClassLoader) loader).getURLs();

Then to test to see the file exists a java.io.File is used

  File file = new File(urls[i].getFile());
  try {
    file = file.getCanonicalFile();
  } catch (IOException e) {
    // Ignore
  if (!file.exists()) { // file.exists() RETURNING FALSE

The problem is to do with converting spaces.  The paths on my web app all 
looked something like "file:///c:/Documents%20%and%20Settings/foo/bar".  The 
File class does not understand the %20 as a space.

A hack would be to add a .replaceAll("%20", " ") but i'm sure this will cause 
problems somewhere.  And is %20 valid in a File URI?

Comment 1 Mark Thomas 2007-05-12 16:29:03 UTC
Fixed in svn and will be included in 5.5.24 onwards.