[#4336] - URL connection to jar will lock the jasperreports.jar in web application

Category:
Bug report
Priority:
Normal
Status:
Acknowledged
Project: Severity:
Minor
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

After we moved from version 3.1.0 to 3.5.3 or 3.6.0 we have been unable to undeploy web application on Tomcat when running on Windows and SUN JVM.

Apparently now in jasperreports you are reading property file:
jasperreports_extension.properties using URL.openStream();
And the file is included in distribution.

This leads to locking the jasperreports.jar and file can't be remove.

Apparently this is known SUN Java bug.

This is a simple change I can suggest to solve the problem
---
// JRPropertiesMap.java Line 370
//stream = location.openStream();
java.net.URLConnection connection = location.openConnection();
if (connection instanceof java.net.JarURLConnection) {
((java.net.JarURLConnection) connection).setUseCaches(false);
}
stream = connection.getInputStream();
---

See the file JRPropertiesMap.java I tested in my app to fix the problem.

AttachmentSize
File JRPropertiesMap.java11.25 KB
vlads's picture
4
Joined: Nov 6 2006 - 5:29am
Last seen: 15 years 6 months ago

1 Comment:

#1

FYI: I found the same behaviour during development of a small servlet interface to JasperReports (using a FileInputStream object for the report, a JRXmlDataSource object connected to a url for the data and JasperRunManager to run the report). Once I deployed the servlet to Tomcat and a report was run using the servlet, I was unable to undeploy correctly (file in use). Each time I try to undeploy + redeploy my servlet, I need to stop Tomcat, delete the servlet folder and restart Tomcat. You have also my vote for fixing this!

Feedback
randomness