Hi, Steve's post is excellent, and I hope that in the future people search the archives and read it. Of course I've been hoping that would happen with other such posts for years now ;)
Tomcat offers great flexibility in this area. I think the docs now are at a point where they really cover the vast majority of cases and work for the vast majority of people. That wasn't always the case, and we've worked diligently to improve them. But with flexibility comes responsibility: we expect Tomcat users to be able to read, understand, and follow the docs. Yoav Shapira http://www.yoavshapira.com >-----Original Message----- >From: Steve Kirk [mailto:[EMAIL PROTECTED] >Sent: Tuesday, October 26, 2004 8:58 AM >To: 'Tomcat Users List' >Subject: RE: JNDI DataSource GlobalResources problem > > >This question illustrates (IMHO) probably the biggest issue of confusion >with regard to DBCP - that is, there are several XML elements that you can >potentially use, and several places that you can potentially put them. >Specifically, the <Resource>, <ResourceParams> and <ResourceLink> elements >can go in server.xml or your webapp's context config file, and ><resource-ref> can go in your web.xml file. Most people that have DBCP >problems seem to have trouble working out elements to use, and where to put >them. A quick search on the web shows that this issue is widely >misunderstood, and there is lots of misinformation out there. > >There are actually several possibilities that work. I have not chosen the >same possibility as you Roland, but hope I can help. The how-to pages >linked earlier by Shinobu and me are also good points of reference, and if >you follow them _exactly_ it will work. I belive that the simplest and >clearest page to follow is this one: >http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.ht ml - >I think the JDBC page contains at least one slightly misleading >instruction. > >To answer your question, yes you have used <resource-ref> correctly and >your ><Resource> and <ResourceParams> elements seem OK. > >However, note that you have not followed the recommended approach in the >how-to docs ;) because your <Resource> and <ResourceParams> are under ><GlobalNamingResources> rather than your webapp's <Context> tag. However >that does not make it completely wrong. Because they are under ><GlobalNamingResources> at the moment, they are not visible to your webapp. >To fix this, either they need to be moved under <Context> as recommended in >the how-to, or you need to add a <ResourceLink> under your webapp's ><Context> that refers to them. > >The <Context> that I am referring to should be either under <Host> in >server.xml as described in the how-to docs, or in your webapp's context >config file (see my example below). > >Strictly speaking, according to the JNDI how-to docs, I think your ><Resource> tag is not needed because you have a <resource-ref>, which is >equivalent, and you do not need both. Having said that, I have tried it >both with and without the <Resource> tag, and both approaches work as long >as <resource-ref> is in web.xml. > >For what it's worth, (but not wanting to confuse you!) below is the >approach >that I have working. I'm including this to illustrate that there is more >than one way to configure DBCP. Note that this is a different approach to >yours, and also different to that described in the how-to docs on the TC >site. I took this approach via trial and error because I did not find the >how-to docs until after I'd got pooling working. > >1. I have a <resource-ref> like yours in my >CATALINA_HOME\webapps\webapp\WEB-INF\web.xml > >2. I created a context config file at >CATALINA_HOME\conf\Catalina\localhost\mywebapp.xml, where "mywebapp" is the >name of the webapp, which contains just my webapp's <Context> element, >which in turn contains <Resource> and <ResourceParams> very similar to >yours. That this <Context> tag is more usually included in server.xml, >under the default localhost <Host> tag. (By default your server.xml will >not include a <Context> tag for your webapp, you have to add it inside the >Context element for your webapp, or inside a DefaultContext element for the >surrounding <Host> or <Engine> element, as described in the JNDI how-to >page. The entire contents of my context config file are below: > ><?xml version='1.0' encoding='utf-8'?> ><Context docBase="C:\jakarta-tomcat-5.0.27\webapps\mywebapp" >path="/mywebapp" reloadable="true"> > <ResourceParams name="jdbc/mywebapp"> > <parameter> > <name>factory</name> > ><value>org.apache.commons.dbcp.BasicDataSourceFactory</value> > </parameter> > ... more parameters like yours ... > </ResourceParams> ></Context> > >3. I have no <ResourceLink> anywhere - I don't need it because I have not >used <GlobalNamingResources> > >I know that this is a long-winded reply, but this is a tricky area and easy >to get confused. I've also been meaning to post this to the list for a few >months, having spent days learning it. Hope this helps you and others :) > >> -----Original Message----- >> From: Roland Carlsson [mailto:[EMAIL PROTECTED] >> Sent: Tuesday 26 October 2004 12:09 >> To: TomcatUsers >> Subject: Sv: JNDI DataSource GlobalResources problem >> >> >> Hello! >> >> Thanks for your answer. I have no ResourceLink in my configuration. I >> understand that I should put it a <Context>-tag but not where. >> >> How does this affect the configuration I already have done? >> Is the use of >> resource-ref and Resource correct? >> > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
