I am using iReport tool in conjunction with JasperReports 1.3.4.
I have a master report, which contain two subreports. One of these subreports has an embedded subrep
I had the same issue and setting the SUBREPORT_DIR to the full package name containing my reports worked.
For example:
"com/mycomp/myapp/reports/"
Our set ups are similar in that you have all reports in the same directory. The difference is I am running my app from the desktop (Java SE). However, my reports were located in a jar file. When I tried to set teh SUBREPORT_DIR to c:\path\to\app\myapp.jar!\com\mycomp\myapp\reports Jasper failed to locate the file.
Hope this helps.
As Marcio already explained, your SUBREPORT_DIR
parameter has to be passed from the calling report to the subreport.
Using relative path with .
or ./
is not reliable, an absolute path is always to prefer.
So you have to write in your jrxml file:
<subreport isUsingCache="false">
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "mySubreport.jasper"]]></subreportExpression>
</subreport>
You have to pass the subreportParameterExpression
with the $P{SUBREPORT_DIR}
, elswise it won't pass the parameters (only setting <subreportParameter name="SUBREPORT_DIR"/>
is not enough).
Click in Subreport1
, go to the properties tab -> Subreport properties -> Parameters
You will pass your 'MasterReport' SUBREPORT_DIR
parameter as a parameter to 'Subreport1'.
Create this entry:
Name: SUBREPORT_DIR
Expression: $P{SUBREPORT_DIR}
Don't forget to recompile your reports and make sure to republish your web app in the application server.
just set $P{SUBREPORT_DIR}
as prompt and pass your value(the path to the directory may not be
valid like c:\something.jasper
instead of c:\\something.jasper
)