使用Ignite对象时,来自GridUnsafe的Apache Ignite IllegalAccessException

时间:2019-01-11 05:34:54

标签: ignite

这就是我代码中的全部内容。这只是使用Ignite的典型方式:

Ignite ignite = Ignition.ignite();

我看到的错误消息是:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ignite.internal.util.GridUnsafe$2 (file:/C:/Users/.../.m2/repository/org/apache/ignite/ignite-core/2.7.0/ignite-core-2.7.0.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of org.apache.ignite.internal.util.GridUnsafe$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.ignite.internal.util.IgniteUtils.<clinit>(IgniteUtils.java:795)
    at org.apache.ignite.internal.IgnitionEx.<clinit>(IgnitionEx.java:209)
    at org.apache.ignite.Ignition.ignite(Ignition.java:489)
    at distributedjobexecutor.App.<init>(App.java:19)
    at distributedjobexecutor.App.main(App.java:39)
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)
    ... 5 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 @2ac273d3
    at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:360)
    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)
    ... 6 more

为什么会收到此消息,该如何解决?我正在使用Java jdk-10.0.1。

1 个答案:

答案 0 :(得分:1)

此问题来自Java 9中引入的模块访问控制系统。

要解决此问题,请使用以下JVM参数:

--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED