我创建了 StorageService 类对象,如下所示
StorageService service=new StorageService();
当此指令遇到以下异常时,已抛出异常。
java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: org.apache.cassandra.db:type=StorageService
at org.apache.cassandra.service.StorageService.<init>(StorageService.java:233)
at com.exterro.edrm.restore.EmbeddedService.main(EmbeddedService.java:144)
Caused by: javax.management.InstanceAlreadyExistsException: org.apache.cassandra.db:type=StorageService
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
at org.apache.cassandra.service.StorageService.<init>(StorageService.java:229)
... 1 more
我应该添加或更改什么以避免此异常?
创建此 StorageService 类对象后,我必须调用startRPCServer()
以启动 cassandra 服务以及注册 MBean 以在 java 代码中以编程方式使用 nodetool 实用程序。