jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaun Barriball" <sbarr...@yahoo.co.uk>
Subject RE: Providing RMI access for a model 2 - shared deployment
Date Thu, 15 Feb 2007 14:48:23 GMT
Hi Zukka,
Your idea worked perfectly. I created a custom servlet which registers a
repository in RMI after first locating it in the global JNDI. The servlet is
setup to register the repository with "//localhost:1099/jcr".

We can then access the repository remotely via the JCR command line tool (in
contribs) by:

1) amending the jndi.properties with


2) starting the command line tool (run.bat)

3) executing "jndi jcr"

This enables the application to run quickly as a Model 2 shared resource,
but allow administration via other utilities.


PS> I'm happy to contribute the servlet code at some point if of use.

-----Original Message-----
From: Jukka Zitting [mailto:jukka.zitting@gmail.com] 
Sent: 15 February 2007 12:56
To: users@jackrabbit.apache.org
Subject: Re: Providing RMI access for a model 2 - shared deployment


On 2/15/07, Shaun Barriball <sbarriba@yahoo.co.uk> wrote:
> * However I expected/hoped that specifying an rmi-url with host and 
> port would result in the repository being exposed via RMI. This didn't
> Looking at the code for RepositoryAccessServlet it does not appear to 
> be capable of exposing a repository via RMI, unlike RepositoryStartup 
> which can. I'm guessing RepositoryAccessServlet  is only intended for 
> access, not for publishing?

Ah, you're right, my mistake.

> If this is the case, is it possible to get the RepositoryStartup to
>  * read from a JNDI name and publish via RMI, or
>  * initialise the repository and publish into the global JNDI spec for 
> other webapps AND via RMI. Perhaps I'm just looking for the right 
> combination of "java.naming.provider.url" and 
> "java.naming.factory.initial" values to emulate the settings on the Tomcat

The RepositoryStartup servlet always starts up the repository locally, but
you can instruct it to register the repository both in JNDI and RMI as in
your second option above. Unfortunately I don't think that Tomcat allows a
webapp to modify the global JNDI tree, so you'd need to use some other JNDI

An alternative approach would be to create a custom servlet class that looks
up the repository from JNDI and binds it in RMI directly.
Something like this:

    InitialContext context = new InitialContext();
    Context environment = (Context) context.lookup("java:comp/env");
    Repository repository = (Repository) environment.lookup("...");

    RemoteAdapterFactory factory = new ServerAdapterFactory();
    RemoteRepository remote = factory.getRemoteRepository(repository);
    Naming.bind("...", remote);

Just remember to keep a local reference to the remote repository adapter
within the servlet instance to avoid it from being garbage collected when no
clients are connected.


Jukka Zitting

Copy addresses and emails from any email account to Yahoo! Mail - quick, easy and free. http://uk.docs.yahoo.com/trueswitch2.html

View raw message