jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: How can I get access to repository using multi-threading mechanism?
Date Tue, 12 Dec 2006 12:31:11 GMT
Hi,

On 12/12/06, Vitaliy Obmanjuk <vetalok@gmail.com> wrote:
> Can someone give me the answer to the question "How can I get access to
> repository using multi-threading mechanism?"
> If I run 1 thread I have no errors.
> If I run 2 threads I have:
> ==============
> javax.jcr.RepositoryException: The repository home at ....\bin\repository
> appears to be in use since the file at ....bin\repository\.lock is locked by
> another process.
> ==============
> What is the simplest way to do it (excluding RMI)?
> Can I configure my repository.xml for the 2 threads?
>
> The same code (login and add node) must be implemented by 2 threads.

The problem is that you try to run two concurrent Repository instances
on the same repository directory. Instead, you should instantiate the
Repository first before launching the threads, and login to the single
repository instance to get the Sessions used by the separate threads.
Like this:

    Repository repository = ...;
    new JCRThread(repository.login(...)).start();
    new JCRThread(repository.login(...)).start();

BR,

Jukka Zitting

Mime
View raw message