Hmm, I don't know. Looking at the code in MyFaces I found out that MyFaces uses Resource.getURL() to get the file from the jar archive. Then it uses URL.openConnection() (or openStream()) to access the resource. Maybe jetty has a concurrency issue here, I don't know, but it really looks that way.
Maybe you can have a look at the code in jetty and get some clearance about what happens! Regards, Jakob 2011/10/27 <gregor.jari...@raibau.at>: > Hi Jakob, > > thank you for your answer. I agree to your explanation. Although I believe > Jetty does work as expected. It allows concurrent exceptions, the only thing > it is missing is the fact that it returns input streams also when they are > closed. > I would assume that it would be more suitable if jetty would check if the > connection is still open, otherwise open a new one and return that. > > Nevertheless, as stated previously I have tried out the Jetty patch. What > wonders me the most is that the stream still gets closed (probably by > xerces). This shouldn't be possible anymore, since in this solution the > close method has been overridden in order to do nothing. So regardless of > who is trying to close it, it simply should not get closed! > > By now I have another clue what it might could be. Since the patch does not > allow closing the input stream, this input stream which is closed might not > even pass this lines of code. Maybe those resources come from some other > place. > After some research I came across the following statement: > > "There are two places that the application can deliver an input source to > the parser: as the argument to the Parser.parse method, or as the return > value of the *EntityResolver.resolveEntity* method." -- > http://download.oracle.com/javase/6/docs/api/org/xml/sax/InputSource.html > > I am wondering if xerces gets the resource from > EntityResolver.resolveEntity. This would explain a lot. > So far I have found 3 implementations: > * org.apache.xerces.util.DOMEntityResolverWrapper > * org.apache.xerces.util.EntityResolverWrapper > * org.apache.xerces.util.EntityResolver2Wrapper > > I am not sure yet which of those is involved here. > > Any comments, ideas, statements to this? > > Thanks. > > Gregor JARISCH > Basis und Spezialdienste > > Raiffeisen Bausparkasse Gesellschaft m.b.H. > 1050 Wien, Wiedner Hauptstraße 94 > Tel.: +43 (1) 546 46-1619, Fax: DW 2360 > E-Mail: gregor.jari...@raibau.at > www.bausparen.at > FN 116309v, Handelsgericht Wien > > ------------------------------------------------- > > Jetzt Jugend Bausparen und Bausparbox holen! > Alle Infos auf www.bausparen.at > > > > > Von: Jakob Korherr <jakob.korh...@gmail.com> > An: MyFaces Development <dev@myfaces.apache.org> > Datum: 26.10.2011 12:59 > Betreff: Re: java.lang.IllegalStateException: zip file closed > Gesendet von: sethfromaust...@gmail.com > > ________________________________ > > > Hi Gregor, > > This issue seems to be a race condition resulting of the combination > of xerces closing every InputStream it gets and Jetty failing to > handle this. > > In the stacktrace you can see that there is a call to > ServletContext.getResource() via ExternalContext. Also you can see > that it currently tries to load an xhtml file of a composite > component. > > IMO the problem is the following: the 1st thread runs through the > above stacktrace, Jetty opens the jar file in which the xhtml file is > located and returns the URL. Then the second thread does the same. At > the same time the 2nd thread does this, the first thread processes the > xhtml file by getting the InputStream and handing it over to xerxes > for parsing it (in order to create the component tree for the > composite component). Unfortunately, xerxes closes this InputStream > when it is done. However, the 2nd thread is still reading the same jar > file (internally via the same JarInputStream), which unfortunately has > been closed. Thus the exception from the JDK class. > > I think that this is a result of poor concurrent jar file handling of > jetty. I don't know what the servlet spec states here exactly, but I > am pretty sure that multiple concurrent connections to the same jar > file should be possible. > > Regards, > Jakob > > 2011/10/25 Michael Kurz <michi.k...@gmx.at>: >> Hi, >> have you already tried it on another servlet container like tomcat? >> I guess the key for finding out what happens is the other thread that does >> not fail. The first thing I would try to find out is where the >> JarFileResource (or the underlying file) is closed. >> Have you checked that the resource in question is really loaded with the >> code that was changed with the Jetty patch? >> regards >> Michael >> >> Am 25.10.2011 um 14:47 schrieb gregor.jari...@raibau.at: >> >> Hello, >> >> we are developing internal software based on myfaces (2.0.2) and jetty >> (7.1.6). We ran into the following problem: >> After the start of the server, if two requests (threads) are send at the >> same time, jetty reports an "IllegalStateException: zip file closed". >> To me it seems that one request is closing the stream when it has finished >> using it, so for the second request it has already been closed when it >> trys >> to attempt using it. >> >> After some research we had a very promising solution suggestion: >> http://jira.codehaus.org/browse/JETTY-254 >> http://jira.codehaus.org/secure/attachment/26212/JETTY-254-2.patch >> >> We did patch it, but the behaviour did not change at all. It also doesn't >> work with the current jetty (in which the patch is also included). >> >> Following is our stacetrace; It is very similar to the problem described >> in >> the jira issue above. Still, it seems to be something else. >> I am glad for any suggestions. >> >> Thanks in advance. >> >> java.lang.IllegalStateException: zip file closed >> at java.util.zip.ZipFile.ensureOpen(ZipFile.java:403) >> ~[na:1.6.0_17] >> at java.util.zip.ZipFile.access$100(ZipFile.java:29) >> ~[na:1.6.0_17] >> at java.util.zip.ZipFile$2.nextElement(ZipFile.java:309) >> ~[na:1.6.0_17] >> at java.util.zip.ZipFile$2.nextElement(ZipFile.java:299) >> ~[na:1.6.0_17] >> at java.util.jar.JarFile$1.nextElement(JarFile.java:223) >> ~[na:1.6.0_17] >> at java.util.jar.JarFile$1.nextElement(JarFile.java:218) >> ~[na:1.6.0_17] >> at >> >> org.eclipse.jetty.util.resource.JarFileResource.exists(JarFileResource.java:163) >> ~[org.eclipse.jetty.util_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> org.eclipse.jetty.webapp.WebAppContext.getResource(WebAppContext.java:290) >> ~[org.eclipse.jetty.webapp_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.webapp.WebAppContext$Context.getResource(WebAppContext.java:1003) >> ~[org.eclipse.jetty.webapp_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.apache.myfaces.context.servlet.ServletExternalContextImplBase.getResource(ServletExternalContextImplBase.java:121) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.shared_impl.resource.ExternalContextResourceLoader.getResourceURL(ExternalContextResourceLoader.java:144) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.application.ResourceHandlerImpl.deriveResourceMeta(ResourceHandlerImpl.java:228) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.application.ResourceHandlerImpl.createResource(ResourceHandlerImpl.java:104) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> javax.faces.application.ResourceHandlerWrapper.createResource(ResourceHandlerWrapper.java:50) >> ~[myfaces-api-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.custom.captcha.CAPTCHAResourceHandlerWrapper.createResource(CAPTCHAResourceHandlerWrapper.java:82) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> org.apache.myfaces.tomahawk.resource.UncompressedResourceHandlerWrapper.createResource(UncompressedResourceHandlerWrapper.java:107) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> javax.faces.application.ResourceHandlerWrapper.createResource(ResourceHandlerWrapper.java:50) >> ~[myfaces-api-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.custom.captcha.CAPTCHAResourceHandlerWrapper.createResource(CAPTCHAResourceHandlerWrapper.java:82) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> org.apache.myfaces.tomahawk.resource.UncompressedResourceHandlerWrapper.createResource(UncompressedResourceHandlerWrapper.java:107) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> org.apache.myfaces.tomahawk.resource.UncompressedResourceHandlerWrapper.createResource(UncompressedResourceHandlerWrapper.java:61) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> org.apache.myfaces.view.facelets.compiler.TagLibraryConfig$TagLibraryImpl.containsTagHandler(TagLibraryConfig.java:97) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.tag.CompositeTagLibrary.containsTagHandler(CompositeTagLibrary.java:73) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:270) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:227) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at >> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at >> >> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at >> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) >> ~[xercesImpl-2.9.0.jar:na] >> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown >> Source) >> ~[xercesImpl-2.9.0.jar:na] >> at >> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown >> Source) ~[xercesImpl-2.9.0.jar:na] >> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) >> ~[xercesImpl-2.9.0.jar:na] >> at javax.xml.parsers.SAXParser.parse(SAXParser.java:198) >> ~[na:1.6.0_17] >> at >> >> org.apache.myfaces.view.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:675) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.compiler.Compiler.compile(Compiler.java:118) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createFacelet(DefaultFaceletFactory.java:280) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:162) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:137) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage._getFacelet(FaceletViewDeclarationLanguage.java:1888) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:311) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> >> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:66) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at >> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239) >> ~[myfaces-impl-2.0.2.jar:2.0.2] >> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191) >> ~[myfaces-api-2.0.2.jar:2.0.2] >> at >> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:527) >> ~[org.eclipse.jetty.servlet_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216) >> ~[org.eclipse.jetty.servlet_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:286) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187) >> ~[org.eclipse.jetty.servlet_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349) >> ~[tomahawk20-1.1.10.jar:1.1.10] >> at >> >> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187) >> ~[org.eclipse.jetty.servlet_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:421) >> [org.eclipse.jetty.servlet_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:456) >> [org.eclipse.jetty.security_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:930) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358) >> [org.eclipse.jetty.servlet_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:866) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at org.eclipse.jetty.server.Server.handle(Server.java:351) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1059) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:764) >> [org.eclipse.jetty.http_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217) >> [org.eclipse.jetty.http_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424) >> [org.eclipse.jetty.server_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506) >> [org.eclipse.jetty.io_7.1.6.v20100715.jar:7.1.6.v20100715] >> at >> >> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436) >> [org.eclipse.jetty.util_7.1.6.v20100715.jar:7.1.6.v20100715] >> at java.lang.Thread.run(Thread.java:619) [na:1.6.0_17] >> >> Gregor JARISCH >> Basis und Spezialdienste >> >> Raiffeisen Bausparkasse Gesellschaft m.b.H. >> 1050 Wien, Wiedner Hauptstraße 94 >> Tel.: +43 (1) 546 46-1619, Fax: DW 2360 >> E-Mail: gregor.jari...@raibau.at >> www.bausparen.at >> FN 116309v, Handelsgericht Wien >> >> ------------------------------------------------- >> >> Zuverlässigkeit seit 50 Jahren - Raiffeisen Bausparen >> Alle Infos auf https://www.bausparen.at/ >> >> <mime-attachment.jpg> >> >> ______________________________________ >> Raiffeisen Bausparkasse Gesellschaft m.b.H., 1050 Wien, Wiedner >> Hauptstraße >> 94, Firmenbuchnummer 116309v, Handelsgericht Wien, DVR 0066257, UID >> ATU15350206 >> >> Diese E-Mail kann vertrauliche und geschuetzte Informationen enthalten. >> Wenn >> diese E-Mail nicht für Sie bestimmt ist, bitten wir Sie, uns unverzueglich >> zu informieren und sie zu loeschen. >> >> This e-mail message may contain information, which is confidential and >> protected. If you are not the intended recipient of this message, we ask >> you >> to inform us immediately and delete the message afterwards. >> >> > > > > -- > Jakob Korherr > > blog: http://www.jakobk.com > twitter: http://twitter.com/jakobkorherr > work: http://www.irian.at > > > ______________________________________ > Raiffeisen Bausparkasse Gesellschaft m.b.H., 1050 Wien, Wiedner Hauptstraße > 94, Firmenbuchnummer 116309v, Handelsgericht Wien, DVR 0066257, UID > ATU15350206 > > Diese E-Mail kann vertrauliche und geschuetzte Informationen enthalten. Wenn > diese E-Mail nicht für Sie bestimmt ist, bitten wir Sie, uns unverzueglich > zu informieren und sie zu loeschen. > > This e-mail message may contain information, which is confidential and > protected. If you are not the intended recipient of this message, we ask you > to inform us immediately and delete the message afterwards. > > -- Jakob Korherr blog: http://www.jakobk.com twitter: http://twitter.com/jakobkorherr work: http://www.irian.at