2

I am trying to run embedded Cassandra using cassandra-unit library in Azul JDK 11 with Gradle project and getting following AccessDenindException. I've checked the permissions of the build folder it is not readonly and there are some files already. Don't have anything else in the project which might causing the issue.

org.apache.cassandra.io.FSWriteError: java.nio.file.AccessDeniedException: build\embeddedCassandra\commitlog\CommitLog-6-1642719269564.log
    at org.apache.cassandra.io.util.FileUtils.deleteWithConfirm(FileUtils.java:143)
    at org.apache.cassandra.io.util.FileUtils.deleteWithConfirm(FileUtils.java:160)
    at org.apache.cassandra.db.commitlog.CommitLogSegment.discard(CommitLogSegment.java:409)

Java class

EmbeddedCassandraServerHelper.startEmbeddedCassandra();

build.gradle

testCompile 'org.cassandraunit:cassandra-unit:4.3.1.0'
testCompile 'com.datastax.oss:java-driver-core:4.13.0'

2 Answers 2

2

There isn't any magic that happens here since Cassandra is simply using the Java IO utilities so this is a low-level filesystem issue.

One of the things to check for is whether the existing commit logs in the directory are owned by a different user that the Cassandra process does not have access to. For example, CommitLog-6-1642719269564.log is owned by root but the C* process is running with cassandra. If so, you will need to change the file ownership. Cheers!

[UPDATE] Java 11 is only supported from Cassandra 4.x. Earlier versions of Cassandra only work with Java 8.

Sign up to request clarification or add additional context in comments.

2 Comments

Is there a way to fix that permissions error from the outside? Or the only thing to do is to observe an error and wait for fix?
@yu.pitomets it might not be a permission issue after all. Java 11 is only supported for Cassandra 4.x+ and won't work with earlier versions of Cassandra. Commit log version -6- indicates you're running Cassandra 3.x. Cheers!
0

Check the test dependency tree for version downgrades with gradle dependencies. My Apache Cassandra and Java Native Access libs were getting downgraded by Spring Boot 2.2. Fixing the JNA version took care of the AccessDeniedException error in Windows.

Additionally, CassandraUnit uses a JDK-internal Cleaner class that is restricted in Java 11. You can add a JVM arg in the test task(s) to make it available again.

The relevant build.gradle snippets are shown below.

dependencies {
    ...
    testImplementation 'org.cassandraunit:cassandra-unit:4.3.1.0'
    testImplementation 'com.datastax.oss:java-driver-core:4.11.3'
    testImplementation 'org.apache.cassandra:cassandra-all:4.0.8' // override 3.x from spring-data-cassandra
    testImplementation 'net.java.dev.jna:jna:5.13.0'              // override 4.5 from spring-boot-dependencies
}
tasks.withType(Test) {
    // allow cassandraunit to use jdk11 internal Cleaner
    jvmArgs '--add-exports', 'java.base/jdk.internal.ref=ALL-UNNAMED'
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.