Jasper sub reports are not being updated on tomcat

I have a jasper report (crfTemplate.jrxml) with a sub-report (crfCover.jrxml) and when I make a change in the sub-report and deploy the new war in tomcat the change does not appear in the file (it always get the older sup-report). But when I change the main report (it is my code that gets the main report) the change appears in the file.

The jasper reports are in a jar on the war file. And in order the sub-report to be update I need to restart the tomcat. And this only happens when the tomcat unpackWAR is set to true.

My question is why this is happening (Jasper report have some kind of cache?) and what I have to do to not have to restart the tomcat all the time besides to change the option unpackWAR to false?

The jasper-report version that I am using is 5.6.0 and the tomcat is 6.

In my Java code I have this:

String fileName = filePath + "/name" + SystemDate.getDate().getTime();       Map<String, Object> parameters = setUpParameters(trial.getId(), patientCRFData.getStage(), trial, crf, options);       InputStream io = this.getClass().getResourceAsStream("/crfTemplate.jasper");       JasperReport jasperReport = (JasperReport) JRLoader.loadObject(io);   JRDataSource ds = new JRBeanCollectionDataSource(patientCRFs);   JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, ds);         JasperExportManager.exportReportToPdfFile(jasperPrint, fileName);       InputStream template = new DataInputStream(new FileInputStream(filePath));

And in the crfTemplate.jrxml I have this:

 <detail>                                                                                                                                  <band height="700">                                                                                                                       <subreport isUsingCache="false">                                                                                                          <reportElement x="0" y="0" width="555" height="100" uuid="13e1c2e2-4f44-4441-9890-7f9008b82955"/>                                     <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{PATIENT_INFORMATION})]]></dataSourceExpression>                                                                                                                           <subreportExpression><![CDATA["crfCoverPage.jasper"]]></subreportExpression>                                                       </subreport>                                                                                                                     </band>                                                                                                                           </detail>
semog1epilif's picture
Joined: Jul 14 2014 - 6:43am
Last seen: 8 years 8 months ago

I do not think that this is related to JR but on some kind of caching or persistence in your web app. Without looking at your code or how your web app is implementing the JR calls for the report and subreport is dificult to troubleshoot.

Have you tried cleaning the work directory and temp instead of restarting tomcat? If that works that will give you the indication that tomcat is the one caching the call to the subrep..

marianol - 8 years 8 months ago

I posted my code in the question. I had already tried to clean my work directory without success, I didn't try to clean the temp directory. I will try that. 

Thanks for the reply

semog1epilif - 8 years 8 months ago
When I change the crfCover.jrxml name to something else it gives the following error but the file is in the jar (if again I restart the tomcat the error disappears):
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error opening input stream from URL : jar:file:/usr/share/tomcat6/webapps/edc/WEB-INF/lib/cm-persistence-3.1.0-SNAPSHOT.jar!/crfCoverPage2.jasper
at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:117)
at net.sf.jasperreports.repo.InputStreamPersistenceService.load(InputStreamPersistenceService.java:48)
Caused by: net.sf.jasperreports.engine.JRException: Error opening input stream from URL : jar:file:/usr/share/tomcat6/webapps/edc/WEB-INF/lib/cm-persistence-3.1.0-SNAPSHOT.jar!/crfCoverPage2.jasper
at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:302)
at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:112)
... 112 more
Caused by: java.io.FileNotFoundException: JAR entry crfCoverPage2.jasper not found in /usr/share/tomcat6/webapps/edc/WEB-INF/lib/cm-persistence-3.1.0-SNAPSHOT.jar
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:132)
at java.net.URL.openStream(URL.java:1010)
at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:298)
semog1epilif - 8 years 8 months ago

0 Answers:

No answers yet