Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Ignite on JDK 9

I am having trouble using Ignite on JDK 9. I have the following minimal testcase:

package no.ovstetun.ignite;

import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.junit.Test;

public class FailingIgniteTest {
    @Test
    public void failingIgnite() {
        TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
    }
}

This code sample fails with the following stacktrace:

java.lang.ExceptionInInitializerError
  at org.apache.ignite.internal.util.IgniteUtils.<clinit>(IgniteUtils.java:769)
  at org.apache.ignite.spi.IgniteSpiAdapter.<init>(IgniteSpiAdapter.java:119)
  at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.<init>(TcpDiscoverySpi.java:231)
  at no.nrk.mdb.common.infrastructure.ignite.IgniteConfigurationTest.failingIgnite(IgniteConfigurationTest.java:10)
  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.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  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.RuntimeException: jdk.internal.misc.JavaNioAccess class is unavailable.
  at org.apache.ignite.internal.util.GridUnsafe.javaNioAccessObject(GridUnsafe.java:1453)
  at org.apache.ignite.internal.util.GridUnsafe.<clinit>(GridUnsafe.java:112)
  ... 26 more
Caused by: java.lang.IllegalAccessException: class org.apache.ignite.internal.util.GridUnsafe cannot access class jdk.internal.misc.SharedSecrets (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @31ef45e3
  at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
  at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:589)
  at java.base/java.lang.reflect.Method.invoke(Method.java:556)
  at org.apache.ignite.internal.util.GridUnsafe.javaNioAccessObject(GridUnsafe.java:1450)
  ... 27 more

I am trying to migrate my codebase beyond Java 8, and Ignite is now the only dependency holding me back. I have tried adding --add-module to my runner, but I can't seem to find what is needed to make Ignite work with JDK 9.

The same error is with Ignite versions 2.4.0 and 2.5.0.

Any help would be much appreciated!

like image 979
Trond Marius Øvstetun Avatar asked Jun 01 '18 08:06

Trond Marius Øvstetun


1 Answers

Try adding the following parameters when launching Java:

--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED 
like image 141
alamar Avatar answered Sep 22 '22 04:09

alamar