JSF2 on Jetty gives a random "zip file closed", but it works when starting from the maven plugin berth (berth: run)

my JSF web application gives a random error: "zip file closed" when accessing files (for example, images, css, js). It deploys on Jetty 7. It appears that some of these files are not loaded (some images are missing from the page).

java.lang.IllegalStateException: zip file closed at java.util.zip.ZipFile.ensureOpen(ZipFile.java:403) at java.util.zip.ZipFile.entries(ZipFile.java:298) at java.util.jar.JarFile.entries(JarFile.java:217) at org.eclipse.jetty.util.resource.JarFileResource.list(JarFileResource.java:261) at org.eclipse.jetty.util.resource.ResourceCollection.list(ResourceCollection.java:421) at org.eclipse.jetty.util.resource.Resource.getListHTML(Resource.java:509) at org.eclipse.jetty.servlet.DefaultServlet.sendDirectory(DefaultServlet.java:741) at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:564) 

When I launch it from the maven (7.x) plugin with the berth: run or jetty: run-war, then I get no errors. Moreover, access to the root path of the web context gives the error "zip file is closed" only when starting on a stand-alone pier, but such an error when starting from maven will connect, and then this is a directory view.

My web.xml:

  <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> 

pom.xml:

  .... <dependencies> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1.3</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.1.3</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> </dependencies> .... <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>7.5.1.v20110908</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> </configuration> <dependencies> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1.3</version> </dependency> <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-impl</artifactId> <version>2.1.3</version> </dependency> </dependencies> </plugin> 

Any idea what this could be?

+4
source share
3 answers

Jetty looks for your resources in jar files in WEB-INF / lib. When it searches for jsf-impl.jar, it is somehow closed, possibly with a JSF request. Maybe jsf processes and processes its own files with the files themselves.

Anyway, the solution seems to be to move jsf banks from the war file. Define your jsf dependency region so that maven does not pack them into a war file and run them on the server, possibly in the lib folder in stand-alone offline mode.

+1
source

This issue has been fixed in jetty-7.6.0.RC2. The error is caused by connection threads to the JVM caching jar channel.

According to the bug report, you also need to add the following to jetty.xml:

  <Set class="org.eclipse.jetty.util.resource.Resource" name="defaultUseCaches">false</Set> 
+6
source

I had the same problem and managed to solve it by going to etc\webdefault.xml and changing this parameter to false :

 <init-param> <param-name>gzip</param-name> <param-value>true</param-value> </init-param> 
+1
source

All Articles