5
votes

We have a REST layer and backend as Jackrabbit implementation. We have used TransientRepository with the default settings. When two requests (just for reading the nodes) are fired at the same time, we are facing with the following error :

:RepositoryLock.acquire(134)::Existing lock file {tomcat}/.lock detected. Repository was not shut down properly. javax.jcr.RepositoryException: The repository home {tomcat} appears to be in use since the file named .lock is already locked by the current process.

The jackrabbit wiki page : http://wiki.apache.org/jackrabbit/RepositoryLock mentions that this happens when the repository is already open in the same process but within another class loader (for example, in another web application). In this case you need to ensure that the repository is closed when the web-application is stopped.

We have used below code for getting repository and creating sessions :

try {
Repository repository = new TransientRepository(REPO_CONFIG_FILE, REPO_HOME_DIR); 
session = repository.login(new SimpleCredentials(REPOSITORY_USERNAME, REPOSITORY_PASSWORD.toCharArray()));
} finally { 
    if(session != null){
       session.logout();
    } 
}

The above code is for each of the operations of Jackrabbit, so the session gets closed after each operation. And there is only one web application which accesses that Jackrabbit repository.

The solution given on the RepositoryLock page suggests to use Repository Server. Is that the only solution here or I am missing something in the configuration or while coding?

1

1 Answers

1
votes

Maybe you should use the method

loggedOut(SessionImpl session) Removes the given session from the set of open sessions. which is specificto this repositiry or use a Repository Server in an application listener and have it accessible through JNDI so you could start / stop it cleanly ?