Does cassandra-unit run with JDK 17?

1.9k views Asked by At

I tried to run an EmbeddedCassandra.startEmbeddedCassandra() in my unit tests (with casandra-unit:4.3.1.0) and after the startEmbeddedCassandra() is called no errors is thrown but is still loading, no timeout added to the method is triggered.

NOTEs:

  • JAVA version 17
  • Running platform Windows
  • cassandra-driver-core: 3.11.3
  • com.datastax.oss dependencies (java-driver-core, java-driver-query-builder): 4.15.0

Does anyone has any idea?

3

There are 3 answers

0
Erick Ramirez On

CassandraUnit embeds a cluster instance running Cassandra 3.11 which only works with Java 8.

Cassandra 4.0.0 added experimental support for Java 11 (CASSANDRA-9608), with full support added in C* 4.0.2 (CASSANDRA-16894).

Support for Java 17 is a work-in-progress (CASSANDRA-16895) slated for release at some point in the future. Cheers!

0
clunven On

You will never be able to run CassandraUnit with Cassandra3x with JDK17.

WHY

CassandraUnit runs as an embedded Cassandra node in the JDK. As such you need Cassandra to support the JVM as a prequisite. This is what Cassandra JVM support looks like at the moment.

  • Cassandra 3.11 is only supported up to JDK 8
  • Cassandra 4.x is only supported up to JDK 11
  • Cassandra 5.x should support JDK17 but will require a major version update.

Work Around

You need Cassandra to run outside of your JVM with Containers. The solution the most in use is TEST CONTAINERS and specially the Cassandra module or the genric one.

0
jkml On

It is possible to make CassandraUnit work with Casssandra 4.0 and Java 17.

Depending on your exact setup, you will need to do the following:

  • Tweak your POM to manage conflicting or obsolete dependencies of CassandraUnit and Cassandra
  • Use a custom cu-cassandra.yaml because the one from CassandraUnit contains properties no longer supported by Cassandra 4.0
  • Add JVM JPMS options required by Cassandra 4.0 to access non-public parts of the system modules in JDK 17
  • Put a custom version of org.apache.cassandra.utils.ObjectSizes in front of cassandra-all in the class path. Cassandra 4 use an old version of Jamm that does not support Java 17. You'll need to backport some minor changes in this class from Cassandra 5 (which uses a newer version of Jamm)
  • Exclude com.boundary:high-scale-lib because it provides custom implementations of Hashtable and ConcurrentHashMap but JPMS disallows overriding classes in the system modules. Include its source files except those in the java.util and java.util.concurrent packages in your testing source directory instead

You may refer to this project as an example: https://github.com/jkmcl/spring-data-cassandra-example