jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francisco Carriedo Scher <fcarrie...@gmail.com>
Subject Obtaining the running repository through JNDI
Date Mon, 01 Aug 2011 16:39:33 GMT
Hi there,

i have a JR repository up and running and now i want to obtain the (already
running) repository instance through JNDI to use it through simple Java
classes in other projects. By default the repository is available through
JNDI only locally to the webapp, which is not enough for my case.

Now, i followed the instructions to turn it globally available (even simple
Java applications running out of the Tomcat 7 server i am using) without
success. Note that I followed the Tomcat 7 instructions to enable JNDI
resources aswell.

I paste here the relevant pieces of code for this issue:
Context.xml (Tomcat 7 server)*

     <Resource name="repositoryname" auth="Container"


Web.xml (Web application)

        <description>Object Factory for the Repository</description>


# Repository configuration settings (will be adjusted by installer)


# RMI Settings
# If the URI is not specified, it's composed as follows:

# JNDI Settings
# all properties starting with 'java.naming.' will go into the
# environment of the initial context
# if the name is not specified, it's initialized with the repository.name

*Plain Java class trying to obtain the Repository object through JNDI*

Hashtable env = new Hashtable();
        env.put(Context.PROVIDER_URL, "jnp://localhost:1099");

        Context initCtx = new InitialContext(env);
        Context envCtx = (Context) initCtx.lookup("java:comp/env");
        Repository repo = (Repository) envCtx.lookup("repositoryname");

Any clue on how to detect what is going wrong (object not registered in JNDI
directory, object not correctly requested, initial misconfigured

By the way, i assume that the retrieved object will be the initialized
instance created as the JR webapp is fired up, isn't it?

Thanks in advance for your attention!

P.S.: for those who paid attention to my previous emails to this list: the
answer is comming, it is not trivial to write, so it will still take a
little bit, but will come because i find my case helpfull for other newbies.
I thank you all once more!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message