Bug 57626

Summary: IllegalStateException: zip file closed
Product: Tomcat 8 Reporter: Kenny Moens <kenny.moens>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: major CC: kenny.moens, vmahajan
Priority: P2    
Version: 8.0.18   
Target Milestone: ----   
Hardware: PC   
OS: Linux   

Description Kenny Moens 2015-02-24 07:08:03 UTC
Our webapp was working fine with Tomcat 8.0.14, we recently did an upgrade to 8.0.18 and since then we are experiencing an exception during the compilation of the JSP pages.

The exception is effectively an IllegalStateException, with message zip file is closed.

We did some debugging in the Tomcat source code and found out that the probable cause of this issue is the fix applied to ensure that all JARs files gets properly closed to prevent resource leaks (SVN revision 1641056).

More concretely in JspCompilationContext, the method getLastModified() will use an already closed instance of the tagJar. This occurs when the JSP file gets recompiled, and thus not upon first compilation.

The full exception is:

java.lang.IllegalStateException: zip file closed 
        java.util.zip.ZipFile.ensureOpen(ZipFile.java:670) 
        java.util.zip.ZipFile.getEntry(ZipFile.java:310) 
        java.util.jar.JarFile.getEntry(JarFile.java:240) 
        org.apache.tomcat.util.scan.JarFileUrlJar.getLastModified(JarFileUrlJar.java:87) 
        org.apache.jasper.JspCompilationContext.getLastModified(JspCompilationContext.java:358) 
        org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:434) 
        org.apache.jasper.compiler.Compiler.isOutDated(Compiler.java:408) 
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) 
        org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:239) 
        org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:580) 
        org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:50) 
        org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:662) 
        org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536) 
        org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) 
        org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) 
        org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434) 
        org.apache.jasper.compiler.Node$Root.accept(Node.java:464) 
        org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) 
        org.apache.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:680) 
        org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:229) 
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:356) 
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:336) 
        org.apache.jasper.compiler.Compiler.compile(Compiler.java:323) 
        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:570) 
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356) 
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) 
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) 
        javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
        org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1078) 
        org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:295) 
        org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:271) 
        org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:332) 
        org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:232) 
        org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) 
        org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) 
        javax.servlet.http.HttpServlet.service(HttpServlet.java:618) 
        javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
        org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
        be.cipal.setup.SetupFilter.doFilter(SetupFilter.java:60) 
        be.cipal.web.struts.tiles.AppModeFilter.doFilter(AppModeFilter.java:45) 
        be.cipal.filter.UTF8Filter.doFilter(UTF8Filter.java:44)
Comment 1 Mark Thomas 2015-02-25 11:27:27 UTC
Thanks for the report. This has been fixed in trunk and 8.0.x for 8.0.21 onwards.
Comment 2 Rafael Mattos 2015-05-04 18:33:28 UTC
Was this solved? I'm still having this issue on Tomcat 8.0.21
Comment 3 Mark Thomas 2015-05-04 19:41:22 UTC
Which part of "This has been fixed in trunk and 8.0.x for 8.0.21 onwards." is not clear?

If you are seeing a similar issue then open a new bug report and provide the steps to reproduce it.