You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Minilin-inbox <mi...@inbox.com> on 2006/03/19 16:10:42 UTC

JNDI in embedded tomcat

Hi, All,

I want to start tomcat by program, but I also need a JNDI data source.
Could anyone tell me how to config a Tomcat JNDI data source by program, 
or any method let the data source configuration file work?

Minilin

RE: JNDI in embedded tomcat

Posted by slashny <in...@mac.com>.
Thanks for the reply and pointing me in the right direction.  I just wanted
to complete the circle regarding the resolution.

I prevented Tomcat from using creating its own JNDI Context (and having new
InitialContext() resolve to a preexisting Context), by setting the
StandardContext.setUseNaming(false), which can be done in code or I guess
through the context.xml file as well.

Thanks again
--
View this message in context: http://www.nabble.com/JNDI-in-embedded-tomcat-t1306622.html#a3692505
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI in embedded tomcat

Posted by slashny <in...@mac.com>.
My question is similar but slightly different.  I am running my own custom
Spring-like container with an embedded version of Tomcat 5.5.  I have my own
JNDI Context object configured in my application that I bind objects to. 
However all those objects in that Context are not available to my web
applications because Tomcat is using it's own Context:

Context ctx = new InitialContext();
DataSource myDS = (DataSource) ctx.lookup( "java:/myDataSource" );

javax.naming.NameNotFoundException: Name myDataSource is not bound in this
Context
	at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
	at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
	at javax.naming.InitialContext.lookup(InitialContext.java:347)

I am starting up my application as per this article:
http://www.vsj.co.uk/articles/display.asp?id=319.  All the documentation
I've seen has been using the server.xml which is not available to me as I'm
using the Embedded tomcat.  If I can use server.xml with Embedded.java,
please let me know.

Thanks
--
View this message in context: http://www.nabble.com/JNDI-in-embedded-tomcat-t1306622.html#a3691348
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JNDI in embedded tomcat

Posted by Minilin-inbox <mi...@inbox.com>.
I'm sorry, I should have given the question more detailed.
Generally, we config our JNDI data source in configuration file and put it into "conf/catalina/localhost", when tomcat is starting up alone, the configuration is loaded by tomcat and then we can find our data source like that:
Context context = new InitialContext()
context.lookup("my_data_sourc_name");

But now I start up tomcat in Eclipse and the configuration isn't loaded automatically and also the data source couldn't be found.
So, the question is how could I make the configuration file work.

In one word, how to make tomcat(started by Eclipse) include a data source that I can find out like the above snippet.


----- Original Message ----- 
From: "David Smith" <dn...@cornell.edu>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Monday, March 20, 2006 8:15 AM
Subject: Re: JNDI in embedded tomcat


> Details please. This question is way to general to answer without even
> so much as a version number.
> 
> JNDI config information for tomcat can be found at
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html for
> tomcat 5.5.x
> 
> --David
> 
> Minilin-inbox wrote:
> 
>>Hi, All,
>>
>>I want to start tomcat by program, but I also need a JNDI data source.
>>Could anyone tell me how to config a Tomcat JNDI data source by program, 
>>or any method let the data source configuration file work?
>>
>>Minilin
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: JNDI in embedded tomcat

Posted by David Smith <dn...@cornell.edu>.
Details please. This question is way to general to answer without even
so much as a version number.

JNDI config information for tomcat can be found at
http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html for
tomcat 5.5.x

--David

Minilin-inbox wrote:

>Hi, All,
>
>I want to start tomcat by program, but I also need a JNDI data source.
>Could anyone tell me how to config a Tomcat JNDI data source by program, 
>or any method let the data source configuration file work?
>
>Minilin
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org