You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2001/09/17 05:28:22 UTC

DO NOT REPLY [Bug 3644] New: - Errors reloading resources from jars: possible JDK bug

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=3644>.
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=3644

           Summary: Errors reloading resources from jars: possible JDK bug
           Product: Tomcat 3
           Version: 3.3 Beta 2
          Platform: PC
               URL: N/A
        OS/Version: Linux
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Unknown
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: bojan@binarix.com


The problem occurs when whole or parts of an application are distributed in a
jar file and reload feature of Tomcat is turned on. If jar file is updated,
either of the following might occur:

- resources from within jar cannot be read
- class itself cannot be found within jar (comes back to first the first)

To replicate the problem with class loading do this:

- create a servlet and pack it into WEB-INF/lib/app.jar
- keep making changes to the servlet, pack it and put into WEB-INF/lib
- attempt to use the servlet

To replicate the problem with resource loading do this:

- in your servlet call:

  ServletClassName.class.getResourceAsStream(<file-packed-in-jar>);

  or:

  this.getClass().getClassLoader().getResourceAsStream(<file-packed-in-jar>);

- change the contents of the jar file and distribute into WEB-INF/lib
- use the servlet

The 'amount of change' to the jar file seems to make a difference. Small changes
are less likely to cause errors. If the resource you're attempting to fetch is
packed in the same jar with the servlet that fetches it, you might get
intermittent resource loading problems or ClassNotFoundException thrown by
DependClassLoader (which indicates that class itself could not be loaded).

ClassNotFoundException happens due to the IOException being thrown by reading
from ZipFile$1 (this is an InputStream), in method readFully() of
DependClassLoader. This indicates that it is ZipFile of JDK that is probably
broken and cannot read an updated jar file.

The workaround is to use straight classes and files in WEB-INF/classes
directory.