Jump to content

JasperSoft Library with Cassandra


peter.cliff

Recommended Posts

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());[/code]

but when I run this (as a Java application) I get:

No query executer factory registered for the "CQL" language.[/code]

Setting the data source to empty:

JasperPrint jp = JasperFillManager.fillReport("PATH TO COMPILED REPORT TEMPLATE EXPORTED FROM STUDIO", params, new JREmptyDataSource());[/code]

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?

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

OK, so adding the jars in the plugin above:

cassandra-driver-core-2.1.3.jarjs-cassandracql3-datasource-2.3.jarmetrics-core-3.0.2.jarnetty-3.9.0.Final.jarjasperreports_extension.properties[/code]

to the classpath changes the error to:

There is no underlying connection. Please check your datasource[/code]Sounds like progress.Just need to work out how to sensibly create a CassandraDataSource perhaps? 
Link to comment
Share on other sites

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>[/code]

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());.[/code]

Of course this only helps because I know the CQL for the report so suggestions for a better way welcome.

Link to comment
Share on other sites

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...