Return value of plugins.jasperPluginRMI.runReport()

Hello,

I am having some difficulties with the return value of plugins.jasperPluginRMI.runReport(). As it is described in the documentation this should contain a byte array of the file created during runReport (dependent on the arguments for filetype).

So here is a little example

//not working
var pdfBytes = plugins.jasperPluginRMI.runReport(forms.frmTest.controller.getServerName(), 'repTest.jrxml', null, 'pdf', params);
//also not working
var pdfBytes = plugins.jasperPluginRMI.runReport(forms.frmTest.controller.getServerName(), 'repTest.jrxml', '', 'pdf', params);
//but this is working
var pdfBytes = plugins.jasperPluginRMI.runReport(forms.frmTest.controller.getServerName(), 'repTest.jrxml', 'test.pdf', 'pdf', params);

Is there an alternative then using the last statement - as I understand the documentation this should be possible.

Regards

Steffen

P.S.: tested under Servoy Developer and Server unde Linux, Servoy 5.2.6, MySQL, Java 1.6.24, Plugin Version 3.1.0 but using jasperreports-4.0.0.jar (till now no problems)

var pdfBytes = plugins.jasperPluginRMI.runReport(forms.frmTest.controller.getServerName(), ‘repTest.jrxml’, false, ‘pdf’, params);

Unfortunately it is not working like that:

try {
	var pdfBytes = plugins.jasperPluginRMI.runReport(forms.frmTest.controller.getServerName(), 'repTest.jrxml', false, 'pdf', params);	
}
catch (e) {
	application.output("Error during running report\n" +e);	
	return;
}

I get the following Exeption:

Error during runing report
JavaException: java.lang.Exception:  (File not found)

But the exception doesn’t tell me which file not found - or perhaps I am unable to retrieve it.

Tested with jasper version jasperreports-3.7.1 and jasperreports-4.0.0 and also tried using the compiled *.jasper files.

Have you set the reports directory via the admin page so the plugin knows where to find the jasper file?

I suppose you are hitting the same bug as this user:
http://forum.servoy.com/viewtopic.php?f=15&t=15722&p=84588&e=84588

Hello,

yes I set the reports directory because ```
plugins.jasperPluginRMI.getReports()


Seems I am hitting the same bug: <a class="postlink-local" href="http://forum.servoy.com/viewtopic.php?f=15&t=15722&p=84588#p84588">viewtopic.php?f=15&t=15722&p=84588#p84588</a>
But one question - how can I get the stack trace as shown in the linked thread? Is there any possibility to get the stack trace of this exception in servoy ? Because I checked out the source code of the plugin and it looks like it shouldn't be to difficult to find the bug...

The exception should be in your servoy_log.txt file (in application_server).
And no it isn’t a very difficult bug to fix, a simple test on filename should be enough to avoid trying to create a non existing file when not necessary.
I will submit a patch for this.

[EDIT] patch submitted on ServoyForge:

Also did a patch - but I did in a little different way - don’t even call saveByteArrayToFile();

But if I am reading the code in the right way the call of the plugin should be

var pdfBytes = plugins.jasperPluginRMI.runReport(forms.frmTest.controller.getServerName(), 'repTest.jrxml', null, 'pdf', params);

because with false as the parameter we do not set nooutput = true; in line 405.

noFileSaved.patch.txt (867 Bytes)

nooutput = true on web client will return a file (of the type you asked for) to the browser, which is unwanted behavior if you only want the byte in code.
This is why I did it this way.