Jasper report not generating in Headless client.

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

Jasper report not generating in Headless client.

Postby ashutoslenka426 » Sat Jun 18, 2016 4:42 pm

Hi All,

I am generating a sql based report in the headless client . I am passing all the parameters of the report from the main solution to the headless client solution . But I could not able to see the report . Why ? . Please provide some suggestion on this.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Jasper report not generating in Headless client.

Postby ashutoslenka426 » Mon Jun 20, 2016 6:21 am

Hi All,

I am doing anything wrong or it is not possible ? . Please provide some suggestion .
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Jasper report not generating in Headless client.

Postby patrick » Mon Jun 20, 2016 9:52 am

You have to provide a little more information. How / where do you expect to see the report? Maybe it's easiest you post some code that shows how you call the headless client and what the headless client does then.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Jasper report not generating in Headless client.

Postby ashutoslenka426 » Mon Jun 20, 2016 10:02 am

Hi ,

I am doing this in the main solution :
Code: Select all
var headlessClient = plugins.headlessclient.createClient("ReportGeneration", null, null, null);
if (headlessClient != null && headlessClient.isValid()) {
         headlessClient.queueMethod(null, "printReportHeadlessClient", [reportSource,reportName + '.jrxml',null,plugins.jasperPluginRMI.OUTPUT_FORMAT.VIEW,parameters], callback);
}

In the headless client solution (ReportGeneration) :
Code: Select all
function printReportHeadlessClient(reportSource,reportName,outputOptions,outputType,parameters) {
   
   plugins.jasperPluginRMI.runReport(reportSource,reportName,outputOptions,outputType,parameters);
         
}

Please provide some suggestion on this.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Jasper report not generating in Headless client.

Postby patrick » Mon Jun 20, 2016 10:38 am

You are asking a headless client to create and show a report and expect to see it in the calling client. That won't work. A headless client is a client that runs on the server, so a different client than you user is running. And a headless client is what its name suggests: headless. So nothing could be ever be "viewed" there.

What you need to do is: let the headless client create the report and return that to the client. So something like this

Code: Select all
var headlessClient = plugins.headlessclient.createClient("ReportGeneration", null, null, null);
if (headlessClient != null && headlessClient.isValid()) {
         headlessClient.queueMethod(null, "printReportHeadlessClient", [reportSource,reportName + '.jrxml',null,plugins.jasperPluginRMI.OUTPUT_FORMAT.PDF,parameters], callback);
}


This will ask your headless client to create a PDF and call the callback method.

Your headless client then should return the report created:

Code: Select all
function printReportHeadlessClient(reportSource,reportName,outputOptions,outputType,parameters) {
  return plugins.jasperPluginRMI.runReport(reportSource,reportName,outputOptions,outputType,parameters);
}


your callback method then should look something like this:

Code: Select all
function headlessClientCallback(event) {
   if (event.getType() == JSClient.CALLBACK_EVENT) {
      //headless client was successful and put the result of the method called on the data property of the event
      var pdfBytes = event.data;
      //process PDF
   }
}


I'm actually not sure whether you can show the jasper viewer in the calling client. You'd have to return a JRPRINT format for that for sure, but I don't know out of my head if the plugin has a method that allows you to display the viewer window.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Jasper report not generating in Headless client.

Postby ashutoslenka426 » Mon Jun 20, 2016 11:38 am

Hi Patrick ,

Thanks for your reply . I got that . Now I am doing as per your suggestion . But I am getting some exception in the callback method . The event parameter is :
Code: Select all
{data:"Wrapped java.lang.Exception: java.lang.Exception: Input type JDBCdatabase has been used with an incorrect datasource of type: class java.lang.String"}

Please provide some suggestion on this.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Jasper report not generating in Headless client.

Postby patrick » Mon Jun 20, 2016 12:06 pm

That sounds like your report source. What is that? Are you trying to use a foundset as report source? Then it won't work like that, because you cannot send a JSFoundSet from client to server (headless client) over the wire. If you need to use a foundset, you will have to send something to the headless client that allows it to create/load that same foundset that you want (for example a bunch of primary keys to load or some query criteria).
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Jasper report not generating in Headless client.

Postby ashutoslenka426 » Mon Jun 20, 2016 12:24 pm

Hi Patrick ,

Thanks for your reply . This is a SQL based report and not foundset based . I am passing datasource as the first parameter. Please provide some suggestion on this.
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Jasper report not generating in Headless client.

Postby patrick » Mon Jun 20, 2016 12:31 pm

I think it expects the server name only, not a full datasource string.

To test this, you could simply include your headless client solution as a module to your solution and put a breakpoint in your headless client method. You should be able to debug this... Does the report generation work locally (without headless client) with the exact same parameters?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Jasper report not generating in Headless client.

Postby ashutoslenka426 » Mon Jun 20, 2016 1:37 pm

Hi Patrick ,

Thanks for your reply . It is only getting the server name . The report generation works fine locally without headless client with the exact same parameter . I am seeing one exception to be like : https://www.servoyforge.net/issues/1015
AL
ashutoslenka426
 
Posts: 295
Joined: Thu Jan 26, 2012 3:38 pm

Re: Jasper report not generating in Headless client.

Postby patrick » Mon Jun 20, 2016 1:57 pm

At least the error message suggests you run into the same issue. When I understand it right, that error pops up when some of the parameters provided to the report is used as an integer argument in the query. If that is your case, then the case also suggests a workaround... What I think is not quite clear though is why it works locally then.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 6 guests