[kaffe] Running Tomcat 5.0

Guilhem Lavaux guilhem at kaffe.org
Sat Apr 9 10:48:27 PDT 2005


Hi,

No need to file the bug. I have done it myself.

Regards,

Guilhem.

On Sun, 2005-04-10 at 01:27 +0900, Rei Odaira wrote:
> Fernando Lozano wrote:
> > Having read many reports on the archieve of success running Tomcat under 
> > Kaffe, I decided to try myself using Tomcat 5.0.28. Although many JSP 
> > pages and Servlets do run ok (icluding the Tomcat Manager and most 
> > samples) many applications, including some examples and the Tomcat 
> > Administrator fail with the following exception
> > 
> > java.lang.IllegalStateException: Zip file already closed: 
> > /d/local/jakarta-tomcat-5.0.28/common/lib/commons-pool-1.2.jar
> > 
> > Any idea on how to workaround this, or should I fill a bug report? And 
> > the bug report should go to Kaffe or Jakarta?
> 
> I have just found the cause of the problem.
> 
> org.apache.jasper.compiler.TldLocationsCache#scanJar() opens
> commons-pool-1.2.jar, reads some entries, and finally closes it
> when redeployMode == true, as shown below.
> 
> ##################################################
>     private void scanJar(JarURLConnection conn, boolean ignore)
>                 throws JasperException {
> 
>         JarFile jarFile = null;
>         String resourcePath = conn.getJarFileURL().toString();
>         try {
>             if (redeployMode) {
>                 conn.setUseCaches(false);
>             }
>             jarFile = conn.getJarFile();
>             Enumeration entries = jarFile.entries();
> ...<snip>...
> 
>         } finally {
>             if (redeployMode) {
>                 // if in redeploy mode, always close the jar
>                 if (jarFile != null) {
>                     try {
>                         jarFile.close();
>                     } catch (Throwable t) {
>                         // ignore
>                     }
>                 }
>             }
>         }
>     }
> ##################################################
> 
> Since a JarURLConnection can internally cache JarFile objects,
> scanJar() first disables the caching by calling setUseCaches(false)
> when it wants to close the JarFile later.  However,
> gnu.java.net.protocol.jar.Connection, which extends JarURLConnection,
> does not check for the useCaches flag when it opens a connection.
> Therefore, the unintendedly cached JarFile object becomes stale
> after it gets closed by scanJar().  If Tomcat re-opens
> commons-pool-1.2.jar through JarURLConnection, it will get
> the already closed JarFile object.
> 
> The attached patch fixes this problem.
> 
> Rei
> Plain text document attachment (kaffe-jarconn.patch)
> Index: libraries/javalib/gnu/java/net/protocol/jar/Connection.java
> ===================================================================
> RCS file: /cvs/kaffe/kaffe/libraries/javalib/gnu/java/net/protocol/jar/Connection.java,v
> retrieving revision 1.8
> diff -a -u -r1.8 Connection.java
> --- libraries/javalib/gnu/java/net/protocol/jar/Connection.java	8 Mar 2005 21:03:53 -0000	1.8
> +++ libraries/javalib/gnu/java/net/protocol/jar/Connection.java	9 Apr 2005 15:22:59 -0000
> @@ -69,13 +69,18 @@
>      private static Hashtable cache = new Hashtable();
>      private static final int READBUFSIZE = 4*1024;
>      
> -    public static synchronized JarFile get (URL url) throws IOException
> +    public static synchronized JarFile get (URL url, boolean use_caches) throws IOException
>      {
> -      JarFile jf = (JarFile) cache.get (url);
> +      JarFile jf;
> +
> +      if (use_caches)
> +	{
> +	  jf = (JarFile) cache.get (url);
> +
> +	  if (jf != null)
> +	    return jf;
> +	}
>  
> -      if (jf != null)
> -        return jf;
> -      
>        if ("file".equals (url.getProtocol()))
>  	{
>  	  File f = new File (url.getFile());
> @@ -101,7 +106,8 @@
>  			    ZipFile.OPEN_READ | ZipFile.OPEN_DELETE);
>  	}
>            
> -      cache.put (url, jf);
> +      if (use_caches)
> +	cache.put (url, jf);
>        
>        return jf;
>      }
> @@ -120,7 +126,7 @@
>        return;
>  
>      jar_url = getJarFileURL();
> -    jar_file = JarFileCache.get (jar_url);
> +    jar_file = JarFileCache.get (jar_url, useCaches);
>      String entry_name = getEntryName();
>      
>      if (entry_name != null
> _______________________________________________
> kaffe mailing list
> kaffe at kaffe.org
> http://kaffe.org/cgi-bin/mailman/listinfo/kaffe





More information about the kaffe mailing list