Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364936 - Occasional "zip file closed" error, when extract=false is used for webapp
Summary: Occasional "zip file closed" error, when extract=false is used for webapp
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: 7.5.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 7.5.x   Edit
Assignee: Jan Bartel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-28 06:09 EST by vgarnashevich CLA
Modified: 2011-12-08 17:21 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vgarnashevich CLA 2011-11-28 06:09:29 EST
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
Comment 1 Jan Bartel CLA 2011-11-28 22:11:07 EST
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
Comment 2 vgarnashevich CLA 2011-11-29 06:42:08 EST
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.
Comment 3 Jan Bartel CLA 2011-12-07 19:34:18 EST
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
Comment 4 vgarnashevich CLA 2011-12-08 06:11:25 EST
I've tried to set defaultUseCaches=false, and it helped.
Comment 5 Jan Bartel CLA 2011-12-08 17:21:28 EST
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