jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blanco Emanuele <e.bla...@reply.it>
Subject RE: accessing JCR over JNDI
Date Fri, 10 Oct 2008 13:05:48 GMT
I'm using Jboss 4.2, which uses JbossWeb to deploy web applications.

Anyway, there are some similar thing between Tomcat and JbossWeb and I tried the way you suggested
me, but I'm getting a naming not bound exception on jcr. The webapp I'm trying to modify is
written with SEAM and the component who initializes the repository is set with @Startup.

It seems strange that lots of people have no difficulties with it, maybe I'm missing something
but I really don’t know what.

-----Original Message-----
From: Aleksei Lukin [mailto:lukin@stu.cn.ua]
Sent: venerdì 10 ottobre 2008 14.00
To: users@jackrabbit.apache.org
Subject: Re: accessing JCR over JNDI

Friday 10 October 2008 12:57:28 Blanco Emanuele написав:

Well, first question is: how do you start JCR?  You need model 2 to be able to access JCR
from all deployed apps.
To do so you msut define global JNDI resource  in tomcat's config like this:
       JackRabbit content repository //
    <Resource configFilePath="/usr/local/jackrabbit-repo/repository.xml"
              name="jcr/globalRepository" repHomeDir="/usr/local/jackrabbit-repo"
              auth="Container" />


Thus Tomcat must have all libraries of JCR available. The simpliest way  is  just to put all
of it in ${tomcat_home}/lib

So tomcat will start JCR whet it starts.
Next step is configuration of web application. You must put following reference to global
repo into your context.xml

 <ResourceLink global="jcr/globalRepository" name="jcr/repository" type="javax.jcr.Repository"/>

After that ytou can obtain JNDI access to JCR with following code:

        BindableRepository jrepository = null;

        try {
            InitialContext context = new InitialContext();
            Context environment = (Context) context.lookup("java:comp/env");
            jrepository = (BindableRepository) environment.lookup("/jcr/repository");

 the best place for this code is
 public void contextInitialized(ServletContextEvent sce) method  of application listener.
Then you can bind repository to web application context and use in any place of your

SY, Alex Lukin

The information transmitted is intended for the person or entity to which it is addressed
and may contain confidential and/or privileged material. Any review, retransmission, dissemination
or other use of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received this in error, please
contact the sender and delete the material from any computer.
View raw message