You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Patricio Echagüe <pa...@gmail.com> on 2009/10/15 20:57:10 UTC

Exposing(binding) a repository object through JNDI in Tomcat 6.

Hi all, I have a problem I cannot sort out.

I deployed the jackrabbit webapp in tomcat with MySQL according to the steps
in the wiki. (so far so good).
This webapp has a servlet called: RepositoryStartupServlet which I'm using
to bind the repository (created by it) to JNDI so that another webapp can do
a lookup, get the repo and use it.

After configuring ALL the parameters in tomcat to link the resource name
with the context, I get this exception when tomcat starts up:

Caused by: javax.naming.NameNotFoundException: Name jcr is not bound in this
Context
    at org.apache.naming.NamingContext.bind(NamingContext.java:843)
    at org.apache.naming.NamingContext.bind(NamingContext.java:171)
    at org.apache.naming.NamingContext.bind(NamingContext.java:187)
    at org.apache.naming.SelectorContext.bind(SelectorContext.java:171)
    at javax.naming.InitialContext.bind(Unknown Source)
    at
org.apache.jackrabbit.j2ee.RepositoryStartupServlet.registerJNDI(RepositoryStartupServlet.java:451)
    ... 29 more

As you can see there, the error is when the servlet executes the bind()
method. Apparently, the InitialContext is read correctly.

Does anyone has clue?
Basically, these are the configuration files I have set up:

*bootstrap.prop:*
  repository.config=C:/temp/jackrabbitTomcat/repository.xml
  repository.home=C:/temp/jackrabbitTomcat
  repository.name=jcr/local
  # RMI Settings
  rmi.enabled=true
  rmi.port=0
  rmi.host=localhost
  # If the URI is not specified, it's composed as follows:
  #rmi.uri=//${rmi.host}:${rmi.port}/${repository.name}

  # JNDI Settings
  # all properties starting with 'java.naming.' will go into the
  # environment of the initial context
  jndi.enabled=true
  # if the name is not specified, it's initialized with the repository.name
  jndi.name=jcr/local
  java.naming.provider.url=java:comp/env

META-INF -->* context.xml *(in my webapp)

<?xml version="1.0" encoding="UTF-8"?>

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

*Server.xml*

  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->

    <Resource name="jcr/local" auth="Container"
              type="javax.jcr.Repository"
              description="local repository"

factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory" />

     <!-- I tried with and without the factory attribute -->

  </GlobalNamingResources>


I have tried to create a simple String and do a lookup from another webapp
and it works fine. But in that case, tomcat is instantiating the object.
In my case, I want jackrabbit servlet to create the repository and bind it
to the JNDI context.

Note: I works fine with JBoss though


Thanks.

-- 
Patricio.-

Re: Exposing(binding) a repository object through JNDI in Tomcat 6.

Posted by Patricio Echagüe <pa...@gmail.com>.
Just to clarify, has anyone had some success at configuring a Repository
instance in JNDI with Tomcat 6 ?

This is the java doc:

     * A sample JNDI configuration inside a servlet container's
<code>server.xml</code>:
     * <pre>
     *   &lt;Resource
     *         name="jcr/repositoryname"
     *         auth="Container"
     *         type="org.apache.jackrabbit.jcr2spi.RepositoryImpl"
     *
factory="org.apache.jackrabbit.jcr2spi.RepositoryImpl$Factory"
     *
org.apache.jackrabbit.jcr2spi.RepositoryImpl.factory="<em>class name of
{@link ObjectFactory} for {@link RepositoryConfig} instances</em>"
     *         org.apache.jackrabbit.jcr2spi.RepositoryImpl.class="<em>class
name of {@link RepositoryConfig} implementation class</em>"
     *         <em>...additional properties passed to the {@link
ObjectFactory}...</em>
     *   /&gt;
     * </pre>

It looks like there is no factory for RepositoryConfig.
The closest I got was:

    <Resource name="jcr/local" auth="Container"
              description="local repository"
              type="org.apache.jackrabbit.jcr2spi.RepositoryImpl"
              factory="org.apache.jackrabbit.jcr2spi.RepositoryImpl$Factory"


org.apache.jackrabbit.jcr2spi.RepositoryImpl.factory="........<no factory
here>.........."

org.apache.jackrabbit.jcr2spi.RepositoryImpl.class="org.apache.jackrabbit.core.config.RepositoryConfig"
/>

Any clue?


2009/10/15 Patricio Echagüe <pa...@gmail.com>

> Hi all, I have a problem I cannot sort out.
>
> I deployed the jackrabbit webapp in tomcat with MySQL according to the
> steps in the wiki. (so far so good).
> This webapp has a servlet called: RepositoryStartupServlet which I'm using
> to bind the repository (created by it) to JNDI so that another webapp can do
> a lookup, get the repo and use it.
>
> After configuring ALL the parameters in tomcat to link the resource name
> with the context, I get this exception when tomcat starts up:
>
> Caused by: javax.naming.NameNotFoundException: Name jcr is not bound in
> this Context
>     at org.apache.naming.NamingContext.bind(NamingContext.java:843)
>     at org.apache.naming.NamingContext.bind(NamingContext.java:171)
>     at org.apache.naming.NamingContext.bind(NamingContext.java:187)
>     at org.apache.naming.SelectorContext.bind(SelectorContext.java:171)
>     at javax.naming.InitialContext.bind(Unknown Source)
>     at
> org.apache.jackrabbit.j2ee.RepositoryStartupServlet.registerJNDI(RepositoryStartupServlet.java:451)
>     ... 29 more
>
> As you can see there, the error is when the servlet executes the bind()
> method. Apparently, the InitialContext is read correctly.
>
> Does anyone has clue?
> Basically, these are the configuration files I have set up:
>
> *bootstrap.prop:*
>   repository.config=C:/temp/jackrabbitTomcat/repository.xml
>   repository.home=C:/temp/jackrabbitTomcat
>   repository.name=jcr/local
>   # RMI Settings
>   rmi.enabled=true
>   rmi.port=0
>   rmi.host=localhost
>   # If the URI is not specified, it's composed as follows:
>   #rmi.uri=//${rmi.host}:${rmi.port}/${repository.name}
>
>   # JNDI Settings
>   # all properties starting with 'java.naming.' will go into the
>   # environment of the initial context
>   jndi.enabled=true
>   # if the name is not specified, it's initialized with the
> repository.name
>   jndi.name=jcr/local
>   java.naming.provider.url=java:comp/env
>
> META-INF -->* context.xml *(in my webapp)
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <Context>
>   <ResourceLink name="jcr/local"  global="jcr/local"
> type="javax.jcr.Repository" />
> </Context>
>
> *Server.xml*
>
>   <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>
>     <Resource name="jcr/local" auth="Container"
>               type="javax.jcr.Repository"
>               description="local repository"
>
> factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory" />
>
>      <!-- I tried with and without the factory attribute -->
>
>   </GlobalNamingResources>
>
>
> I have tried to create a simple String and do a lookup from another webapp
> and it works fine. But in that case, tomcat is instantiating the object.
> In my case, I want jackrabbit servlet to create the repository and bind it
> to the JNDI context.
>
> Note: I works fine with JBoss though
>
>
> Thanks.
>
> --
> Patricio.-
>



-- 
Patricio.-