sesameopenrdf

What are possible causes of Multiple ID-statement Exception in Sesame?


I would like to know what are possible causes that can rise the following Exception ?

org.openrdf.repository.config.RepositoryConfigException: Multiple ID-statements for repository ID test_3

It rises when i try to query the test_3 repository. Another fact is that after that there is two repository with the same name displayed in my web page http://localhost:8080/openrdf-workbench/repositories/NONE/repositories

any help is welcome !

EDIT

I'm using Sesame 2.7.7

EDIT 2

Providing more details about the code which cause the Exception

code

public void connectToRepository(){

    RepositoryConnection connection;

    RemoteRepositoryManager repositoryManager = new RemoteRepositoryManager("http://localhost:8080/openrdf-sesame/"); 

    try {

        repositoryManager.initialize();

        SailImplConfig backendConfig = new NativeStoreConfig("spoc,sopc,posc,psoc,ospc,opsc");

        RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(backendConfig);

        RepositoryConfig repConfig = new RepositoryConfig(repositoryID, repositoryTypeSpec);

        repositoryManager.addRepositoryConfig(repConfig);

        Repository myRepository = repositoryManager.getRepository(repositoryID);

        myRepository.initialize();

        connection = myRepository.getConnection();

    } 

    catch (RepositoryException | RepositoryConfigException e) {
        e.printStackTrace();
    }
}

The Exception is cause by the following line in the code:

repositoryManager.addRepositoryConfig(repConfig);

Here are details

log4j:WARN No appenders could be found for logger (org.openrdf.rio.DatatypeHandlerRegistry).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Custom NTriples/NQuads Parser
Custom NTriples/NQuads Parser
org.openrdf.repository.config.RepositoryConfigException: Multiple ID-statements for repository ID 10m7_m
at org.openrdf.repository.config.RepositoryConfigUtil.getIDStatement(RepositoryConfigUtil.java:269)
at org.openrdf.repository.config.RepositoryConfigUtil.hasRepositoryConfig(RepositoryConfigUtil.java:91)
at org.openrdf.repository.manager.RemoteRepositoryManager.createRepository(RemoteRepositoryManager.java:174)
at org.openrdf.repository.manager.RepositoryManager.getRepository(RepositoryManager.java:376)
at soctrace.repositories.OLDSesameRepositoryManagement.connectToRepository(OLDSesameRepositoryManagement.java:123)
at soctrace.repositories.OLDSesameRepositoryManagement.queryInRepository(OLDSesameRepositoryManagement.java:150)
at soctrace.views.Main.main(Main.java:692)
[sesame in memory] connection to repository 10m7_m done , 444, ms
Exception in thread "main" java.lang.NullPointerException
at soctrace.repositories.OLDSesameRepositoryManagement.runQuery(OLDSesameRepositoryManagement.java:250)
at soctrace.repositories.OLDSesameRepositoryManagement.queryInRepository(OLDSesameRepositoryManagement.java:155)
at soctrace.views.Main.main(Main.java:692) 

Solution

  • Your code creates a new repository (by adding a new repository configuration to the repository manager) every time you execute the connectToRepository() method. Since you use the exact same repository configuration (including the actual id of the repository) every time, naturally this causes an error the second time you execute it: you are trying to add a repository with an id that already exists.

    You should rewrite your code to make sure that it only tries to create the repository when a repository with that id doesn't exist yet - if it already exists, it should just use the existing one.