I've created a very simple example report that uses a Cassandra Data Adapter (com.jaspersoft.connectors.cassandra.adapter.CassandraDataAdapterImpl) and a simple dataset and query and use these to populate a crosstab. This works well using TIBCO JasperSoft Studio and the report previews with the data all there.
I then created a very simple Java application using JasperSoft Library:
JasperPrint jp = JasperFillManager.fillReport("PATH TO COMPILED REPORT TEMPLATE EXPORTED FROM STUDIO", params); File reportfile = new File("./" + UUID.randomUUID().toString() + ".report.html"); JasperExportManager.exportReportToHtmlFile(jp, reportfile.getAbsolutePath()); String report = Files.toString(reportfile, Charset.defaultCharset());
but when I run this (as a Java application) I get:
No query executer factory registered for the "CQL" language.
Setting the data source to empty:
JasperPrint jp = JasperFillManager.fillReport("PATH TO COMPILED REPORT TEMPLATE EXPORTED FROM STUDIO", params, new JREmptyDataSource());
works, but of course the report is empty. I've tried taking the Cassandra plugin library from Studio (com.jaspersoft.studio.data.cassandra_6.3.1.final.jar) and adding to the classpath but that didn't help. I'm going to try pulling out the lib jars in there and add these directly too and see if I can create a CassandraDataSource.
In the mean time does anyone have any ideas on where I'm going wrong and what I might need to do to fix this?
1 Answer:
OK, so I think I've figured it partially out...
Not very tidy but as this is a proof-of-concept I'll worry about tidy later...
I unpacked the various jars as above, but in the end removed "cassandra-driver-core-2.1.3.jar" from the classpath and added it as a Maven dependency instead:
<dependency> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-core</artifactId> <version>2.1.3</version> </dependency>
The jar doesn't come with all the dependencies needed - I was getting a ClassNotFound for log4j. Thinking I might try v3 of the driver next...
Then I create my own connection to Cassandra, manually execute the query and then pass the ResultSet to the CassandraDataSource. Finally pass that in to the report and I get data.
Cluster cluster = Cluster.builder().addContactPoint("localhost").build(); Session session = cluster.connect("my_lovely_keyspace"); ResultSet rs = session.execute("SELECT * FROM table"); CassandraDataSource ds = new CassandraDataSource(rs); JasperPrint jp = JasperFillManager.fillReport(PATH_TO_COMPILED_REPORT, params, ds); File reportfile = new File("./" + UUID.randomUUID().toString() + ".report.html"); JasperExportManager.exportReportToHtmlFile(jp, reportfile.getAbsolutePath()); String report = Files.toString(reportfile, Charset.defaultCharset());.
Of course this only helps because I know the CQL for the report so suggestions for a better way welcome.
OK, so adding the jars in the plugin above:
to the classpath changes the error to:
There is no underlying connection. Please check your datasource