You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by maninder s batth <an...@netscape.net> on 2002/12/03 05:41:10 UTC

Datasource and Initial Context

hi i am using my own DataSource class which cannot be configuered by xml 
file
i need to programatically configure it . since tomcat provides read only 
context
, is there any way i can use tomcat's jndi implementation, as of now i 
am using
filesystem provider for datasource, is there any other open source 
provider for
jndi which is more scalable and faster than file system provider?
thanks


Craig R. McClanahan wrote:

>On Tue, 3 Dec 2002, Peng Tuck Kwok wrote:
>
>  
>
>>Date: Tue, 03 Dec 2002 12:09:42 +0800
>>From: Peng Tuck Kwok <pe...@makmal.net>
>>Reply-To: Tomcat Users List <to...@jakarta.apache.org>
>>To: Tomcat Users List <to...@jakarta.apache.org>
>>Subject: Datasource and Web.xml
>>
>>If a web application uses a jndi datasource, should the web.xml contain
>>the definition for the datasource before deployment (that is in the war
>>file) or after deployment (that is after the war file has been deployed)
>>? This sounds strange as I was having problems with this in tomcat
>>4.1.12 , where Tomcat could not start if the there was a resource
>>definition in the web.xml. Of course I can't create a resource for the
>>context using the admin interface since the context doesn't exist yet.
>>I've used Sun one server and all seems ok so what is the correct
>>sequence for doing things in tomcat?
>>
>>    
>>
>
>There is not really a pre-deploy versus post-deploy state of the web.xml
>file in Tomcat stand-alone.  The net effect of this is that:
>
>* You MUST declare your JNDI resources in the web.xml file before
>  you deploy the app (i.e. in the original web.xml file you provide)
>
>* You MUST configure your JNDI resources in either server.xml
>  at Tomcat startup time (nested in the <Context> element) or
>  dynamically if you deploy via the manager webapp, in which case
>  you must provide a context configuration file that includes the
>  resource configurations.
>
>If you're using the admin webapp to create resources, what you're actually
>doing is setting up things in the <GlobalNamingResources> section of
>server.xml -- the resources are not actually configured to a particular
>webapp until you include a <ResourceLink> element in the <Context> element
>for that webapp.
>
>For more info about JNDI resources in general:
>
>http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html
>
>For detailed walkthroughs (using the Java Web Services Developer Pack, but
>the instructions for JNDI resources are also generally applicable to
>Tomcat 4.1 standalone use), see the webapp related chapters in the Java
>Web Services Tutorial:
>
>http://java.sun.com/webservices/docs/1.0/tutorial/index.html
>
>Craig
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>  
>

-- 
Your favorite stores, helpful shopping tools and great gift ideas. 
Experience the convenience of buying online with Shop@Netscape! 
http://shopnow.netscape.com/


Reading wanted.

Posted by Triptpal Singh Lamba <tr...@cs.sunysb.edu>.
Hi all.

Can someone direct me to the following two things please...

1. The most exhaustive online, free resource for Tomcat documentation
2. Whats the best newsletter to keep in touch with the J2EE World updates.
Like we have  IEEE software for SE, Dr Dobb blah blah, but whats  a good one
for j2ee in general. I tried google but there are so many results I dont
know what to do:)

Btw ,bless the soul of the man who suggested Eclipse. It rocks! I used VA fo
Java 3.5 last time I did a project , buthad to make do with Jbuilder till
eclipse came along.  I didnt find a fav. feature I like din editors --the
ctrl + bracket key to manually check brackets match or not and till where.

Thanks
Tript Singh



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Datasource and Initial Context

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 2 Dec 2002, maninder s batth wrote:

> Date: Mon, 02 Dec 2002 20:41:10 -0800
> From: maninder s batth <an...@netscape.net>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: Datasource and Initial Context
>
> hi i am using my own DataSource class which cannot be configuered by xml
> file
> i need to programatically configure it . since tomcat provides read only
> context
> , is there any way i can use tomcat's jndi implementation, as of now i
> am using
> filesystem provider for datasource, is there any other open source
> provider for
> jndi which is more scalable and faster than file system provider?
> thanks
>

Tomcat will let you use any resource factory you want, as long as it (or a
wrapper class around it) implements the standard JNDI object factory
interface (javax.naming.spi.ObjectFactory).  If you grab a source distro
of commons-dbcp <http://jakarta.apache.org/commons/dbcp> and look at the
sources for org.apache.commons.dbcp.BasicDataSourceFactory (the default
object factory for data sources in Tomcat) you can see that it's actually
pretty easy to create such a wrapper class around your own data source
implementation.  Then, you tell Tomcat to use your factory by using a
"factory" parameter in the <ResourceParams> section of server.xml.

For more info about JNDI resources in Tomcat, including a simple example
of building your own factory, see:

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>