Running Apache Ignite on OpenJDK 15, 16 and 17

September 9, 2022

The current docs state1 that the following but incorrect JVM flags and options must be given.

--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED
--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
--illegal-access=permit

However these options result in the following errors on OpenJDK 17.

OpenJDK 64-Bit Server VM warning: Ignoring option --illegal-access=permit; support was removed in 17.0
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.ignite.internal.util.IgniteUtils.(IgniteUtils.java:878)
    at org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder.(TcpDiscoveryMulticastIpFinder.java:95)
    at Main.main(Main.java:25)
Caused by: java.lang.RuntimeException: java.nio.DirectByteBuffer.address field is unavailable.
    at org.apache.ignite.internal.util.GridUnsafe$2.run(GridUnsafe.java:1570)
    at org.apache.ignite.internal.util.GridUnsafe$2.run(GridUnsafe.java:1557)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.apache.ignite.internal.util.GridUnsafe.bufferAddressOffset(GridUnsafe.java:1557)
    at org.apache.ignite.internal.util.GridUnsafe.(GridUnsafe.java:109)
    ... 3 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field long java.nio.Buffer.address accessible: module java.base does not "opens java.nio" to unnamed module @f2a0b8e
    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 org.apache.ignite.internal.util.GridUnsafe$2.run(GridUnsafe.java:1562)
    ... 7 more

Fix

In order to run Ignite on OpenJDK with higher versions than 14, the following and correct JVM flags2 are required to run. Tested with Apache Ignite 2.13 and OpenJDK 17.0.1.

--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED 
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED 
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED 
--add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED 
--add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED 
--add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED 
--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED 
--add-opens=java.base/java.io=ALL-UNNAMED 
--add-opens=java.base/java.nio=ALL-UNNAMED 
--add-opens=java.base/java.util=ALL-UNNAMED 
--add-opens=java.base/java.lang=ALL-UNNAMED 

OpenJDK 18

As of writing this post, the current latest Ignite version 2.13 does not support OpenJDK 18, but a fix is planned in the future 2.14 release3 (mailing list reference4).  

SEVERE: Failed to stop component (ignoring): GridManagerAdapter [enabled=true, name=o.a.i.i.managers.deployment.GridDeploymentManager]
java.lang.ClassCastException: class java.io.ObjectInputStream$Caches$1 cannot be cast to class java.util.Map (java.io.ObjectInputStream$Caches$1 and java.util.Map are in module java.base of loader 'bootstrap')
    at org.apache.ignite.internal.managers.deployment.GridDeploymentStoreAdapter.clearSerializationCache(GridDeploymentStoreAdapter.java:151)
    at org.apache.ignite.internal.managers.deployment.GridDeploymentStoreAdapter.clearSerializationCaches(GridDeploymentStoreAdapter.java:120)
    at org.apache.ignite.internal.managers.deployment.GridDeploymentLocalStore.undeploy(GridDeploymentLocalStore.java:565)
    at org.apache.ignite.internal.managers.deployment.GridDeploymentLocalStore.stop(GridDeploymentLocalStore.java:101)
    at org.apache.ignite.internal.managers.deployment.GridDeploymentManager.storesStop(GridDeploymentManager.java:630)
    at org.apache.ignite.internal.managers.deployment.GridDeploymentManager.stop(GridDeploymentManager.java:137)
    at org.apache.ignite.internal.IgniteKernal.stop0(IgniteKernal.java:1928)
    at org.apache.ignite.internal.IgniteKernal.stop(IgniteKernal.java:1806)
    at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.stop0(IgnitionEx.java:2382)
    at org.apache.ignite.internal.IgnitionEx$IgniteNamedInstance.stop(IgnitionEx.java:2205)
    at org.apache.ignite.internal.IgnitionEx.stop(IgnitionEx.java:350)
    at org.apache.ignite.Ignition.stop(Ignition.java:230)
    at org.apache.ignite.internal.IgniteKernal.close(IgniteKernal.java:2776)
    at Main.main(Main.java:45)

References
1
Ignite Quick Start Guide for Java | Ignite Documentation

https://ignite.apache.org/docs/latest/quick-start/java#running-ignite-with-java-11

cached copy
2
ignite/jvmdefaults.sh at 51c8ff1c2fa61fe7b375179bb65894d1422a5da5 · apache/ignite · GitHub

https://github.com/apache/ignite/blob/51c8ff1c2fa61fe7b375179bb65894d1422a5da5/bin/include/jvmdefaults.sh#L55

cached copy
Tags