InstanceAlreadyExistsException:jetbrains.exodus.entitystore:类型=EntityStoreConfig
InstanceAlreadyExistsException: jetbrains.exodus.entitystore: type=EntityStoreConfig
什么会导致抛出这个异常?
Caused by: javax.management.InstanceAlreadyExistsException: jetbrains.exodus.entitystore: type=EntityStoreConfig, location=/var/xodus/master, name=persistentEntityStore
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at com.sun.enterprise.v3.admin.DynamicInterceptor.registerMBean(DynamicInterceptor.java:393)
at jetbrains.exodus.management.MBeanBase.<init>(MBeanBase.java:36)
来自这段代码:
public PersistentEntityStore getPersistentEntityStore(String xodusRoot, String dir, boolean isReadOnly) {
if(persistentEntityStoreCache == null) {
persistentEntityStoreCache = buildPersistentEntityStoreCache();
}
PersistentEntityStore entityStore = persistentEntityStoreCache.get(xodusRoot + dir);
if (entityStore == null) {
Environment environment = getEnvironment(xodusRoot, dir);
entityStore = PersistentEntityStores.newInstance(environment); // <-- here
entityStore.getConfig().setDebugSearchForIncomingLinksOnDelete(true);
entityStore.getConfig().setRefactoringHeavyLinks(true);
entityStore.getConfig().setManagementEnabled(false);
PersistentEntityStore finalEntityStore = entityStore;
entityStore.executeInTransaction(
txn -> {
finalEntityStore.registerCustomPropertyType(
txn, EmbeddedEntityIterable.class, EmbeddedEntityBinding.BINDING);
finalEntityStore.registerCustomPropertyType(
txn, EmbeddedArrayIterable.class, EmbeddedEntityBinding.BINDING);
persistentEntityStoreCache.put(xodusRoot + dir, finalEntityStore);
});
}
PersistentEntityStore persistentEntityStore = persistentEntityStoreCache.get(xodusRoot + dir);
return persistentEntityStore;
}
记录为 Mutable at runtime: no
的所有设置在创建实例后均无法修改。至少,这样的修改没有效果。因此,您应该在创建 EntityStore 实例之前关闭管理,而不是之后:
Environment environment = getEnvironment(xodusRoot, dir);
PersistentEntityStoreConfig config = new PersistentEntityStoreConfig().setManagementEnabled(false);
entityStore = PersistentEntityStores.newInstance(environment, config, "your EntityStore name");
什么会导致抛出这个异常?
Caused by: javax.management.InstanceAlreadyExistsException: jetbrains.exodus.entitystore: type=EntityStoreConfig, location=/var/xodus/master, name=persistentEntityStore
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at com.sun.enterprise.v3.admin.DynamicInterceptor.registerMBean(DynamicInterceptor.java:393)
at jetbrains.exodus.management.MBeanBase.<init>(MBeanBase.java:36)
来自这段代码:
public PersistentEntityStore getPersistentEntityStore(String xodusRoot, String dir, boolean isReadOnly) {
if(persistentEntityStoreCache == null) {
persistentEntityStoreCache = buildPersistentEntityStoreCache();
}
PersistentEntityStore entityStore = persistentEntityStoreCache.get(xodusRoot + dir);
if (entityStore == null) {
Environment environment = getEnvironment(xodusRoot, dir);
entityStore = PersistentEntityStores.newInstance(environment); // <-- here
entityStore.getConfig().setDebugSearchForIncomingLinksOnDelete(true);
entityStore.getConfig().setRefactoringHeavyLinks(true);
entityStore.getConfig().setManagementEnabled(false);
PersistentEntityStore finalEntityStore = entityStore;
entityStore.executeInTransaction(
txn -> {
finalEntityStore.registerCustomPropertyType(
txn, EmbeddedEntityIterable.class, EmbeddedEntityBinding.BINDING);
finalEntityStore.registerCustomPropertyType(
txn, EmbeddedArrayIterable.class, EmbeddedEntityBinding.BINDING);
persistentEntityStoreCache.put(xodusRoot + dir, finalEntityStore);
});
}
PersistentEntityStore persistentEntityStore = persistentEntityStoreCache.get(xodusRoot + dir);
return persistentEntityStore;
}
记录为 Mutable at runtime: no
的所有设置在创建实例后均无法修改。至少,这样的修改没有效果。因此,您应该在创建 EntityStore 实例之前关闭管理,而不是之后:
Environment environment = getEnvironment(xodusRoot, dir);
PersistentEntityStoreConfig config = new PersistentEntityStoreConfig().setManagementEnabled(false);
entityStore = PersistentEntityStores.newInstance(environment, config, "your EntityStore name");