InstanceAlreadyExistsException: jetbrains.exodus.entitystore: type=EntityStoreConfig

huangapple go评论78阅读模式
英文:

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); // &lt;-- 这里
        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;
}
英文:

What would cause this exception to be thrown?

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.&lt;init&gt;(MBeanBase.java:36)

From this code:

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); // &lt;-- here
   entityStore.getConfig().setDebugSearchForIncomingLinksOnDelete(true);
          entityStore.getConfig().setRefactoringHeavyLinks(true);
          entityStore.getConfig().setManagementEnabled(false);
          PersistentEntityStore finalEntityStore = entityStore;
          entityStore.executeInTransaction(
                  txn -&gt; {
                    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;
      }

答案1

得分: 1

所有在文档中标记为“运行时不可变:否”的设置在实例创建后无法修改。至少,这样的修改没有任何效果。因此,在创建EntityStore实例之前,您应该关闭管理,而不是之后:

Environment environment = getEnvironment(xodusRoot, dir);
PersistentEntityStoreConfig config = new PersistentEntityStoreConfig().setManagementEnabled(false);
entityStore = PersistentEntityStores.newInstance(environment, config, "您的EntityStore名称");
英文:

All settings that are documented as Mutable at runtime: no cannot be modified after instance is created. At least, such modifications have no effect. So you should turn management off before creation of the EntityStore instance, not after:

Environment environment = getEnvironment(xodusRoot, dir);
PersistentEntityStoreConfig config = new PersistentEntityStoreConfig().setManagementEnabled(false);
entityStore = PersistentEntityStores.newInstance(environment, config, &quot;your EntityStore name&quot;);

huangapple
  • 本文由 发表于 2020年9月19日 13:13:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/63965457.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定