java jdbc 连接ignite,在JDK 9上使用Ignite

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.(IgniteUtils.java:769)

at org.apache.ignite.spi.IgniteSpiAdapter.(IgniteSpiAdapter.java:119)

at org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi.(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.(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!

解决方案

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

你可能感兴趣的:(java,jdbc,连接ignite)