Jump to content
Changes to the Jaspersoft community edition download ×

How to call jasper file from java code


Recommended Posts

I have try, this code for call report with web service datasource, but always get error  like this

1832 [AWT-EventQueue-0] DEBUG net.sf.jasperreports.engine.fill.JRFillDataset  - Fill 1: Creating WebServiceQuery query executer
2299 [AWT-EventQueue-0] DEBUG net.sf.jasperreports.engine.fill.JRFillDataset  - Fill 1: closing query executer
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.jaspersoft.webservice.data.query.WebServiceQueryExecuter.getInternalQE(WebServiceQueryExecuter.java:244)
    at com.jaspersoft.webservice.data.query.WebServiceQueryExecuter.close(WebServiceQueryExecuter.java:201)
    at net.sf.jasperreports.engine.fill.JRFillDataset.closeQueryExecuter(JRFillDataset.java:1334)
    at net.sf.jasperreports.engine.fill.JRFillDataset.closeDatasource(JRFillDataset.java:1315)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:641)
    at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:214)
    at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:200)
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:548)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:966)

 

this my code for call report

 public void mouseClicked(MouseEvent e) {
                try {
                    JasperReport jr = (JasperReport) JRLoader.loadObject(new File("laporan/Kasmasuksatu.jasper"));
                    HashMap param = new HashMap();
                    param.put(WebServiceDataAdapterService.URI_KEY, "http://192.168.1.5:556/");
                    param.put(WebServiceDataAdapterService.VERB_KEY, "get");
                    param.put(WebServiceDataAdapterService.LANGUAGE_KEY, LanguageType.JSON);
                    //param.put(WebServiceDataAdapterService.AUTH_PARAMETERS_KEY, "none");
                    //param.put("tipe", "0");
                    //JasperReport jr = JasperCompileManager.compileReport(new FileInputStream(new File("laporan/Kasmasuksatu.jrxml")));
                    JasperPrint jp = JasperFillManager.fillReport(jr, param);
                    JRViewer jv = new JRViewer(jp);
                    pane.mainpane.add(jv);
                    pane.mainpane.revalidate();
                } catch (JRException ex) {
                    Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }

 

whats wrong on my code?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...