如何解决在 java 11 中启用了 hazelcast-kubernetes 集群 ClassNotFoundException
我在 Java 11 中为我的应用程序启用了 hazelcast-kubernetes,但是当我尝试部署它时,我收到以下警告
09-Jun-2021 13:12:05.881 WARNING [main] com.hazelcast.instance.impl.HazelcastInstanceFactory.null Hazelcast is starting in a Java modular environment (Java 9 and newer) but without proper access to required Java packages. Use additional Java arguments to provide Hazelcast access to Java internal API. The internal API access is used to get the best performance results. Arguments to be used:
--add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
为了解决这个问题,我在我的 deployment.yaml 中添加了 java args 命令,如此 link
containers:
- name: application
image: docker-image
command: ["java"]
args: [" --add-modules java.se \\"," --add-exports java.base/jdk.internal.ref=ALL-UNNAMED \\"," --add-opens java.base/java.lang=ALL-UNNAMED \\"," --add-opens java.base/java.nio=ALL-UNNAMED \\"," --add-opens java.base/sun.nio.ch=ALL-UNNAMED \\"," --add-opens java.management/sun.management=ALL-UNNAMED \\"," --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED \\"]
当我尝试在集群中部署 Pod 时,出现以下错误:-
Error: Could not find or load main class --add-modules java.se \
Caused by: java.lang.classNotFoundException: --add-modules java.se \
解决方法
看起来你的论点有问题。
变化:
args: [" --add-modules java.se \\"," --add-exports java.base/jdk.internal.ref=ALL-UNNAMED \\"," --add-opens java.base/java.lang=ALL-UNNAMED \\"," --add-opens java.base/java.nio=ALL-UNNAMED \\"," --add-opens java.base/sun.nio.ch=ALL-UNNAMED \\"," --add-opens java.management/sun.management=ALL-UNNAMED \\"," --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED \\"]
致:
args:
- --add-modules
- java.se
- --add-exports
- java.base/jdk.internal.ref=ALL-UNNAMED
- --add-opens
- java.base/java.lang=ALL-UNNAMED
- --add-opens
- java.base/java.nio=ALL-UNNAMED
- --add-opens
- java.base/sun.nio.ch=ALL-UNNAMED
- --add-opens
- java.management/sun.management=ALL-UNNAMED
- --add-opens
- jdk.management/com.sun.management.internal=ALL-UNNAMED
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。