-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cassandra unit on Java 9 #249
Comments
Hi, System.setProperty("cassandra.config", "file:///" + “/path/to/yaml/file/file_name.yaml");
DatabaseDescriptor.daemonInitialization(); before EmbeddedCassandraServerHelper.startEmbeddedCassandra(“file_name.yaml"); but now I have this error: [pool-2-thread-1] ERROR o.a.c.service.CassandraDaemon - Exception encountered during startup
java.lang.IncompatibleClassChangeError: Inconsistent constant pool data in classfile for class org/apache/cassandra/utils/btree/UpdateFunction. Method lambda$static$0(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; at index 45 is CONSTANT_MethodRef and should be CONSTANT_InterfaceMethodRef
at org.apache.cassandra.utils.btree.UpdateFunction.<clinit>(UpdateFunction.java:66) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.utils.btree.BTree$Builder.build(BTree.java:1108) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.utils.btree.BTreeSet$Builder.build(BTreeSet.java:608) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.db.PartitionColumns$Builder.build(PartitionColumns.java:196) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.config.CFMetaData$Builder.build(CFMetaData.java:1327) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.config.CFMetaData.compile(CFMetaData.java:427) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.schema.SchemaKeyspace.compile(SchemaKeyspace.java:266) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.schema.SchemaKeyspace.<clinit>(SchemaKeyspace.java:114) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.config.Schema.<init>(Schema.java:69) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.config.Schema.<clinit>(Schema.java:49) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.service.StartupChecks$10.execute(StartupChecks.java:371) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.service.StartupChecks.verify(StartupChecks.java:116) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:200) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:600) ~[cassandra-unit-shaded-3.3.0.2.jar:na]
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.lambda$startEmbeddedCassandra$1(EmbeddedCassandraServerHelper.java:144) [cassandra-unit-shaded-3.3.0.2.jar:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:844) ~[na:na] Maybe it could be useful to someone. I saw that there is a patch in the related ticket https://issues.apache.org/jira/browse/CASSANDRA-9608. When will CassandraUnit be patched to support Java 9? By the way, for now, I've found a workaround. Thanks |
I will add some details to this issue instead of starting a new one. For today, cassandra-unit still crashes on startup on Java 9. I created a sample demo project to reproduce the issue. Both Mave and Gradle are affected. Here's the stacktrace: java.lang.ExceptionInInitializerError
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.mkdir(EmbeddedCassandraServerHelper.java:302)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.copy(EmbeddedCassandraServerHelper.java:289)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:99)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:81)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:73)
at org.cassandraunit.utils.EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.java:69)
at com.gosiewski.demo.CassandraIntegrationTest.init(CassandraIntegrationTest.java:16)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.NullPointerException
at org.apache.cassandra.config.DatabaseDescriptor.getDiskFailurePolicy(DatabaseDescriptor.java:1881)
at org.apache.cassandra.utils.JVMStabilityInspector.inspectThrowable(JVMStabilityInspector.java:82)
at org.apache.cassandra.io.util.FileUtils.<clinit>(FileUtils.java:79)
... more And here's the link to repo: |
@nachii
Is this working? |
Looking at CASSANDRA-9608:
This ticket seems to remain open for quite a while. |
Yes, the main problem is that cassandra-unit is starting in the same JVM an instance of Cassandra which does not work on Java 9 at the moment... |
@jsevellec |
@lukasz-gosiewski yes, it's working. I'll try to explain it better. @SpringBootApplication
public class Application {
public static void main(String[] args) throws IOException, TTransportException {
EmbeddedCassandraServerHelper.startEmbeddedCassandra("embedded-cassandra.yaml");
}
} Then I have a Spring Boot app built with JDK 9 where there are the tests that use CassandraUnit. ...
<properties>
<!-- Default value to allow Jenkins build run. -->
<jdk8.path>java</jdk8.path>
</properties>
...
<!--
Plugin that starts the embedded Cassandra before the unit tests are run.
In the Jenkins CI environment this will be ignored because of a connection error. Pre-step build have been added instead.
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>generate-test-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${jdk8.path}</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>com.example.embedded.cassandra.Application</argument>
</arguments>
<async>true</async>
<!-- Ignore errors when exit code is 1. -->
<successCodes>0,1</successCodes>
</configuration>
</plugin> And I launch Maven like this: mvn clean install -Djdk8.path=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin/java In this way, the embedded Cassandra is launched in a separate process before the tests execution that will be killed automatically at the end of the build. It seems that with TestContainers (https://www.testcontainers.org/) we can start a Docker container directly from JUnit, but I haven't tried it yet. I hope I was clear. |
still not working with Java10 `
` this code just works with Java 8 |
https://issues.apache.org/jira/browse/CASSANDRA-9608 is fixed now. |
The workaround proposed by @nachii is fine with Java 10, but it is not working with Java 11 (see stacktrace below) Cassandra is now compatible Java 11.
|
@fabianpiau have you tried upgrading to jamm 0.3.2? |
No, I see I have a dependency on 0.3.0 |
Yes it's working, thanks a lot for the tip! |
At the end it's just a of dependency management and which dependency version does cassandra-unit bring with him by default Would you mind to share to propose a PR for CU containing the good dependency versions? |
I'd personally wait until Cassandra 4 is available to get full Java 11 support. |
thanks for your time! |
Hi ,
Version Details --> |
Any Update on this Thread . |
Hello guys! Have you resolved this issue? |
Cassandra Unit issue - jsevellec/cassandra-unit#249 #202
* Support for Cassandra dataStax driver 4 #202 * Exclude instrumentation for pre 4.0.0 release versions #202 * Exclude unit tests for Java 9+ Cassandra Unit issue - jsevellec/cassandra-unit#249 #202
This is more of a to-be-done ticket as soon as Cassandra supports Java 9.
Right now, Cassandra fails on Java 9 because of initialization errors that are attempted to be reported but reporting fails because of uninitialized
DatabaseDescriptor
.Setting up the configuration
Before calling
org.cassandraunit.utils.EmbeddedCassandraServerHelper#rmdir
initializesDatabaseDescriptor
eagerly yet Cassandra still fails because of the illegal access toByteBuffer.cleaner()
.Related ticket: https://issues.apache.org/jira/browse/CASSANDRA-9608
The text was updated successfully, but these errors were encountered: