yong
yong

Reputation: 53

How do i get a Report from jasperserver?

please help me to fix it, i really have no idea ! please

/* - To change this template, choose Tools | Templates - and open the template in the editor. */ - package pdfprint;

import com.jaspersoft.ireport.jasperserver.JServer; import
com.jaspersoft.ireport.jasperserver.ws.WSClient; import
java.util.HashMap; import java.util.*; import
net.sf.jasperreports.engine.JasperPrint; import
net.sf.jasperreports.engine.JasperReport; import
net.sf.jasperreports.engine.export.JRPrintServiceExporter; import
net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import net.sf.jasperreports.view.JasperViewer;



public class Pdfprint {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
      try{
    JServer server = new JServer();
    server.setUrl("http://localhost:8080/jasperserver/services/repository");
    server.setUsername("jasperadmin");
    server.setPassword("jasperadmin");


    ResourceDescriptor rd = new ResourceDescriptor();
    rd.setUriString("/solucisv3_testing/jr_testing_print");

    WSClient client = new WSClient(server);
    List list = client.list(rd);

      Map params = new HashMap();
      params.put("Plb_Company", "Company");
      params.put("Plb_Address", "Address");
      params.put("Plb_Title","Title");
      params.put("PCondition","SELECT * FROM v_doc_ticketing  WHERE f_doc_no='MYCSB0000096'");

     JasperPrint printer = client.runReport(rd, params);
     JasperViewer.viewReport(printer, false,Locale.GERMAN);


     JRPrintServiceExporter exporter;
     exporter = new JRPrintServiceExporter();
     //exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
     exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
Boolean.FALSE);
     exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
Boolean.TRUE);
     exporter.setParameter(JRPdfExporterParameter.PDF_JAVASCRIPT,"this.print({bUI:
false,bSilent: true,bShrinkToFit: true});");
     exporter.exportReport(); } catch(Exception ex){ }
    } }

Upvotes: 1

Views: 3054

Answers (1)

GenericJon
GenericJon

Reputation: 8986

You are passing a pdfprint.ResourceDescriptor instead of a com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor.

Possibly in your IDE you accidentally created a ResourceDescriptor class in your current package instead of importing the existing one. If so, simply delete the class from your package and add an import statement for the correct one, making sure that it is on the classpath for your project.

Upvotes: 1

Related Questions