Community
Participate
Working Groups
Build Identifier: 7.5.4.v20111024 If I configure web application with extract=false option, Jetty sometimes fails to serve resources. This seem to happen with random resources at random times. 25 Nov 2011 18:13:19,031 WARN org.eclipse.jetty.servlet.ServletHandler - /resources/css/gxt-all.css java.lang.IllegalStateException: zip file closed at java.util.zip.ZipFile.ensureOpen(Unknown Source) at java.util.zip.ZipFile.access$100(Unknown Source) at java.util.zip.ZipFile$2.hasMoreElements(Unknown Source) at java.util.jar.JarFile$1.hasMoreElements(Unknown Source) at org.eclipse.jetty.util.resource.JarFileResource.exists(JarFileResource.java:163) at org.eclipse.jetty.webapp.WebAppContext.getResource(WebAppContext.java:321) at org.eclipse.jetty.webapp.WebAppContext$Context.getResource(WebAppContext.java:1222) at org.eclipse.jetty.servlet.DefaultServlet.getResource(DefaultServlet.java:366) at org.eclipse.jetty.server.ResourceCache.lookup(ResourceCache.java:188) at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:445) at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547) ... Reproducible: Sometimes
Have a read of this troubleshooting wiki page: http://docs.codehaus.org/display/JETTY/ZIP+exception+reading+jar+or+war+files Does that cover your situation? Jan
The exception can happen right after application start, on first page refresh. The JAR file with the webapp is not being updated. The resources, on which the exception occurs, are not packed inside additional JARs, within the webapp's JAR. The webapp is deployed as an OSGi application, and OSGiAppProvider is configured with parameter extract=false.
In your osgi setup, do you have a jetty.xml file anywhere? Or one called jetty-osgi-default.xml? If so, can you add near the top of that file, the following line: <Set class="org.eclipse.jetty.util.resource.Resource" name="defaultUseCaches">false</Set> That should ensure that jetty tells the jvm not to cache jar url connection streams, which is the cause of that bug. There may, however, be 1 or 2 places in relatively newish code that opens a jar url connection directly and thus won't use this workaround - I'll have a trawl through the code and see if I can find any, but it would be good if you could try the above in the meanwhile. thanks Jan
I've tried to set defaultUseCaches=false, and it helped.
Good. Although your problem is fixed with the Resource.setDefaultUseCaches, I am marking this bug as "fixed", as I've also modified the code in a few places that was doing direct Url.openStream. Jan