hpgrahsl / kryptonite-for-kafka

Kryptonite for Kafka is a client-side 🔒 field level 🔓 cryptography library for Apache Kafka® offering a Kafka Connect SMT, ksqlDB UDFs, and a standalone HTTP API service. It's an ! UNOFFICIAL ! community project
83 stars 6 forks source link

Java 17 seems to be not yet supported #14

Closed ghost closed 12 months ago

ghost commented 12 months ago

Hi @hpgrahsl,

Thanks for your great library, I have tried it using Java 11 and it's working fine. But when I use different environment with Java 17, it's throwing an error as below:

Unable to make field final java.util.Collection java.util.Collections$UnmodifiableCollection.c accessible: module java.base does not "opens java.util" to unnamed module @30ed8e6f

aused by: java.lang.RuntimeException: Could not access source collection field in java.util.Collections$UnmodifiableCollection. at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.(UnmodifiableCollectionsSerializer.java:62) ... 30 more Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field final java.util.Collection java.util.Collections$UnmodifiableCollection.c accessible: module java.base does not "opens java.util" to unnamed module @30ed8e6f at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178) at java.base/java.lang.reflect.Field.setAccessible(Field.java:172) at de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer.(UnmodifiableCollectionsSerializer.java:55) ... 30 more

I come to search over the internet and find out it's Java incompatibility issue. When you have time (I know you were busy), we can work together to fix this.

Appreciate your help, Vincent Trinh.

wdutkiewicz commented 12 months ago

I had the same issue for Java 17. After some research I found a workaround: add JAVA_TOOLS_OPTION system environment variable and set its value to --add-opens=java.base/java.util=ALL-UNNAMED.

ghost commented 12 months ago

Hi @wdutkiewicz ,

Thanks for your information, I tried your suggestion (setup java environment variable) (I use Confluent Platform and use Ansible to make deployment and config), but still the issue remains.

Are you just simply doing export? Could you help to share how you set it up in this case, step by step? It will be very helpful for me.

Thank you very much, Vincent Trinh.

wdutkiewicz commented 12 months ago

Hi, @baduy9x

I am running Kafka on Windows, therefore I use system settings to set up the environment variable. In order to verify if Java picks the variable, go to command line and run java -version. You should see the variable being listed. You should see something like: Picked up JAVA_TOOL_OPTIONS: --add-opens=java.base/java.util=ALL-UNNAMED. I don't know how to set it up on Linux.

ghost commented 12 months ago

oh I find out, there is a typo in the environment variable, should be JAVA_TOOL_OPTIONS. Fixed for me now. Thanks a lot @wdutkiewicz

wdutkiewicz commented 11 months ago

Hi, @baduy9x. Sorry for the typo, I am happy this worked for you. However, the issue still exists and I believe this should be fixed on code-level.

hpgrahsl commented 11 months ago

Hi @baduy9x and @wdutkiewicz! Yes you are right that the code base and this project is currently supposed to be used with Java 11. The reason is not this library per se but the dependencies to the 2 kryo related serialization libs. These are making use of code constructs and unsafe methods that lead to the behaviour you both have experienced. Hope this helps!