Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF2 on Jetty gives randomly 'zip file closed' but works when running from maven jetty plugin (jetty:run)

Tags:

jsf-2

jetty

my JSF web app is giving randomly error: "zip file closed" when accessing files (like images, css, js). It is deployed on Jetty 7. It looks like some of those files are not loaded (some images are missing on a 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 run it from maven plugin (7.x) with jetty:run or jetty:run-war then I do not get any error. What's more, accessing root path of web context gives that "zip file closed" error only when running on standalone jetty, but no such error when running from maven pluging, then is those 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 could it be?

like image 894
szymex Avatar asked Feb 23 '23 18:02

szymex


1 Answers

This issue has been fixed in jetty-7.6.0.RC2. The bug is caused by the JVM caching jar url connection streams.

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

 <Set class="org.eclipse.jetty.util.resource.Resource" name="defaultUseCaches">false</Set>
like image 107
kldavis4 Avatar answered Feb 25 '23 06:02

kldavis4