You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by vikas bhatia <vi...@gmail.com> on 2006/05/12 00:10:25 UTC

repository login

I am trying to understand how to access a jackrabbit repository from another
process.

I have the jackrabbit server running in a webapp. this creates a .lock file.

now when i try to connect to this repository from another java process, i
get this message The repository home at c:\jackrabbit\repository appears to
be in use since the file at c:\jackrabbit\repository\.lock is locked by
another process. its failing at
RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
REPO_HOME_DIR, true);

and error at org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
(RepositoryImpl.java:322)

now according to
http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706,
i need to get a handle on this repository from jndi or rmi registry. is
there any example that explains how to do this or a tip would be helpful.

regards.

vikas.

Re: repository login

Posted by Ramesh Anand <ra...@gmail.com>.
I suggest  not to use the repository helper class.
1. Use this code to create repository,

RepositoryConfig config = RepositoryConfig.create(propStream, DIRECTORY);
Repository repository = RepositoryImpl.create(config);

2. Bind the repository with the app server's JNDI tree. not with
org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory.Because
this implementation is just a dummy JNDI and it will not be your app
server's jndi.

3. Now, from your client, lookup the jndi for repository instence.			

Also webservice or session bean or XML-Over-HTTP will be the better
solutions to expose any service.

Thanks
SRA


On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
> A follow up. Please bear with the noob
>
> I think what I am trying to do here is implement model 3 deployment. Is JNDI
> an option for me here, because wont the JNDI registries on the 2 JVMs be
> different?
>
> So, the options that I could use is implement RMI or design webservices or
> use the included WEBDAV interfaces.
>
> Please confirm.
>
> vikas.
>
> On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
> >
> > Hi,
> >
> > Thanks for the reply. I am thinking by option 1 you mean, using
> > webservices.
> >
> > I am trying to use option 2 as in the code below
> > ---
> > if (ctx == null) {
> >             Hashtable environment = new Hashtable();
> >             environment
> >                     .put(Context.INITIAL_CONTEXT_FACTORY,
> >                             "
> > org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
> >             environment.put (Context.PROVIDER_URL, "localhost");
> >             ctx = new InitialContext(environment);
> >
> >             RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> >                     REPO_HOME_DIR, true);
> >         }
> >         Repository r = (Repository) ctx.lookup(REPO_NAME);
> > ----
> > This is from the http://www.artima.com/lejava/articles/contentrepositoryP.html
> > example. And I am using the jackrabbit server as my webapp.
> >
> > I know that the repository is being found, but the lock does not allow it
> > to connect. The code hiccups at RegistryHelper.registerRepository....
> >
> > What am I missing here.
> >
> > thanks for the help.
> >
> >
> >
> >
> > On 5/11/06, Ramesh Anand < ramesh.anand@gmail.com> wrote:
> > >
> > > Hi Vikas,
> > > To my knowledge, at any point of time the Repository home has to be
> > > associated with one active repository instance. you may need to
> > > shutdown the  webapp project in order to run another application that
> > > uses the same home directory.
> > >
> > > If you want to run two different application to use the same
> > > repository instance,
> > > you can,
> > >    1. run the repository as a separate project and expose the service
> > > methods.
> > >    2. look up the RepositoryImpl JNDI from different application
> > >
> > > Hope the above information is helpful.
> > > Thanks
> > > SRA
> > >
> > >
> > > On 5/11/06, vikas bhatia < vik002@gmail.com > wrote:
> > > > I am trying to understand how to access a jackrabbit repository from
> > > another
> > > > process.
> > > >
> > > > I have the jackrabbit server running in a webapp. this creates a .lock
> > > file.
> > > >
> > > > now when i try to connect to this repository from another java
> > > process, i
> > > > get this message The repository home at c:\jackrabbit\repository
> > > appears to
> > > > be in use since the file at c:\jackrabbit\repository\.lock is locked
> > > by
> > > > another process. its failing at
> > > > RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> > > > REPO_HOME_DIR, true);
> > > >
> > > > and error at
> > > org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
> > > > (RepositoryImpl.java:322)
> > > >
> > > > now according to
> > > > http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706
> > > ,
> > > > i need to get a handle on this repository from jndi or rmi registry.
> > > is
> > > > there any example that explains how to do this or a tip would be
> > > helpful.
> > > >
> > > > regards.
> > > >
> > > > vikas.
> > > >
> > > >
> > >
> >
> >
>
>

Re: repository login

Posted by vikas bhatia <vi...@gmail.com>.
This worked

---
    private static Repository getRepository() throws NamingException,
            RepositoryException {
        String name = "//localhost:1099/jackrabbit.repository";
//make sure that rmi is enabled in webapp web.xml
    ClientRepositoryFactory factory = new ClientRepositoryFactory();
    Repository repository = null;
        try {
            repository = factory.getRepository(name);
        } catch (ClassCastException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (NotBoundException e) {
            e.printStackTrace();
        }
    return repository;
    }
---
thanks for the help.

vikas.

On 5/12/06, Stefan Guggisberg <st...@gmail.com> wrote:
>
> On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
> > A follow up. Please bear with the noob
> >
> > I think what I am trying to do here is implement model 3 deployment. Is
> JNDI
> > an option for me here, because wont the JNDI registries on the 2 JVMs be
> > different?
> >
> > So, the options that I could use is implement RMI or design webservices
> or
> > use the included WEBDAV interfaces.
>
> the jcr-rmi subproject in jackrabbit is probably what your looking for.
>
> cheers
> stefan
>
> >
> > Please confirm.
> >
> > vikas.
> >
> > On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
> > >
> > > Hi,
> > >
> > > Thanks for the reply. I am thinking by option 1 you mean, using
> > > webservices.
> > >
> > > I am trying to use option 2 as in the code below
> > > ---
> > > if (ctx == null) {
> > >             Hashtable environment = new Hashtable();
> > >             environment
> > >                     .put(Context.INITIAL_CONTEXT_FACTORY,
> > >                             "
> > > org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
> > >             environment.put (Context.PROVIDER_URL, "localhost");
> > >             ctx = new InitialContext(environment);
> > >
> > >             RegistryHelper.registerRepository(ctx, REPO_NAME,
> CONFIG_FILE,
> > >                     REPO_HOME_DIR, true);
> > >         }
> > >         Repository r = (Repository) ctx.lookup(REPO_NAME);
> > > ----
> > > This is from the
> http://www.artima.com/lejava/articles/contentrepositoryP.html
> > > example. And I am using the jackrabbit server as my webapp.
> > >
> > > I know that the repository is being found, but the lock does not allow
> it
> > > to connect. The code hiccups at RegistryHelper.registerRepository....
> > >
> > > What am I missing here.
> > >
> > > thanks for the help.
> > >
> > >
> > >
> > >
> > > On 5/11/06, Ramesh Anand < ramesh.anand@gmail.com> wrote:
> > > >
> > > > Hi Vikas,
> > > > To my knowledge, at any point of time the Repository home has to be
> > > > associated with one active repository instance. you may need to
> > > > shutdown the  webapp project in order to run another application
> that
> > > > uses the same home directory.
> > > >
> > > > If you want to run two different application to use the same
> > > > repository instance,
> > > > you can,
> > > >    1. run the repository as a separate project and expose the
> service
> > > > methods.
> > > >    2. look up the RepositoryImpl JNDI from different application
> > > >
> > > > Hope the above information is helpful.
> > > > Thanks
> > > > SRA
> > > >
> > > >
> > > > On 5/11/06, vikas bhatia < vik002@gmail.com > wrote:
> > > > > I am trying to understand how to access a jackrabbit repository
> from
> > > > another
> > > > > process.
> > > > >
> > > > > I have the jackrabbit server running in a webapp. this creates a
> .lock
> > > > file.
> > > > >
> > > > > now when i try to connect to this repository from another java
> > > > process, i
> > > > > get this message The repository home at c:\jackrabbit\repository
> > > > appears to
> > > > > be in use since the file at c:\jackrabbit\repository\.lock is
> locked
> > > > by
> > > > > another process. its failing at
> > > > > RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> > > > > REPO_HOME_DIR, true);
> > > > >
> > > > > and error at
> > > > org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
> > > > > (RepositoryImpl.java:322)
> > > > >
> > > > > now according to
> > > > >
> http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706
> > > > ,
> > > > > i need to get a handle on this repository from jndi or rmi
> registry.
> > > > is
> > > > > there any example that explains how to do this or a tip would be
> > > > helpful.
> > > > >
> > > > > regards.
> > > > >
> > > > > vikas.
> > > > >
> > > > >
> > > >
> > >
> > >
> >
> >
>

Re: repository login

Posted by Stefan Guggisberg <st...@gmail.com>.
On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
> A follow up. Please bear with the noob
>
> I think what I am trying to do here is implement model 3 deployment. Is JNDI
> an option for me here, because wont the JNDI registries on the 2 JVMs be
> different?
>
> So, the options that I could use is implement RMI or design webservices or
> use the included WEBDAV interfaces.

the jcr-rmi subproject in jackrabbit is probably what your looking for.

cheers
stefan

>
> Please confirm.
>
> vikas.
>
> On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
> >
> > Hi,
> >
> > Thanks for the reply. I am thinking by option 1 you mean, using
> > webservices.
> >
> > I am trying to use option 2 as in the code below
> > ---
> > if (ctx == null) {
> >             Hashtable environment = new Hashtable();
> >             environment
> >                     .put(Context.INITIAL_CONTEXT_FACTORY,
> >                             "
> > org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
> >             environment.put (Context.PROVIDER_URL, "localhost");
> >             ctx = new InitialContext(environment);
> >
> >             RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> >                     REPO_HOME_DIR, true);
> >         }
> >         Repository r = (Repository) ctx.lookup(REPO_NAME);
> > ----
> > This is from the http://www.artima.com/lejava/articles/contentrepositoryP.html
> > example. And I am using the jackrabbit server as my webapp.
> >
> > I know that the repository is being found, but the lock does not allow it
> > to connect. The code hiccups at RegistryHelper.registerRepository....
> >
> > What am I missing here.
> >
> > thanks for the help.
> >
> >
> >
> >
> > On 5/11/06, Ramesh Anand < ramesh.anand@gmail.com> wrote:
> > >
> > > Hi Vikas,
> > > To my knowledge, at any point of time the Repository home has to be
> > > associated with one active repository instance. you may need to
> > > shutdown the  webapp project in order to run another application that
> > > uses the same home directory.
> > >
> > > If you want to run two different application to use the same
> > > repository instance,
> > > you can,
> > >    1. run the repository as a separate project and expose the service
> > > methods.
> > >    2. look up the RepositoryImpl JNDI from different application
> > >
> > > Hope the above information is helpful.
> > > Thanks
> > > SRA
> > >
> > >
> > > On 5/11/06, vikas bhatia < vik002@gmail.com > wrote:
> > > > I am trying to understand how to access a jackrabbit repository from
> > > another
> > > > process.
> > > >
> > > > I have the jackrabbit server running in a webapp. this creates a .lock
> > > file.
> > > >
> > > > now when i try to connect to this repository from another java
> > > process, i
> > > > get this message The repository home at c:\jackrabbit\repository
> > > appears to
> > > > be in use since the file at c:\jackrabbit\repository\.lock is locked
> > > by
> > > > another process. its failing at
> > > > RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> > > > REPO_HOME_DIR, true);
> > > >
> > > > and error at
> > > org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
> > > > (RepositoryImpl.java:322)
> > > >
> > > > now according to
> > > > http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706
> > > ,
> > > > i need to get a handle on this repository from jndi or rmi registry.
> > > is
> > > > there any example that explains how to do this or a tip would be
> > > helpful.
> > > >
> > > > regards.
> > > >
> > > > vikas.
> > > >
> > > >
> > >
> >
> >
>
>

Re: repository login

Posted by vikas bhatia <vi...@gmail.com>.
A follow up. Please bear with the noob

I think what I am trying to do here is implement model 3 deployment. Is JNDI
an option for me here, because wont the JNDI registries on the 2 JVMs be
different?

So, the options that I could use is implement RMI or design webservices or
use the included WEBDAV interfaces.

Please confirm.

vikas.

On 5/12/06, vikas bhatia <vi...@gmail.com> wrote:
>
> Hi,
>
> Thanks for the reply. I am thinking by option 1 you mean, using
> webservices.
>
> I am trying to use option 2 as in the code below
> ---
> if (ctx == null) {
>             Hashtable environment = new Hashtable();
>             environment
>                     .put(Context.INITIAL_CONTEXT_FACTORY,
>                             "
> org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
>             environment.put (Context.PROVIDER_URL, "localhost");
>             ctx = new InitialContext(environment);
>
>             RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
>                     REPO_HOME_DIR, true);
>         }
>         Repository r = (Repository) ctx.lookup(REPO_NAME);
> ----
> This is from the http://www.artima.com/lejava/articles/contentrepositoryP.html
> example. And I am using the jackrabbit server as my webapp.
>
> I know that the repository is being found, but the lock does not allow it
> to connect. The code hiccups at RegistryHelper.registerRepository....
>
> What am I missing here.
>
> thanks for the help.
>
>
>
>
> On 5/11/06, Ramesh Anand < ramesh.anand@gmail.com> wrote:
> >
> > Hi Vikas,
> > To my knowledge, at any point of time the Repository home has to be
> > associated with one active repository instance. you may need to
> > shutdown the  webapp project in order to run another application that
> > uses the same home directory.
> >
> > If you want to run two different application to use the same
> > repository instance,
> > you can,
> >    1. run the repository as a separate project and expose the service
> > methods.
> >    2. look up the RepositoryImpl JNDI from different application
> >
> > Hope the above information is helpful.
> > Thanks
> > SRA
> >
> >
> > On 5/11/06, vikas bhatia < vik002@gmail.com > wrote:
> > > I am trying to understand how to access a jackrabbit repository from
> > another
> > > process.
> > >
> > > I have the jackrabbit server running in a webapp. this creates a .lock
> > file.
> > >
> > > now when i try to connect to this repository from another java
> > process, i
> > > get this message The repository home at c:\jackrabbit\repository
> > appears to
> > > be in use since the file at c:\jackrabbit\repository\.lock is locked
> > by
> > > another process. its failing at
> > > RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> > > REPO_HOME_DIR, true);
> > >
> > > and error at
> > org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
> > > (RepositoryImpl.java:322)
> > >
> > > now according to
> > > http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706
> > ,
> > > i need to get a handle on this repository from jndi or rmi registry.
> > is
> > > there any example that explains how to do this or a tip would be
> > helpful.
> > >
> > > regards.
> > >
> > > vikas.
> > >
> > >
> >
>
>

Re: repository login

Posted by vikas bhatia <vi...@gmail.com>.
Hi,

Thanks for the reply. I am thinking by option 1 you mean, using webservices.

I am trying to use option 2 as in the code below
---
if (ctx == null) {
            Hashtable environment = new Hashtable();
            environment
                    .put(Context.INITIAL_CONTEXT_FACTORY,
                            "
org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
            environment.put(Context.PROVIDER_URL, "localhost");
            ctx = new InitialContext(environment);
            RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
                    REPO_HOME_DIR, true);
        }
        Repository r = (Repository) ctx.lookup(REPO_NAME);
----
This is from the
http://www.artima.com/lejava/articles/contentrepositoryP.html example. And I
am using the jackrabbit server as my webapp.

I know that the repository is being found, but the lock does not allow it to
connect. The code hiccups at RegistryHelper.registerRepository....

What am I missing here.

thanks for the help.



On 5/11/06, Ramesh Anand <ra...@gmail.com> wrote:
>
> Hi Vikas,
> To my knowledge, at any point of time the Repository home has to be
> associated with one active repository instance. you may need to
> shutdown the  webapp project in order to run another application that
> uses the same home directory.
>
> If you want to run two different application to use the same
> repository instance,
> you can,
>    1. run the repository as a separate project and expose the service
> methods.
>    2. look up the RepositoryImpl JNDI from different application
>
> Hope the above information is helpful.
> Thanks
> SRA
>
>
> On 5/11/06, vikas bhatia <vik002@gmail.com > wrote:
> > I am trying to understand how to access a jackrabbit repository from
> another
> > process.
> >
> > I have the jackrabbit server running in a webapp. this creates a .lock
> file.
> >
> > now when i try to connect to this repository from another java process,
> i
> > get this message The repository home at c:\jackrabbit\repository appears
> to
> > be in use since the file at c:\jackrabbit\repository\.lock is locked by
> > another process. its failing at
> > RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> > REPO_HOME_DIR, true);
> >
> > and error at
> org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
> > (RepositoryImpl.java:322)
> >
> > now according to
> > http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706
> ,
> > i need to get a handle on this repository from jndi or rmi registry. is
> > there any example that explains how to do this or a tip would be
> helpful.
> >
> > regards.
> >
> > vikas.
> >
> >
>

Re: repository login

Posted by Ramesh Anand <ra...@gmail.com>.
Hi Vikas,
To my knowledge, at any point of time the Repository home has to be
associated with one active repository instance. you may need to
shutdown the  webapp project in order to run another application that
uses the same home directory.

If you want to run two different application to use the same
repository instance,
you can,
   1. run the repository as a separate project and expose the service methods.
   2. look up the RepositoryImpl JNDI from different application

Hope the above information is helpful.
Thanks
SRA


On 5/11/06, vikas bhatia <vi...@gmail.com> wrote:
> I am trying to understand how to access a jackrabbit repository from another
> process.
>
> I have the jackrabbit server running in a webapp. this creates a .lock file.
>
> now when i try to connect to this repository from another java process, i
> get this message The repository home at c:\jackrabbit\repository appears to
> be in use since the file at c:\jackrabbit\repository\.lock is locked by
> another process. its failing at
> RegistryHelper.registerRepository(ctx, REPO_NAME, CONFIG_FILE,
> REPO_HOME_DIR, true);
>
> and error at org.apache.jackrabbit.core.RepositoryImpl.acquireRepositoryLock
> (RepositoryImpl.java:322)
>
> now according to
> http://thread.gmane.org/gmane.comp.apache.jackrabbit.devel/4702/focus=4706,
> i need to get a handle on this repository from jndi or rmi registry. is
> there any example that explains how to do this or a tip would be helpful.
>
> regards.
>
> vikas.
>
>