Hello! You need to obtain the running repository object and log in to that - the TransientRepository is a repository object in its own right, and can't share the underlying stored data with the running repository.
How you obtain the running repository depends on how the JCR repository is deployed - see http://jackrabbit.apache.org/deployment-models.html and http://jackrabbit.apache.org/standalone-server.html for more information. Typically if your repository is running in a web application environment, you'll need to configure and use JNDI to obtain the repository object in each Java application. On 8 February 2013 10:23, amin_nr2000 <[email protected]> wrote: > Hi! > > I have a running JCR. It's in use and creates/updates/removes content when > needed. > > I have another Java project where I need a direct access to the repository. > I try to connect by this code: > > Repository repository = new > TransientRepository("target/repository.xml", > "target/"); > Credentials myCredentials = new SimpleCredentials(userName, > password.toCharArray()); > try { > Session session = repository.login(myCredentials); > } catch (LoginException e) { > e.printStackTrace(); > } catch (RepositoryException e) { > e.printStackTrace(); > } > > I also changed the relative paths for ${rep.home} and ${wsp.home} in > repository.xml to absolute paths. > > It connects to the repository when the other project is not running and I > can access the content of the repository with no problem. But if I first > run > the code in 'target' it locks the repository and it's impossible to connect > to the same repository in 'target' from the second project. > > I even tried to remove the lock file .lock manually, but it didn't work. > > > > Can anyone help me? > > > Thanks > > > > -- > View this message in context: > http://jackrabbit.510166.n4.nabble.com/Multiple-accesses-to-a-repository-tp4657670.html > Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >
