Jasper report not generating in Headless client.

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

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:

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:

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.