4 Replies Latest reply on Jun 8, 2006 2:08 PM by mmoales

    Binding objects in JNDI similar to Tomcat GlobalNamingResour

    mmoales

      I'm trying to bind a Jackrabbit repository in JNDI under JBoss (4.0.3SP1). In the Jackrabbit documentation, they describe how to do this under tomcat using the GlobalNamingResources/Resource tags in server.xml and ResourceLink tag in context.xml. This all works fine.

      Now I want to do the same thing under JBoss. I've tried modifying server.xml and context.xml in jbossweb-tomcat55.sar, but this doesn't appear to work. I've looked at using JNDIBindingServiceMgr, but I can't figure out how to use it for this type of binding.

      Anyway, here's the Resource entry from tomcat:

      <Resource name="jcr/globalRepository"
       auth="Container"
       type="javax.jcr.Repository"
       factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
       configFilePath="/path/to/repository.xml"
       repHomeDir="/path/to/repository"/>


      Here's the ResourceLink from tomcat:

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


      In my servlet on tomcat, I can then simply do the following to locate the repository:

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


      Can anyone shed some light on how to do this in JBoss?

      Thanks!

      Mark


        • 1. Re: Binding objects in JNDI similar to Tomcat GlobalNamingRe
          bwtaylor

          I have the same question/problem. It looks like jboss has switched off the catalina naming service and overridden naming configuration in server.xml and context.xml. It's easy enough to do these in web.xml and jboss-web.xml but since both of these are deployed with the WAR file, it doesn't look like there is any simple way to bind names into the java:comp/env context (ENC) using server configuration. If there is, I've missed it.

          I've done a work around using JNDIBindingServiceMgr, but these use global naming and component isolation to some extent. I don't quite understand why the GlobalNamingResources/Resource tags in server.xml and ResourceLink tag in context.xml would be turned off without providing some equivalent functionality.

          • 2. Re: Binding objects in JNDI similar to Tomcat GlobalNamingRe
            bwtaylor

            Whoops -- my 2nd pg 1st sentence should read "I've done a work around using JNDIBindingServiceMgr, but this uses global naming and **breaks** component isolation to some extent.

            • 3. Re: Binding objects in JNDI similar to Tomcat GlobalNamingRe
              dbevacqua

              Hi

              JBoss Day 1 and I'm trying to solve this same problem.

              bwtaylor, do you have the MBean definition you used to get the JNDIBindingServiceMgr to put a Jackrabbit repository in JNDI? I'm not really au fait with JBossXB - do I need to be?

              Your help would really be appreciated - I'm think in at the deep end here.

              Thanks in advance

              Dominic Bevacqua

              • 4. Re: Binding objects in JNDI similar to Tomcat GlobalNamingRe
                mmoales

                dbevacqua,

                There was a bug in Jackrabbit 1.0 that prevented using the org.apache.jackrabbit.core.jndi.RegistryHelper to properly register the repository with a JNDI server. This should be fixed in in Jackrabbit 1.0.1.

                So, instead of trying to register the repository using GlobalNamingResources, you can just call RegistryHelper.registerRepository method.

                You can have a look at the Jackrabbit bug here:

                http://issues.apache.org/jira/browse/JCR-411?page=comments#action_12413403

                Mark