Bug 44337 - Dir listing crashes if no readme-file present
Dir listing crashes if no readme-file present
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
6.0.14
Sun Windows Server 2003
: P2 blocker (vote)
: default
Assigned To: Tomcat Developers Mailing List
http://www.a-weinert.de
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2008-02-01 01:54 UTC by Dr. Albrecht Weinert
Modified: 2008-02-12 08:17 UTC (History)
1 user (show)



Attachments
Patch to DefaultServlet.java (1.00 KB, patch)
2008-02-02 10:34 UTC, Tim Funk
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dr. Albrecht Weinert 2008-02-01 01:54:32 UTC
DefaultServlet docu 6.0  says about attibute readmeFile:
If a directory listing is presented, a readme file
 *may* 
also be presented with the listing. This file is inserted
.....

This was true for 5.5.x.

6.0.14 crashes if the file is absent in the listed directory.
javax.servlet.ServletException: 
Error opening readme resource at
org.apache.catalina.servlets.DefaultServlet.getReadme(DefaultServlet.java:1418)

This new behaviour blocks the listing of big directory trees managed by others,
where the work-around is nor feasible.

Work around 1: readme file in *every* subdir, empty (length=0) if none wanted 
     (and subsequent changes in the used XSL-Transformers)
Work around 2: Change "may" to  "must" in docu.

Repair: fix DefaultServlet

From web.xml:

    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>listings</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>globalXsltFile</param-name>
            <param-value>D:\www\serv-intra\meva-dir-li.xsl</param-value>
        </init-param>
        <init-param>
            <param-name>readmeFile</param-name>
            <param-value>readme.htm</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
Comment 1 Tim Funk 2008-02-02 10:34:59 UTC
Created attachment 21461 [details]
Patch to DefaultServlet.java

Patch is for tomcat6 trunk. 

When the readme resource is not found. A NamingException is thrown instead of
assuming null is returned.

Patch eats the NamingException and returns null as well as optionally logs it
if debugging turned up very high.

Same condition can occur with the localxslt lookup.
Comment 2 Tim Funk 2008-02-12 08:17:55 UTC
applied to version 6.0.17+