Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法打开只读环境_Java_Database_Xodus - Fatal编程技术网

Java 无法打开只读环境

Java 无法打开只读环境,java,database,xodus,Java,Database,Xodus,我正在尝试使用以下内容打开只读环境: public Environment getReadOnlyEnvironment(String xodusRoot, String instance) { final EnvironmentConfig config = new EnvironmentConfig(). setLogDataReaderWriterProvider("jetbrains.exodus.io.WatchingFileDataRea

我正在尝试使用以下内容打开只读环境:

  public Environment getReadOnlyEnvironment(String xodusRoot, String instance) {
    final EnvironmentConfig config = new EnvironmentConfig().
            setLogDataReaderWriterProvider("jetbrains.exodus.io.WatchingFileDataReaderWriterProvider").
            setLogCacheShared(false).
            setMemoryUsagePercentage(10);
    config.setLogLockTimeout(3000);
    Environment env = Environments.newInstance(xodusRoot + instance, config);
    return env;
  }
问题是它不断抛出这个错误:

Caused by: javax.management.InstanceAlreadyExistsException: jetbrains.exodus.env: type=EnvironmentConfig, location=\var\xodus\master
    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 jetbrains.exodus.management.MBeanBase.<init>(MBeanBase.java:36)
原因:javax.management.instancealreadyexistException:jetbrains.exodus.env:type=EnvironmentConfig,location=\var\xodus\master
位于com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
位于com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
位于com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966)
位于com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900)
位于com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324)
位于com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
在jetbrains.exodus.management.MBeanBase.(MBeanBase.java:36)

我认为这是一个。要解决此问题,请关闭管理:
EnvironmentConfig.setManagementEnabled(false)

错误消失了,但数据库运行不正常,如果根本无法获取数据,则获取的数据不一致。深入研究后,我想我发现了问题,似乎您无法创建两个
环境
s(意思是
newInstance
将抛出)一个具有写访问权限,另一个同时具有只读访问权限。因此,这违背了只读环境的目的。我猜这与此有关:我将再次检查并返回接受此帖子(如果是)。