You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Tyson Norris <tn...@organic.com> on 2009/02/10 00:21:51 UTC

tomcat + JNDI + sling 3

Hello - 

First, thanks for sling! 

 

Next, I have a question about using sling - I'd like to access my JCR
repository via JNDI within Tomcat. 

I believe that I have tomcat properly configured, because I can deploy
jackrabbit org.apache.jackrabbit.j2ee.RepositoryAccessServlet within a
webapp that does NOT deploy an embedded repository, and I can access
the repository without a problem.

 

However, when I deploy a similar config with sling, I believe I am
running into classloader problems, because the JNDI context does NOT
have anything bound to it.

 

Exception stack is below; basically I get
javax.naming.NameNotFoundException: Name java:comp is not bound in this
Context when my (custom) jndi context impl lookup method is executing:

Context initCtx = new InitialContext();

Context ctx = (Context) initCtx.lookup("java:comp/env");

(note that this works fine with jackrabbit webapp).

 

I am deploying the prepacked sling webapp from
http://incubator.apache.org/sling/site/downloads.cgi
<http://incubator.apache.org/sling/site/downloads.cgi> 

 

I downloaded the src from same site, and built the
org.apache.sling.jcr.jackrabbit.client-2.0.2-incubator.jar, and added to
sling\WEB-INF\resources\bundles.

 

In WEB-INF/sling.properties I added:

sling.repository.url=jndi://magnoliaAuthor22:java.naming.factory.initial
=org.myo.jndi.simple.SimpleInitialContextFactory,java.naming.provider.ur
l=localhost

 

I also added to both sling.properties AND jcr-client.properties:

 

sling.bootdelegation.class.org.myo.jndi.simple.SimpleInitialContextFacto
ry = \

 org.myo.jndi.simple,javax.naming,org.apache.naming

 

sling.bootdelegation.class.javax.naming.InitialContext = \

 javax.naming

 

sling.bootdelegation.class.org.apache.naming.NamingContext = \

 org.apache.naming

 

sling.bootdelegation.simple = org.myo.jndi.simple

 

I will try a few more things like, newer codebase of sling (I know some
minor changes have been made to processing of sling.repository.url
property) as well as deployment in jboss.

 

Any ideas how to make this work in tomcat?

 

Thanks for any help.

Tyson

 

 

 

09.02.2009 15:00:54.157 *INFO* [Repository Pinger]
org.apache.sling.jcr.base.util.RepositoryAccessor Unable to acquire R

epository 'magnoliaAuthor22' via JNDI,
context={java.naming.provider.url=localhost,
java.naming.factory.initial=org.myo.

jndi.simple.SimpleInitialContextFactory}
javax.naming.NameNotFoundException: Name java:comp is not bound in this
Context

 

        at
org.apache.naming.NamingContext.lookup(NamingContext.java:770)

        at
org.apache.naming.NamingContext.lookup(NamingContext.java:153)

        at javax.naming.InitialContext.lookup(InitialContext.java:392)

        at
org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:270)

        at
org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:287)

        at javax.naming.InitialContext.lookup(InitialContext.java:392)

        at
org.apache.sling.jcr.base.util.RepositoryAccessor.getRepository(Reposito
ryAccessor.java:76)

        at
org.apache.sling.jcr.base.util.RepositoryAccessor.getRepositoryFromURL(R
epositoryAccessor.java:171)

        at
org.apache.sling.jcr.base.AbstractSlingRepository.acquireRepository(Abst
ractSlingRepository.java:408)

        at
org.apache.sling.jcr.jackrabbit.client.SlingClientRepository.acquireRepo
sitory(SlingClientRepository.java:57)

 

        at
org.apache.sling.jcr.base.AbstractSlingRepository.startRepository(Abstra
ctSlingRepository.java:795)

        at
org.apache.sling.jcr.base.AbstractSlingRepository.run(AbstractSlingRepos
itory.java:913)

        at java.lang.Thread.run(Thread.java:619)


--------------------------------------------------------------------
This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.


RE: tomcat + JNDI + sling 3

Posted by Javier Ruiz Jiménez <jr...@tecsisa.com>.
Hi Tyson

JNDI context for each type of resource seems to be different in each server, so in order to support different application servers and servlet engines I find that JNDI names should include the context and not let the lookup make any decisions about the context root since there seems no to be a standard in place.

Instead of specifying  "JNDIResource" in properties use "java:comp/env/JNDIResource" when running in Tomcat, and use just "JNDIResource" when running in Weblogic since in Weblogic JNDI resources are on the "global namespace. 

Env = tomcat
tomcat.jndiResourceName = java:comp/env/JNDIResource
weblogic.jndiResourceName = JNDIResource

Regards,
Javier

-----Mensaje original-----
De: Tyson Norris [mailto:tnorris@organic.com] 
Enviado el: miércoles, 11 de febrero de 2009 3:33
Para: sling-dev@incubator.apache.org
Asunto: Re: tomcat + JNDI + sling 3

Thanks Felix.
That mostly worked- I can now look up the repo in Sling, but it is  
found at java:repository instead of java:comp/env/repository.
For now I just hacked my custom naming context impl to look in java:  
in case java:comp/env fails.
Thanks
Tyson

On Feb 10, 2009, at 12:05 AM, "Felix Meschberger" <fm...@gmail.com>  
wrote:

> Hi Tyson,
>
> Tyson Norris schrieb:
>> First, thanks for sling!
>
> You are welcome - Glad you like it ;-)
>
>> Next, I have a question about using sling - I'd like to access my JCR
>> repository via JNDI within Tomcat.
>
> I have to admit, that both Tomcat and JNDI are almost a book with  
> seven
> seals to me ... But I give it a try ...
>
>>
>> I believe that I have tomcat properly configured, because I can  
>> deploy
>> jackrabbit org.apache.jackrabbit.j2ee.RepositoryAccessServlet  
>> within a
>> webapp that does NOT deploy an embedded repository, and I can access
>> the repository without a problem.
>>
>>
>>
>> However, when I deploy a similar config with sling, I believe I am
>> running into classloader problems, because the JNDI context does NOT
>> have anything bound to it.
>
> It looks like you might really have a class loading issue. Since the
> InitialContext might not be correclty set up. What you might try is to
> set the Thread context ClassLoader before instantiating the
> InitialContext in your SimpleInitialContextFactory class, someting  
> like:
>
>    ClassLoader old = Thread.currentThread.getContextClassLoader();
>    try {
>        Thread.currentThread.setContextClassLoader(
>               getClass().getClassLoader());
>
>         Context initCtx = new InitialContext();
>         Context ctx = (Context) initCtx.lookup("java:comp/env");
>         ....
>    finally {
>        Thread.currentThread.setContextClassLoader(old);
>    }
>
> Regards
> Felix
>
>>
>>
>>
>> Exception stack is below; basically I get
>> javax.naming.NameNotFoundException: Name java:comp is not bound in  
>> this
>> Context when my (custom) jndi context impl lookup method is  
>> executing:
>>
>> Context initCtx = new InitialContext();
>>
>> Context ctx = (Context) initCtx.lookup("java:comp/env");
>>
>> (note that this works fine with jackrabbit webapp).
>>
>>
>>
>> I am deploying the prepacked sling webapp from
>> http://incubator.apache.org/sling/site/downloads.cgi
>> <http://incubator.apache.org/sling/site/downloads.cgi>
>>
>>
>>
>> I downloaded the src from same site, and built the
>> org.apache.sling.jcr.jackrabbit.client-2.0.2-incubator.jar, and  
>> added to
>> sling\WEB-INF\resources\bundles.
>>
>>
>>
>> In WEB-INF/sling.properties I added:
>>
>> sling.repository.url=jndi:// 
>> magnoliaAuthor22:java.naming.factory.initial
>> =org. 
>> myo.jndi.simple.SimpleInitialContextFactory,java.naming.provider.ur
>> l=localhost
>>
>>
>>
>> I also added to both sling.properties AND jcr-client.properties:
>>
>>
>>
>> sling. 
>> bootdelegation.class.org.myo.jndi.simple.SimpleInitialContextFacto
>> ry = \
>>
>> org.myo.jndi.simple,javax.naming,org.apache.naming
>>
>>
>>
>> sling.bootdelegation.class.javax.naming.InitialContext = \
>>
>> javax.naming
>>
>>
>>
>> sling.bootdelegation.class.org.apache.naming.NamingContext = \
>>
>> org.apache.naming
>>
>>
>>
>> sling.bootdelegation.simple = org.myo.jndi.simple
>>
>>
>>
>> I will try a few more things like, newer codebase of sling (I know  
>> some
>> minor changes have been made to processing of sling.repository.url
>> property) as well as deployment in jboss.
>>
>>
>>
>> Any ideas how to make this work in tomcat?
>>
>>
>>
>> Thanks for any help.
>>
>> Tyson
>>
>>
>>
>>
>>
>>
>>
>> 09.02.2009 15:00:54.157 *INFO* [Repository Pinger]
>> org.apache.sling.jcr.base.util.RepositoryAccessor Unable to acquire R
>>
>> epository 'magnoliaAuthor22' via JNDI,
>> context={java.naming.provider.url=localhost,
>> java.naming.factory.initial=org.myo.
>>
>> jndi.simple.SimpleInitialContextFactory}
>> javax.naming.NameNotFoundException: Name java:comp is not bound in  
>> this
>> Context
>>
>>
>>
>>        at
>> org.apache.naming.NamingContext.lookup(NamingContext.java:770)
>>
>>        at
>> org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>
>>        at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>
>>        at
>> org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:270)
>>
>>        at
>> org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:287)
>>
>>        at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.util.RepositoryAccessor.getRepository(Reposito
>> ryAccessor.java:76)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.util.RepositoryAccessor.getRepositoryFromURL(R
>> epositoryAccessor.java:171)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.AbstractSlingRepository.acquireRepository(Abst
>> ractSlingRepository.java:408)
>>
>>        at
>> org. 
>> apache.sling.jcr.jackrabbit.client.SlingClientRepository.acquireRepo
>> sitory(SlingClientRepository.java:57)
>>
>>
>>
>>        at
>> org. 
>> apache.sling.jcr.base.AbstractSlingRepository.startRepository(Abstra
>> ctSlingRepository.java:795)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.AbstractSlingRepository.run(AbstractSlingRepos
>> itory.java:913)
>>
>>        at java.lang.Thread.run(Thread.java:619)
>>
>>

--------------------------------------------------------------------
This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.


Re: tomcat + JNDI + sling 3

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Tyson,

Tyson Norris schrieb:
> Hi Paul - 
> The architecture I am investigating is using a single JCR repository (initialized in Tomcat as a JNDI resource), but leveraging multiple applications to administer and render content.
> The specific applications I am trying to use together are:
> - Magnolia (community edition)
> - Sling
> 
> Background: 
> Magnolia is a CMS built on top of Jackrabbit that offers features like ACLs, publishing, templating, and document management. All of this is accessed via a web UI.
> However, the templating system (of Magnolia 3.6 - I will mention 4.0 later) is based on JSPs that must be managed via filesystem deployment. In addition, the management of file assets (think images linked via HTML template) are not easily integrated with templates via the repo, and must also be managed within the filesystem. 
> 
> If we could leverage sling's templating and file serving abilities, the system process for publishing content to other remote environments (which magnolia has functionality for JCR repo, but not filesystem), our life would be much easier.
> 

Interesting, indeed ;-)

> That said, I now can access magnolia repo from sling and vice versa, but there is some application-specific meta data that each requires, and in some cases (when magnolia encounters sling meta data, like sling:resourceType) disrupts the other application (magnolia uses some logic to create a property named mgnl:sling:resourceType which is illegal...). 

Well, I don't know much about mangolia, but I would consider magnolia's
munging of sling:resourceTyp to mgnl:sling:resurceType a bug ;-)

> 
> I am now coming to the conclusion that since each application has some dependencies on the data having some specific configuration in the repo, it may be more work to integrate these (or simply get them to work together on the same repo) than to build out the desired functionality in one or the other. In that case we will likely build upon Magnolia, since it offers more breadth of desired functionaliy, even if it is a bit clunky.

I would say, Sling does not have any hard dependencies on the data.
There is just the special sling:resourceType property, which is used to
resolve handling scripts. If you are entirely based on primary node
types, you do not even need sling:resourceType properties, since the
default is to use the primary node type as the resource type.

> 
> Please let me know if you have comments/suggestions on this approach.

Well, I think, with respect to ACL and user management, we are certainly
open to extensions in Sling, they may probably be easily implemented
based on what Jackrabbit 1.5 (and later 1.6) offer in terms of JSR-283
access control.

The rest may also be easily added to Sling (which is exactly what we do
inside Day for our WCM product).

Regards
Felix

> 
> Thanks!
> Tyson
> 
> 
> -----Original Message-----
> From: Paul Noden [mailto:nodenp@nodster.co.uk] 
> Sent: Tuesday, February 10, 2009 7:50 PM
> To: sling-dev@incubator.apache.org
> Subject: Re: tomcat + JNDI + sling 3
> 
> Hi Tyson,
> 
>>>> Next, I have a question about using sling - I'd like to access my JCR repository via JNDI within Tomcat.
> 
> I am interested to know more about the system architecture that you're
> using. Is it a sling-enabled-jcr with tomcat via jndi, do you use
> sling to administer the content and tomcat to generate an output, or
> is tomcat generating output in parallel, or perhaps it is just sling
> running with tomcat, or some other model... If you could be so kind as
> to let us (me) know I'd appreciate it, as it'll stop us (me) guessing
> ;-)
> 
> I'm leading a project for an application which is using jcr to store
> content alongside a traditional relational database, in the first
> stage to handle the storage of large binary blobs and hierarchical
> data. Having evaluated sling a couple of times for this project we
> ended up not leveraging it's features in the current implementation.
> But with an ongoing plan for development I imagine I'll be evaluating
> the use of sling again in the future for the project (as well as for
> other projects in which I am involved) and knowledge of other
> implementations, and any feedback from the teams having done these
> (other than my Day friends), can only assist with this assessment.
> 
> Kind Regards,
> 
> Paul Noden
> 
> --------------------------------------------------------------------
> This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.
> 
> 

RE: tomcat + JNDI + sling 3

Posted by Tyson Norris <tn...@organic.com>.
Thanks for the suggestion, but I may not have been clear about what I am
trying to do.

I am trying to get away from using JSP, so something like .esp
(javascript) works well, but I had trouble getting Magnolia to tolerate
the sling:resourceType meta data, so I am back to using JSP for now...

Thanks
Tyson

-----Original Message-----
From: Torgeir Veimo [mailto:torgeir@pobox.com] 
Sent: Thursday, February 12, 2009 3:23 PM
To: sling-dev@incubator.apache.org
Subject: Re: tomcat + JNDI + sling 3


On 12 Feb 2009, at 03:27, Tyson Norris wrote:

> [...]
> However, the templating system (of Magnolia 3.6 - I will mention 4.0  
> later) is based on JSPs that must be managed via filesystem  
> deployment.

> Please let me know if you have comments/suggestions on this approach.

Did you look into the file system provider for Sling? It allows  
resources to be located on disk and thus would allow legacy support  
for JSPs stored as files through slings JSP support.

-- 
Torgeir Veimo
torgeir@pobox.com





--------------------------------------------------------------------
This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.


Re: tomcat + JNDI + sling 3

Posted by Torgeir Veimo <to...@pobox.com>.
On 12 Feb 2009, at 03:27, Tyson Norris wrote:

> [...]
> However, the templating system (of Magnolia 3.6 - I will mention 4.0  
> later) is based on JSPs that must be managed via filesystem  
> deployment.

> Please let me know if you have comments/suggestions on this approach.

Did you look into the file system provider for Sling? It allows  
resources to be located on disk and thus would allow legacy support  
for JSPs stored as files through slings JSP support.

-- 
Torgeir Veimo
torgeir@pobox.com





RE: tomcat + JNDI + sling 3

Posted by Tyson Norris <tn...@organic.com>.
Hi Paul - 
The architecture I am investigating is using a single JCR repository (initialized in Tomcat as a JNDI resource), but leveraging multiple applications to administer and render content.
The specific applications I am trying to use together are:
- Magnolia (community edition)
- Sling

Background: 
Magnolia is a CMS built on top of Jackrabbit that offers features like ACLs, publishing, templating, and document management. All of this is accessed via a web UI.
However, the templating system (of Magnolia 3.6 - I will mention 4.0 later) is based on JSPs that must be managed via filesystem deployment. In addition, the management of file assets (think images linked via HTML template) are not easily integrated with templates via the repo, and must also be managed within the filesystem. 

If we could leverage sling's templating and file serving abilities, the system process for publishing content to other remote environments (which magnolia has functionality for JCR repo, but not filesystem), our life would be much easier.

That said, I now can access magnolia repo from sling and vice versa, but there is some application-specific meta data that each requires, and in some cases (when magnolia encounters sling meta data, like sling:resourceType) disrupts the other application (magnolia uses some logic to create a property named mgnl:sling:resourceType which is illegal...). 

I am now coming to the conclusion that since each application has some dependencies on the data having some specific configuration in the repo, it may be more work to integrate these (or simply get them to work together on the same repo) than to build out the desired functionality in one or the other. In that case we will likely build upon Magnolia, since it offers more breadth of desired functionaliy, even if it is a bit clunky.

Please let me know if you have comments/suggestions on this approach.

Thanks!
Tyson


-----Original Message-----
From: Paul Noden [mailto:nodenp@nodster.co.uk] 
Sent: Tuesday, February 10, 2009 7:50 PM
To: sling-dev@incubator.apache.org
Subject: Re: tomcat + JNDI + sling 3

Hi Tyson,

>>> Next, I have a question about using sling - I'd like to access my JCR repository via JNDI within Tomcat.

I am interested to know more about the system architecture that you're
using. Is it a sling-enabled-jcr with tomcat via jndi, do you use
sling to administer the content and tomcat to generate an output, or
is tomcat generating output in parallel, or perhaps it is just sling
running with tomcat, or some other model... If you could be so kind as
to let us (me) know I'd appreciate it, as it'll stop us (me) guessing
;-)

I'm leading a project for an application which is using jcr to store
content alongside a traditional relational database, in the first
stage to handle the storage of large binary blobs and hierarchical
data. Having evaluated sling a couple of times for this project we
ended up not leveraging it's features in the current implementation.
But with an ongoing plan for development I imagine I'll be evaluating
the use of sling again in the future for the project (as well as for
other projects in which I am involved) and knowledge of other
implementations, and any feedback from the teams having done these
(other than my Day friends), can only assist with this assessment.

Kind Regards,

Paul Noden

--------------------------------------------------------------------
This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.


Re: tomcat + JNDI + sling 3

Posted by Paul Noden <no...@nodster.co.uk>.
Hi Tyson,

>>> Next, I have a question about using sling - I'd like to access my JCR repository via JNDI within Tomcat.

I am interested to know more about the system architecture that you're
using. Is it a sling-enabled-jcr with tomcat via jndi, do you use
sling to administer the content and tomcat to generate an output, or
is tomcat generating output in parallel, or perhaps it is just sling
running with tomcat, or some other model... If you could be so kind as
to let us (me) know I'd appreciate it, as it'll stop us (me) guessing
;-)

I'm leading a project for an application which is using jcr to store
content alongside a traditional relational database, in the first
stage to handle the storage of large binary blobs and hierarchical
data. Having evaluated sling a couple of times for this project we
ended up not leveraging it's features in the current implementation.
But with an ongoing plan for development I imagine I'll be evaluating
the use of sling again in the future for the project (as well as for
other projects in which I am involved) and knowledge of other
implementations, and any feedback from the teams having done these
(other than my Day friends), can only assist with this assessment.

Kind Regards,

Paul Noden

Re: tomcat + JNDI + sling 3

Posted by Tyson Norris <tn...@organic.com>.
Thanks Felix.
That mostly worked- I can now look up the repo in Sling, but it is  
found at java:repository instead of java:comp/env/repository.
For now I just hacked my custom naming context impl to look in java:  
in case java:comp/env fails.
Thanks
Tyson

On Feb 10, 2009, at 12:05 AM, "Felix Meschberger" <fm...@gmail.com>  
wrote:

> Hi Tyson,
>
> Tyson Norris schrieb:
>> First, thanks for sling!
>
> You are welcome - Glad you like it ;-)
>
>> Next, I have a question about using sling - I'd like to access my JCR
>> repository via JNDI within Tomcat.
>
> I have to admit, that both Tomcat and JNDI are almost a book with  
> seven
> seals to me ... But I give it a try ...
>
>>
>> I believe that I have tomcat properly configured, because I can  
>> deploy
>> jackrabbit org.apache.jackrabbit.j2ee.RepositoryAccessServlet  
>> within a
>> webapp that does NOT deploy an embedded repository, and I can access
>> the repository without a problem.
>>
>>
>>
>> However, when I deploy a similar config with sling, I believe I am
>> running into classloader problems, because the JNDI context does NOT
>> have anything bound to it.
>
> It looks like you might really have a class loading issue. Since the
> InitialContext might not be correclty set up. What you might try is to
> set the Thread context ClassLoader before instantiating the
> InitialContext in your SimpleInitialContextFactory class, someting  
> like:
>
>    ClassLoader old = Thread.currentThread.getContextClassLoader();
>    try {
>        Thread.currentThread.setContextClassLoader(
>               getClass().getClassLoader());
>
>         Context initCtx = new InitialContext();
>         Context ctx = (Context) initCtx.lookup("java:comp/env");
>         ....
>    finally {
>        Thread.currentThread.setContextClassLoader(old);
>    }
>
> Regards
> Felix
>
>>
>>
>>
>> Exception stack is below; basically I get
>> javax.naming.NameNotFoundException: Name java:comp is not bound in  
>> this
>> Context when my (custom) jndi context impl lookup method is  
>> executing:
>>
>> Context initCtx = new InitialContext();
>>
>> Context ctx = (Context) initCtx.lookup("java:comp/env");
>>
>> (note that this works fine with jackrabbit webapp).
>>
>>
>>
>> I am deploying the prepacked sling webapp from
>> http://incubator.apache.org/sling/site/downloads.cgi
>> <http://incubator.apache.org/sling/site/downloads.cgi>
>>
>>
>>
>> I downloaded the src from same site, and built the
>> org.apache.sling.jcr.jackrabbit.client-2.0.2-incubator.jar, and  
>> added to
>> sling\WEB-INF\resources\bundles.
>>
>>
>>
>> In WEB-INF/sling.properties I added:
>>
>> sling.repository.url=jndi:// 
>> magnoliaAuthor22:java.naming.factory.initial
>> =org. 
>> myo.jndi.simple.SimpleInitialContextFactory,java.naming.provider.ur
>> l=localhost
>>
>>
>>
>> I also added to both sling.properties AND jcr-client.properties:
>>
>>
>>
>> sling. 
>> bootdelegation.class.org.myo.jndi.simple.SimpleInitialContextFacto
>> ry = \
>>
>> org.myo.jndi.simple,javax.naming,org.apache.naming
>>
>>
>>
>> sling.bootdelegation.class.javax.naming.InitialContext = \
>>
>> javax.naming
>>
>>
>>
>> sling.bootdelegation.class.org.apache.naming.NamingContext = \
>>
>> org.apache.naming
>>
>>
>>
>> sling.bootdelegation.simple = org.myo.jndi.simple
>>
>>
>>
>> I will try a few more things like, newer codebase of sling (I know  
>> some
>> minor changes have been made to processing of sling.repository.url
>> property) as well as deployment in jboss.
>>
>>
>>
>> Any ideas how to make this work in tomcat?
>>
>>
>>
>> Thanks for any help.
>>
>> Tyson
>>
>>
>>
>>
>>
>>
>>
>> 09.02.2009 15:00:54.157 *INFO* [Repository Pinger]
>> org.apache.sling.jcr.base.util.RepositoryAccessor Unable to acquire R
>>
>> epository 'magnoliaAuthor22' via JNDI,
>> context={java.naming.provider.url=localhost,
>> java.naming.factory.initial=org.myo.
>>
>> jndi.simple.SimpleInitialContextFactory}
>> javax.naming.NameNotFoundException: Name java:comp is not bound in  
>> this
>> Context
>>
>>
>>
>>        at
>> org.apache.naming.NamingContext.lookup(NamingContext.java:770)
>>
>>        at
>> org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>
>>        at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>
>>        at
>> org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:270)
>>
>>        at
>> org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:287)
>>
>>        at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.util.RepositoryAccessor.getRepository(Reposito
>> ryAccessor.java:76)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.util.RepositoryAccessor.getRepositoryFromURL(R
>> epositoryAccessor.java:171)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.AbstractSlingRepository.acquireRepository(Abst
>> ractSlingRepository.java:408)
>>
>>        at
>> org. 
>> apache.sling.jcr.jackrabbit.client.SlingClientRepository.acquireRepo
>> sitory(SlingClientRepository.java:57)
>>
>>
>>
>>        at
>> org. 
>> apache.sling.jcr.base.AbstractSlingRepository.startRepository(Abstra
>> ctSlingRepository.java:795)
>>
>>        at
>> org. 
>> apache.sling.jcr.base.AbstractSlingRepository.run(AbstractSlingRepos
>> itory.java:913)
>>
>>        at java.lang.Thread.run(Thread.java:619)
>>
>>

--------------------------------------------------------------------
This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.


Re: tomcat + JNDI + sling 3

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Tyson,

Tyson Norris schrieb:
> First, thanks for sling! 

You are welcome - Glad you like it ;-)

> Next, I have a question about using sling - I'd like to access my JCR
> repository via JNDI within Tomcat. 

I have to admit, that both Tomcat and JNDI are almost a book with seven
seals to me ... But I give it a try ...

> 
> I believe that I have tomcat properly configured, because I can deploy
> jackrabbit org.apache.jackrabbit.j2ee.RepositoryAccessServlet within a
> webapp that does NOT deploy an embedded repository, and I can access
> the repository without a problem.
> 
>  
> 
> However, when I deploy a similar config with sling, I believe I am
> running into classloader problems, because the JNDI context does NOT
> have anything bound to it.

It looks like you might really have a class loading issue. Since the
InitialContext might not be correclty set up. What you might try is to
set the Thread context ClassLoader before instantiating the
InitialContext in your SimpleInitialContextFactory class, someting like:

    ClassLoader old = Thread.currentThread.getContextClassLoader();
    try {
        Thread.currentThread.setContextClassLoader(
               getClass().getClassLoader());

         Context initCtx = new InitialContext();
         Context ctx = (Context) initCtx.lookup("java:comp/env");
         ....
    finally {
        Thread.currentThread.setContextClassLoader(old);
    }

Regards
Felix

> 
>  
> 
> Exception stack is below; basically I get
> javax.naming.NameNotFoundException: Name java:comp is not bound in this
> Context when my (custom) jndi context impl lookup method is executing:
> 
> Context initCtx = new InitialContext();
> 
> Context ctx = (Context) initCtx.lookup("java:comp/env");
> 
> (note that this works fine with jackrabbit webapp).
> 
>  
> 
> I am deploying the prepacked sling webapp from
> http://incubator.apache.org/sling/site/downloads.cgi
> <http://incubator.apache.org/sling/site/downloads.cgi> 
> 
>  
> 
> I downloaded the src from same site, and built the
> org.apache.sling.jcr.jackrabbit.client-2.0.2-incubator.jar, and added to
> sling\WEB-INF\resources\bundles.
> 
>  
> 
> In WEB-INF/sling.properties I added:
> 
> sling.repository.url=jndi://magnoliaAuthor22:java.naming.factory.initial
> =org.myo.jndi.simple.SimpleInitialContextFactory,java.naming.provider.ur
> l=localhost
> 
>  
> 
> I also added to both sling.properties AND jcr-client.properties:
> 
>  
> 
> sling.bootdelegation.class.org.myo.jndi.simple.SimpleInitialContextFacto
> ry = \
> 
>  org.myo.jndi.simple,javax.naming,org.apache.naming
> 
>  
> 
> sling.bootdelegation.class.javax.naming.InitialContext = \
> 
>  javax.naming
> 
>  
> 
> sling.bootdelegation.class.org.apache.naming.NamingContext = \
> 
>  org.apache.naming
> 
>  
> 
> sling.bootdelegation.simple = org.myo.jndi.simple
> 
>  
> 
> I will try a few more things like, newer codebase of sling (I know some
> minor changes have been made to processing of sling.repository.url
> property) as well as deployment in jboss.
> 
>  
> 
> Any ideas how to make this work in tomcat?
> 
>  
> 
> Thanks for any help.
> 
> Tyson
> 
>  
> 
>  
> 
>  
> 
> 09.02.2009 15:00:54.157 *INFO* [Repository Pinger]
> org.apache.sling.jcr.base.util.RepositoryAccessor Unable to acquire R
> 
> epository 'magnoliaAuthor22' via JNDI,
> context={java.naming.provider.url=localhost,
> java.naming.factory.initial=org.myo.
> 
> jndi.simple.SimpleInitialContextFactory}
> javax.naming.NameNotFoundException: Name java:comp is not bound in this
> Context
> 
>  
> 
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:770)
> 
>         at
> org.apache.naming.NamingContext.lookup(NamingContext.java:153)
> 
>         at javax.naming.InitialContext.lookup(InitialContext.java:392)
> 
>         at
> org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:270)
> 
>         at
> org.myo.jndi.simple.SimpleContext.lookup(SimpleContext.java:287)
> 
>         at javax.naming.InitialContext.lookup(InitialContext.java:392)
> 
>         at
> org.apache.sling.jcr.base.util.RepositoryAccessor.getRepository(Reposito
> ryAccessor.java:76)
> 
>         at
> org.apache.sling.jcr.base.util.RepositoryAccessor.getRepositoryFromURL(R
> epositoryAccessor.java:171)
> 
>         at
> org.apache.sling.jcr.base.AbstractSlingRepository.acquireRepository(Abst
> ractSlingRepository.java:408)
> 
>         at
> org.apache.sling.jcr.jackrabbit.client.SlingClientRepository.acquireRepo
> sitory(SlingClientRepository.java:57)
> 
>  
> 
>         at
> org.apache.sling.jcr.base.AbstractSlingRepository.startRepository(Abstra
> ctSlingRepository.java:795)
> 
>         at
> org.apache.sling.jcr.base.AbstractSlingRepository.run(AbstractSlingRepos
> itory.java:913)
> 
>         at java.lang.Thread.run(Thread.java:619)
> 
> 
> --------------------------------------------------------------------
> This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Dissemination, distribution or copying of this email or the information herein by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is prohibited.  If you have received this email in error, please immediately notify us by calling our Help Desk at (415) 581-5552 or by e-mailing us at helpdesk@organic.com.
> 
>