Actually, I looked at that and its a little odder than that. I use the
Eclipse compiler, and when its locating import dependencies it uses a chunk
of code like this to retrieve the bytes for a specific class:

InputStream is;
try{
 String resourceName = className.replace('.', '/') + ".class";
       URL u = classLoader.getResource(resourceName);
       if(u != null){
       is = u.openStream();
       byte[] classBytes;
       byte[] buf = new byte[8192];
       ByteArrayOutputStream baos = new ByteArrayOutputStream(buf.length);
       int count;
       while ((count = is.read(buf, 0, buf.length)) > 0) {
           baos.write(buf, 0, count);
       }
       baos.flush();
       byte[] classBytes = baos.toByteArray();
       char[] fileName = className.toCharArray();
       ClassFileReader classFileReader = new ClassFileReader(classBytes,
fileName, true);
       return new NameEnvironmentAnswer(classFileReader, null);
       }
   } finally {
       if (is != null) {
       try { is.close(); }catch (IOException exc) {}   // Ignore
       }
   }

This call works just fine when I start up Tomcat the first time. However
when I stop the webapp and attempt to recompile the jar file with the actual
class being loaded above within it I get an exception when Ant tries to
replace the file. Then when I restart the webapp, I get a
FileNotFoundException, even though I KNOW the jar file is present and I know
the class is within it. I've tried the System.gc() call, but still no love.

Anyone know some way of forcing Tomcat to let go of the reference to the
webapp class loader so I can GC it and have it let go of the handle to the
jar file? Alternatively, a cleaner way of fetching the class bytes without
opening a stream into the jar file?

Thanks,

Femi.

On 5/23/06, Peter Crowther <[EMAIL PROTECTED]> wrote:

> From: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED]
> interesting, are you saying that the handle is not closed
> when you call stream.close()?

There's some noise on this at:

http://forum.java.sun.com/thread.jspa?threadID=609458&messageID=3355532

Still haven't found the entry in the bug database though.  Sorry, Filip.

                - Peter

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to