有没有办法在启动 Ignite 客户端时传递 JVM 参数
Is there a way to pass JVM arguments when starting Ignite client
我可以通过在 ignite.sh 脚本中添加一些 JVM 参数来在 Java 17 上启动我的 Ignite 服务器,但是当我通过 Ignition.start 或 [=31 启动我的 Ignite 客户端时=]客户端我收到反射异常。
有没有办法:
- 提供在 Ignition.start 启动新的 jvm 进程时将给出的额外参数?
- 如果没有,是否可以通过 ignite.sh 创建 Ignite 客户端?
我知道这些问题可以通过使用 Java 11 来解决,但这不是一个选项。
下面是调用 Ignition.start
后得到的堆栈跟踪
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-28 18:50:34.518 ERROR 53868 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'igniteThinCacheManager': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=10=](AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar!/:2.6.3]
at com.niksun.myService.MyServiceApplication.main(MyServiceApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.ExceptionInInitializerError: null
at org.apache.ignite.internal.util.IgniteUtils.<clinit>(IgniteUtils.java:865) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient$ClientMarshallerContext.<init>(TcpIgniteClient.java:542) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.<init>(TcpIgniteClient.java:114) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.<init>(TcpIgniteClient.java:102) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.start(TcpIgniteClient.java:339) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.Ignition.startClient(Ignition.java:615) ~[ignite-core-2.12.0.jar!/:2.12.0]
at com.niksun.myService.cache.IgniteThinCacheManager.init(IgniteThinCacheManager.java:45) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.15.jar!/:5.3.15]
... 26 common frames omitted
Caused by: java.lang.RuntimeException: java.nio.DirectByteBuffer.address field is unavailable.
at org.apache.ignite.internal.util.GridUnsafe.run(GridUnsafe.java:1570) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.util.GridUnsafe.run(GridUnsafe.java:1557) ~[ignite-core-2.12.0.jar!/:2.12.0]
at java.base/java.security.AccessController.doPrivileged(Unknown Source) ~[na:na]
at org.apache.ignite.internal.util.GridUnsafe.bufferAddressOffset(GridUnsafe.java:1557) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.util.GridUnsafe.<clinit>(GridUnsafe.java:109) ~[ignite-core-2.12.0.jar!/:2.12.0]
... 40 common frames omitted
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 @27abe2cd
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Unknown Source) ~[na:na]
at org.apache.ignite.internal.util.GridUnsafe.run(GridUnsafe.java:1562) ~[ignite-core-2.12.0.jar!/:2.12.0]
... 44 common frames omitted
编辑,对于发现此问题的任何人,我在启动我的 spring 引导应用程序时错误地传递了 JVM 参数。一旦我修复了 InaccessibleObjectException 不再发生。
下面是我使用的参数列表:
--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
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
Ignite 尚不支持 Java 17。我不认为传入几个参数会有帮助。
无论如何,Ignition.start()
不会启动新的 JVM;它在当前 JVM 中启动一个节点。所以你需要将你的参数传递给你的SpringBoot应用程序。
最后的问题是我没有正确传递 jvm 参数。一旦我修复了应用程序与 Java 17 给出的上述参数一起工作。我想这些并不能保证我不会遇到其他障碍。
我可以通过在 ignite.sh 脚本中添加一些 JVM 参数来在 Java 17 上启动我的 Ignite 服务器,但是当我通过 Ignition.start 或 [=31 启动我的 Ignite 客户端时=]客户端我收到反射异常。
有没有办法:
- 提供在 Ignition.start 启动新的 jvm 进程时将给出的额外参数?
- 如果没有,是否可以通过 ignite.sh 创建 Ignite 客户端?
我知道这些问题可以通过使用 Java 11 来解决,但这不是一个选项。
下面是调用 Ignition.start
后得到的堆栈跟踪Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-28 18:50:34.518 ERROR 53868 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'igniteThinCacheManager': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean[=10=](AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar!/:5.3.15]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar!/:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar!/:2.6.3]
at com.niksun.myService.MyServiceApplication.main(MyServiceApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[myService-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.ExceptionInInitializerError: null
at org.apache.ignite.internal.util.IgniteUtils.<clinit>(IgniteUtils.java:865) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient$ClientMarshallerContext.<init>(TcpIgniteClient.java:542) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.<init>(TcpIgniteClient.java:114) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.<init>(TcpIgniteClient.java:102) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.client.thin.TcpIgniteClient.start(TcpIgniteClient.java:339) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.Ignition.startClient(Ignition.java:615) ~[ignite-core-2.12.0.jar!/:2.12.0]
at com.niksun.myService.cache.IgniteThinCacheManager.init(IgniteThinCacheManager.java:45) ~[classes!/:0.0.1-SNAPSHOT]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.15.jar!/:5.3.15]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.15.jar!/:5.3.15]
... 26 common frames omitted
Caused by: java.lang.RuntimeException: java.nio.DirectByteBuffer.address field is unavailable.
at org.apache.ignite.internal.util.GridUnsafe.run(GridUnsafe.java:1570) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.util.GridUnsafe.run(GridUnsafe.java:1557) ~[ignite-core-2.12.0.jar!/:2.12.0]
at java.base/java.security.AccessController.doPrivileged(Unknown Source) ~[na:na]
at org.apache.ignite.internal.util.GridUnsafe.bufferAddressOffset(GridUnsafe.java:1557) ~[ignite-core-2.12.0.jar!/:2.12.0]
at org.apache.ignite.internal.util.GridUnsafe.<clinit>(GridUnsafe.java:109) ~[ignite-core-2.12.0.jar!/:2.12.0]
... 40 common frames omitted
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 @27abe2cd
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Field.setAccessible(Unknown Source) ~[na:na]
at org.apache.ignite.internal.util.GridUnsafe.run(GridUnsafe.java:1562) ~[ignite-core-2.12.0.jar!/:2.12.0]
... 44 common frames omitted
编辑,对于发现此问题的任何人,我在启动我的 spring 引导应用程序时错误地传递了 JVM 参数。一旦我修复了 InaccessibleObjectException 不再发生。
下面是我使用的参数列表:
--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
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
Ignite 尚不支持 Java 17。我不认为传入几个参数会有帮助。
无论如何,Ignition.start()
不会启动新的 JVM;它在当前 JVM 中启动一个节点。所以你需要将你的参数传递给你的SpringBoot应用程序。
最后的问题是我没有正确传递 jvm 参数。一旦我修复了应用程序与 Java 17 给出的上述参数一起工作。我想这些并不能保证我不会遇到其他障碍。