1. Set up an application with an Ant script to compile JSPs as recommended at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html 2. Write a JSP which contains erroneous text such that the first phase (JSP -> Java translation) fails e.g. by including <jsp:include x="50"/> in the page. 3. Compile the application using the Ant script - a Jasper exception will be reported. 4. Compile the application again - build will succeed despite the error.
Fixed by removing empty .java file (that was generated by "new FileOutputStream()") if parser/validator/generator throws exception.
I must say this still does not work for me in Tomcat 5.0.24. I am attaching an application which reproduces this issue. To reproduce: 1. Unzip the attached testApp.zip 2. Modify the build.properties file from testApp.zip to point to a Tomcat 5.0.24 installation 3. In the root directory of this test application, run Ant twice (I am using Ant 1.6.1). The first time you run Ant, a compilation error is reported, but the second time it is not and build succeeds. Thanks for looking at this.
Created attachment 11444 [details] The test application which reproduces this issue.
Hmm, this works for me (on UNIX). Do you see an empty JSP_jsp.java file being generated in your project's "build" directory? Such a file used to be generated, but my fix should have deleted it (using File.delete()).
Ok, I'll look at this over the weekend and debug it on my side.
I found out where the problem is: When the file is deleted, the outputstream that writes this file is still open, so the delete operation fails on Windows. The stream is closed too late. I will attach a patch that fixes this on my machine.
Created attachment 11489 [details] Patch that works for me.
Created attachment 11499 [details] Set 'writer' to NULL, so it won't be closed again in finally
Thanks for investigating, Petr! I've applied your patch, which I slightly modified by setting 'writer' to NULL after closing it in the exception handling code you added, so that it won't be closed again in the finally. Modified patch attached.
Thanks!