apache / pekko-samples

Apache Pekko Sample Projects
https://pekko.apache.org/
Apache License 2.0
42 stars 20 forks source link

issue with Cassandra in pekko-sample-distributed-workers-scala #109

Open pierreboudes opened 4 months ago

pierreboudes commented 4 months ago

On a stable Debian (OpenJDK 17), the example pekko-sample-distributed-workers-scala will fail on a exception while using sbt run or sbt "runMain worker.Main cassandra".

The logs

Starting Cassandra on port client port: 9042 storage port 45209 host 127.0.0.1 java version 17.0.10+7-Debian-1deb12u1
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.apache.cassandra.security.ThreadAwareSecurityManager (file …/pekko-samples/pekko-sample-distributed-workers-scala/target/cassandra-db/cassandra-bundle.jar)
WARNING: Please consider reporting this to the maintainers of org.apache.cassandra.security.ThreadAwareSecurityManager
WARNING: System::setSecurityManager will be removed in a future release
Exception (java.lang.AssertionError) encountered during startup: java.lang.reflect.InaccessibleObjectException: Unable to make field private int java.io.FileDescriptor.fd accessible: module java.base does not "opens java.io" to unnamed module @11b03c1f
java.lang.AssertionError: java.lang.reflect.InaccessibleObjectException: Unable to make field private int java.io.FileDescriptor.fd accessible: module java.base does not "opens java.io" to unnamed module @11b03c1f
…
[error]     at worker.Main$.startCassandraDatabase(Main.scala:101)
pjfanning commented 4 months ago

you could add something like this to the build.sbt

run / javaOptions ++= Seq("--add-opens", "java.base/java.lang=ALL-UNNAMED")

unfortunately, this will cause issues if you use Java 8 or 11

when we get around to doing a PR to fix this, we'll probably need to add a condition that checks the java runtime version

pierreboudes commented 4 months ago

Thank you for your quick answer ! I also had to add run / fork := true as warned by sbt ([warn] Compile / run / javaOptions will be ignored, Compile / run / fork is set to false). Unfortunately I still have the error. I also tried adding the same option for java.util (random pick on Internet).