0

I have a Java service that I generates reports with the JasperReports 4.0.5 library. It works well with standard JDBC datasource.
Now I am trying to run it on olap datasource, then connecting me to a XML-A server. In the design phase with iReport, everything runs, but when I run it in Java, I get an error "NullPointerException" on execution!
I's using olap4j library to connect to the data source, the same one used by iReport
This is the code:

 try{
      Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
      net.sf.jasperreports.engine.util.JRProperties.setProperty("net.sf.jasperreports.query.executer.factory.xmla-mdx", "net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuterFactory");

      final Connection connection =
        DriverManager.getConnection(
            "jdbc:xmla:Server=http://localhost/olap/msmdpump.dll"
            + ";Cache=org.olap4j.driver.xmla.cache.XmlaOlap4jNamedMemoryCache"
            + ";Cache.Name=MyNiftyConnection"
            + ";Cache.Mode=LFU;Cache.Timeout=600;Cache.Size=100"
            + ";Catalog=Test"
            ,null, null);

    OlapWrapper wrapper = (OlapWrapper) connection;
    OlapConnection olapConnection = wrapper.unwrap(OlapConnection.class);

    String fileJrxml = "C:\\report_xmla.jrxml";

    HashMap<String,Object> hm_parameters = new HashMap<String, Object>();

    JasperDesign jasperDesign = JRXmlLoader.load(fileJrxml);
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

    JasperPrint jp = null;

    jp = JasperFillManager.fillReport(jasperReport, hm_parameters, olapConnection);

    // Done
    connection.close();
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

Where am I doing wrong?

T. Phanelly
  • 189
  • 5
  • 17
  • You should add more details. What versions are you using? Have you tested the olap connection independently? What is the stack trace returned? These are all important for us to be able to help you; we can't really run your report, now, can we? Also, are you aware that OlapConnections do not implement the JDBC specs completly? Does the JR API use olap connections correctly? – Luc Jul 19 '13 at 14:09
  • I solved it. Connection is via parameters without CONNECTION object. String url = "http://localhost/olap/msmdpump.dll"; String ds = "localhost"; String cat = "CAT"; String fileJasper = "C:\\report_xmla.jrxml"; JasperReport jasperReport = JasperCompileManager.compileReport(fileJasper); jp = JasperFillManager.fillReport(jasperReport, parameters); Thank you for your interest Luc – T. Phanelly Jul 25 '13 at 13:32

0 Answers0