Hi, I'm having a little class loading difficulty, and after spending quite a few hours playing with it and searching for a solution online I figured I should go ahead and ask if anyone can point out a solution to me.
Background: I'm developing on Tomcat 5.517 using JDK1.5. The operating system is Windows XP SP2. I'm writing a bit of code that bootstraps the JDT compiler that's included with Tomcat 5.5.17 and uses it to compile a source file that's generated at runtime. After a little tweaking, I finally got that to all work fine: when tomcat starts, it reads through a specified source folder, reads in each source file, compiles each source file, and if the compilation succeeds it reads a bunch of doclet tags from the source file and then generates wrapper source code which is THEN compiled and added to the class path (I could do byte code generation, but I kind of like source code: somewhat less opaque and since I already know it its easier than figuring out the byte code generators: the entire exercise took about 5 hours). In a sense, its sort of like JSPs except the source that gets compiled is not a blend of HTML and scriptlets, its straight Java, and I used doclet tags to dynamically generate the wrapper source. I'm doing all this using a custom class loader that wraps the webapp class loader: that way I can simply discard the class loader and use a completely different one when I reload the webapp. Structurally I have a set of source files that get compiled and placed in WEB-INF\lib, and a set of source files that get compiled at runtime. However, when I try and do a webapp stop/source compile/webapp start I start encountering difficulty. When I use the manager application to stop the webapp context, it stops (like it should). However even after I've stopped the webapp Tomcat still holds an open file handle to the generated library files (in WEB-INF\lib). After I run a stop and view all the open handles tomcat STILL has handles open to all the jar files in the WEB-INF\lib. When I then try and recompile ant complains that it can't delete the project's generated library file. I've enabled antiJARLocking and antiResourceLocking in the webapps Context element in server.xml, but still no love. When I then restart the application I get a "FileNotFoundException" when I try and read a file out of the generated jar file. I'd be grateful if anyone has any tips I can use to get around this. Thanks, Femi.