1

Update
I have seen those "duplicate" answers and accepted one too. I tried those ways but it didn't help me with my issue.

So, to resolve this, I have used an external resource path which points to my .jrxm (.jasper for subreports) files. Now it is resolved.

This question is not a duplicate of Jasper: error opening input stream from url and Warning while Running report: Found two components for namespace.

In my jasper report, there are several subreports which will conditionally be printed.

When I run the project locally, I can download and view the report with no error. But when running on a remote server as a .war file, it gives this error:

Warning:

Found two components for namespace http://jasperreports.sourceforge.net/jasperreports/components

Error:

Caused by: net.sf.jasperreports.engine.JRException: Error opening input stream from URL : file:/opt/tigerhrm/tigerhrm-client/target/tigerhrmclient-beta-1.3.0.war!/WEB-INF/classes!/report-templates/employee-details/empWiseContactReport.jasper
        at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:348)
        at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:132)
        ... 80 more
Caused by: java.io.FileNotFoundException: /opt/tigerhrm/tigerhrm-client/target/tigerhrmclient-beta-1.3.0.war!/WEB-INF/classes!/report-templates/employee-details/empWiseContactReport.jasper (No such file or directory)
        at java.io.FileInputStream.open0(Native Method)

I am setting the file path like this from the controller:

 String jasperResourcePath = request.getServletContext().getRealPath("/WEB-INF/");
 InputStream reportInputStream = getClass().getClassLoader().getResourceAsStream("report-templates/attendance.jrxml");

//note that, all the subreportes are linked as jasper directly from master report i.e <subreportExpression><![CDATA[$P{reportLocation} + "empWiseContactReport.jasper"]]></subreportExpression>

Project Structure:

Project Structure

In my .war file, I have checked the jasper file path using a java-decompiler like this:

path in war file:

So, although the path is shown correctly in the .war file, why does it give this error? Any suggestions would be welcome.

jkdev
  • 11,360
  • 15
  • 54
  • 77
user404
  • 1,934
  • 1
  • 16
  • 32

0 Answers0