jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kamil Nezval" <kamil.nez...@xitee.com>
Subject Re: Client access via JNDI to Jackrabbit Web Application
Date Tue, 05 Apr 2011 16:04:46 GMT
Hi,

I've got the same problem as posted in this mailing list a couple of years
ago (the conversation below my email), but unfortunately I have not found
the solution so far. I'm using Tomcat version 6.0. and Jackrabbit 2.2.5.

My goal is to deploy a Jackrabbit-webapp together with my own servlet and
share the repository resource (initialized by jackrabbit-webapp) via JNDI. A
short description is available when the webbapp is deployed
(http://localhost:8080/jackrabbit-webapp-2.2.5/local.jsp):

"By default the repository is only made available in a dummy JNDI directory
local to this web application. However, you can make the repository globally
available if your servlet container allows a web application to modify the
global JNDI directory or you are using some other JNDI directory that can
manage unserializable Java objects.

To bind the the repository to such a JNDI directory, you need to modify the
java.naming parameters in either the /WEB-INF/web.xml deployment descriptor
or the jackrabbit/bootstrap.properties file. You need to redeploy this web
application to activate the changes."

I did all the steps but still get this error when I try to lookup the
repository:

javax.servlet.ServletException: javax.naming.NamingException: Cannot create
resource instance
	
de.ee.escriba.jackrabbit.test.JackrabbitTestServlet.doGet(JackrabbitTestServ
let.java:117)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

According to the tomcat's log file the repository is bound:

17:43:03.296 [main] INFO  o.a.jackrabbit.j2ee.AbstractConfig -   jndiName:
jackrabbit.repository
17:43:03.296 [main] INFO  o.a.jackrabbit.j2ee.AbstractConfig -
jndiEnabled: true
17:43:03.296 [main] INFO  o.a.jackrabbit.j2ee.AbstractConfig -   class:
class org.apache.jackrabbit.j2ee.JNDIConfig
17:43:03.296 [main] INFO  o.a.jackrabbit.j2ee.AbstractConfig -   jndiEnv:
{java.naming.provider.url=http://www.apache.org/jackrabbit,
java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyIn
itialContextFactory}
...
17:43:10.656 [main] INFO  o.a.j.j2ee.RepositoryStartupServlet - Repository
bound to JNDI with name: jackrabbit.repository


This is my configuration:

1. bootstrap.properties
# Repository configuration settings (will be adjusted by installer)
repository.config=c:/work/escriba/jackrabbit/conf/repository.xml
repository.home=c:/work/escriba/jackrabbit/repository
repository.name=jackrabbit.repository

# RMI Settings
rmi.enabled=false
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=jackrabbit.repository
java.naming.provider.url=http://www.apache.org/jackrabbit
java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyIn
itialContextFactory

2. my client's web.xml contains
<resource-ref>
    <description>JCR Repository</description>
    <res-ref-name>jackrabbit.repository</res-ref-name>
    <res-type>javax.jcr.Repository</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

3. I also moved all jar files from webapp to $tomcat_home/lib

It looks like that something in the configuration is still missing (in
server.xml?).

I've also tried to put these lines into context.xml:
    <Resource name="jackrabbit.repository" scope="Shareable"
type="javax.jcr.Repository"/>
    <ResourceParams name="jackrabbit.repository">
        <parameter>
            <name>factory</name>
 
<value>org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory</
value>
        </parameter>
    </ResourceParams>

but nothing has changed.

When I use a shared context everything works properly. But not via JNDI...

Thanks in advance for any help.

Regards


Kamil







Re: Client access via JNDI to Jackrabbit Web Application

Douglas José
Wed, 24 Sep 2008 05:37:43 -0700

Hello, Ken,

Are you trying to access the repository from another web application? If so,
make sure you declared the resource in your web.xml file:

  <resource-ref>
    <description>JCR Repository</description>
    <res-ref-name>jcr/repository</res-ref-name>
    <res-type>javax.jcr.Repository</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

then the client code:

        InitialContext ctx = new InitialContext();
        Context env = (Context) ctx.lookup("java:comp/env");
        Repository repo = (Repository) env.lookup("jcr/repository");
        return repo.login(new SimpleCredentials("admin", "".toCharArray()));

FYI: The code snippets were copied from my working webapp running on Tomcat.
I assume it should work with Tomcat without any changes.

Good luck,

Douglas

On Sat, Sep 6, 2008 at 11:25 PM, kenclark <[EMAIL PROTECTED]> wrote:

>
>
> I changed the code to this:
>
>                InitialContext ctx = new InitialContext() ;
>                Repository repo = (Repository)
> ctx.lookup("java:jackrabbit");
> // ...
>
> And get the message:
>
> javax.naming.NameNotFoundException: jackrabbit not bound
>
> I also tried: Repository repo = (Repository) ctx.lookup("jackrabbit");
> which resulted in the same error.
>
> Here is the relevant part of my bootstrap.properties:
>
>
> # Repository configuration settings (will be adjusted by installer)
> repository.config=e:/jackrabbit/repository.xml
> repository.home=e:/jackrabbit
> repository.name=jackrabbit.repository
>
> # RMI Settings
> rmi.enabled=true
> rmi.port=6776
> 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=${repository.name}
> jndi.name=jackrabbit
> java.naming.provider.url=http://www.apache.org/jackrabbit
>
>
java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyIn
itialContextFactory
>
> And finally, this from the server log during startup:
>
> 17:12:19,468 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> Configuration of JNDIConfig (AbstractConfig.java, line 101)
> 17:12:19,484 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> ---------------------------------------------- (AbstractConfig.java,
>  line 102)
> 17:12:19,484 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> valid: true (AbstractConfig.java, line 106)
> 17:12:19,484 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> jndiName: jackrabbit (AbstractConfig.java, line 106)
> 17:12:19,484 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> jndiEnabled: true (AbstractConfig.java, line 106)
> 17:12:19,484 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> class: class org.apache.jackrabbit.j2ee.JNDIConfig (AbstractConfig
> .java, line 106)
> 17:12:19,484 INFO  [STDOUT] 06.09.2008 17:12:19 *INFO * AbstractConfig:
> jndiEnv: {java.naming.provider.url=http://www.apache.org/jackrabbit,
>
>
java.naming.factory.initial=org.apache.jackrabbit.core.jndi.provider.DummyIn
itialContextFactory}
> (AbstractConfig.java, line 106)
> ...
>
> 17:12:21,593 INFO  [STDOUT] 06.09.2008 17:12:21 *INFO *
> RepositoryStartupServlet: Repository bound to JNDI with name: jackrabbit
> (RepositoryStartupServlet.java, line 452)
>
> Seems better, but still not working.  Do I just need to change "java:" to
> something else?
>
> Thanks,
> ken
> --
> View this message in context:
>
http://www.nabble.com/Client-access-via-JNDI-to-Jackrabbit-Web-Application-t
p19350925p19351425.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>


Mime
View raw message