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?