Jasper SubReports

Hello

I have a problem with subreport.
I set properly the subreport on IReport like explained in http://www.mindfiresolutions.com/Adding … in-724.php and compile it from IReport.

I run report on developer and work.
In linux server doesn’t work. The error is: “Could not load object from location /home/reports…/subreport.jasper”. The path is surely correct.
Can you give me a suggestion?

I use servoy 5.2.15, and plugin version 3.2.0.

Thank you very much.
Roberto

Roberto, please refer to this wiki page if you have not already; also please try using the 3.3.0 version of the plugin.

Regards,
Andrei

Thank you for fast answer.
I will try with new plugin 3.3.0 this evening.
I read the wiki page but I cannot compiled the report in Ireport ( error during compiling ).

Bye
Roberto

Roberto, try a compatible (with the plugin) version of iReport; in this case use iReport 4.0.0.

Regards,
Andrei

Compiled with Ireport 4.0.0 and doesn’t work. :(

Plugin 3.3.0

Ensure that the path for the report file is RELATIVE to the reports folder specified in the admin page.

Hi Thomas

the path specified in admin page is /home/report/.
The report and subreport are in a subdirectorery ( /home/report/dir/. )
I set the dir of the main report with the command: plugins.jasperPluginRMI.relativeReportsDirectory = “/home/report/dir”.
The reports that have not a subreport works correctly.

Thanks for help
Roberto

Roberto, do you send the SUBREPORT_DIR parameter also to the run report call?

If I set the SUBREPORT_DIR parameter the report search the subreport in “report directory” + “report directory”.
Example: I have the report in /home/report/somedir and the subreport in the same folder, if I set the SUBREPORT_DIR parameter, the system search the subreport in /home/report/somedir/home/report/somedir.

I tried also with another parameter named “path_subdir” and set the parameter with the correct directory and the system search the subreport in /home/report/somedir but I have the same error :(

Roberto,

First, I think you are trying (as said in an above post) to set the relativeReportDirectory from scripting to an absolute path; you should (must!) set that in the admin page, not from scripting (thus trying to set from the client). This is a very important step. From what you are saying, if the report and subreport are in a subdirectory (/home/report/dir/), you have to said that relative to the admin page report directory setting, so like this: ```
plugins.jasperPluginRMI.relativeReportsDirectory = “/dir”.


Then, in your case, in which the subreport is in the same place with the report, you don't need to set the SUBREPORT_DIR as it's the same as your report location (sorry, i missed this info in your post to Thomas) and, under the hood, this will default to the report directory. If you do set the SUBREPORT_DIR, it has to be relative to the report directory specified in the admin page, or if you set it client-side from "plugins.jasperPluginRMI.relativeReportsDirectory", relative to that client side setting.

Also, you may not need the main report compiled, as you can use ```
runReport(..,"report.jrxml",...)
``` (as you said you have trouble compiling), but you need the subreport to be compiled, in order to have something like follows in the main report:

... ```

Please do not forget to use iReport 4.0.0 for compiling, with the 3.3.0 version of the plugin.

The above scenario should work. Please try !

Regards,
Andrei

Thank you Andrei for answer.

I set in admin page /home/report.

I set in code plugins.jasperPluginRMI.relativeReportsDirectory = “/dir”.

I have an exception: Could not load object from location : /dir/subreport.jasper

The reports without subreport are printed correctly.

I used ireport 4.0.0 and plugin 3.3.0

Any other idea?

Thank you

Regards
Roberto

The path is RELATIVE.
So if you omit the “dir/” in your file name of the report to the plugin it should go to the
“dir” folder and find your report file name.
If you retrieve the reports directory using the plugin property you should find it return an empty string and not “dir”. So the plugin is already looking at the contents of the dir.
Try retrieving all report names from the reports directory using the plugin property.
I recommend that you do not set the reports directory from code (I do not think the “set” works that way only the “get”). Instead specify to the plugin the path/filen ame of your report as “dir/<report.jasper>” or “dir/<report.jrxml>”.

Now I set the full path in admin page “/home/report/subdir/”.
So i didn’t set nothing in code.
I have the same exception, the subreport is not found. :(

Regards
Roberto

Could you please attach your report jrxml file?

Regards,
Andrei

In attachments the .rar file with the main report “avviso_arrivo_merce” and the 2 subreport “avviso_merce_singoli_sub” and “avviso_merce_cont_sub”.
Thank you Andrei

[attachment=0]report.rar[/attachment]

report.rar (37.4 KB)

Roberto, from what i see you are using a foundset based report and as you said, you work in a server/client scenario. In this case, as refered in the previously mentioned wiki page, please use the loadReport function in your subreportExpression tag, something like:

<subreport>
   ...
   <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[com.servoy.plugins.jasperreports.JasperReportsResourceLoader.loadReport($P{SUBREPORT_DIR} + "avviso_merce_cont_sub.jasper")]]></subreportExpression>
</subreport>

(do note that the subreportExpression class is not String here)

Hope this helps,
Andrei

Works!!

I’m so sorry for the time that you spent for me, I didn’t understand that with subreports is necessary to compile the report with the plugin and not with Ireport.

Thank you for help!

Regards

Roberto

Roberto, glad things work now.

But, if you use a corresponding version of iReport, compiling with iReport should work also.
Anyway, was it a compilation problem in the end or was the solution to use JasperReportsResourceLoader.loadReport?

Regards,
Andrei

I tried already with the “loader” solution.
But I could to compile with Ireport because I have an error “com.servoy.plugins.jasperreports,JasperReportsResourcesLoader cannot be resolved to a type”.

I need to compile the report with the plugin. and now work!

Regards
Roberto

robysimo09:
I tried already with the “loader” solution.
But I could to compile with Ireport because I have an error “com.servoy.plugins.jasperreports,JasperReportsResourcesLoader cannot be resolved to a type”.

I need to compile the report with the plugin. and now work!

Regards
Roberto

Ok, nice that it all worked out in the end.

An alternative approach would be to have just the subreport compiled (with iReport as you wanted initially) and use the jrxml file for the main report in the runReport call. That way you don’t need to compile the main report with the plugin.

Best regards,
Andrei