Damn, he found it. We try to hide those HOW-TOs really well. ;) Aaron,
Yeah, that's the right place to look; sorry I didn't include that in the first reply, but I didn't want to muddy the waters if that wasn't your real issue. I'm inlining an email that I sent to the list a few months ago. It's not on the exact same issue, but the example may help you get some clarity. Good Luck, Patrick ---- Forwarded Message ---- From: P T <[EMAIL PROTECTED]> Reply-To: P T <[EMAIL PROTECTED]> To: Tomcat Users List <tomcat-user@jakarta.apache.org> Date: Apr 8, 2005 1:31 PM Subject: Re: Add Context Path, Tomcat 5.5.7 Scott, I feel your pain -- I just finished sorting out that whole thing myself. One thing I'd definitely recommend doing is installing the admin tool for tomcat 5 and using it to change something trivial in your server.xml file. When it gets done making the change it strips out all the comments as a side effect and makes the file *much* cleaner and, in my opinion, more readable. As for your question: if the resource is to be used for multiple applications, you could put it in the server.xml... if not (and I'm going to presume that's the case for you -- let me know if not) then you're much better off using your application-specific WEB-INF\web.xml and META-INF\context.xml files like so: <your application docbase>\META-INF\context.xml would look something like: <Context path="/Foo" docBase="C:/Foo" debug="1" reloadable="true"> <Resource auth="Container" name="jdbc/aNameForYourDBresource" type="javax.sql.DataSource" password="Foo" driverClassName="oracle.jdbc.driver.OracleDriver" maxIdle="3" maxWait="5000" username="Foo" url="jdbc:oracle:thin:@Foo:1521:Foo" maxActive="15"/> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>META-INF/context.xml</WatchedResource> </Context> and your <your application docbase>WEB-INF\web.xml would then reference the resource defined in the context above (the res-ref-name should match the resource name).... <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Your app's name</display-name> <description> Slices, dices and makes fresh canned spam! </description> <resource-ref> <description>Description of Datasource</description> <res-ref-name>jdbc/aNameForYourDBresource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app> It's helpful to think of the individual application context.xml files being 'included' as <context> entries in the server.xml file (almost like an @include, except implicit). Hope that helps! Let me know if I can clarify anything. Cheers, Patrick Thomas (PS - remember to install the jakarta commons and pooling jars mentioned in the dbcp documentation.) On 5/31/05, Aaron Hackney <[EMAIL PROTECTED]> wrote: > I think I may have actually found the answer to my own question....does > this look like the right path to go down? > > http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html > > ? > > Thanks > -Aaron > > Aaron Hackney wrote: > > > Thanks for the response Patrick. I'm probably going about this all wrong. > > > > Simply put, I'm just trying to make a datasource available to my > > application. Sounds sinple enough. I have found a lot of conflicting > > information out there on the implementation. > > > > I develop with JBuilder (good, bad or indifferent!) But > > anyhow....where does one properly make a datasource for a tomcat > > application available? I'm using Tomcat 5.0 (I could use 5.5 if I had > > to). > > > > Thanks in advance. I'm a bit blind and stubling around here and really > > tried to research it on my own this weekend but to no avail. > > > > -Aaron > > > > Patrick Thomas wrote: > > > >>> and if a context with the same name is defined in a webapp WEB-INF/xml > >>> file which would "win" such a fight? I have a feeling my context > >>> defined > >>> in /localhost is being overwritten by the app. (I'm fighting with > >>> JBuilder 2005 trying to get some JNDI naming stuff to work for my > >>> datasources) > >>> > >>> Ideas? Or am I waaaaay off? > >>> > >> > >> > >> I'm gonna go with "possibly way off" because you shouldn't be putting > >> the context name into web.xml (context.xml is okay, though not > >> required, but web.xml no... in fact, I don't think it'll even > >> acknowledge it there). Did you mean to say "META-INF/context.xml"? If > >> so, then we've got a meatier discussion; let us know. > >> > >> Cheers, > >> Patrick > >> > >> On 5/31/05, Aaron Hackney <[EMAIL PROTECTED]> wrote: > >> > >> > >>> Hello. I'm hoping someone can help me with a context question. > >>> > >>> If I define a context in an xml file in > >>> /tomcathome/conf/catalina/localhost > >>> > >>> and if a context with the same name is defined in a webapp WEB-INF/xml > >>> file which would "win" such a fight? I have a feeling my context > >>> defined > >>> in /localhost is being overwritten by the app. (I'm fighting with > >>> JBuilder 2005 trying to get some JNDI naming stuff to work for my > >>> datasources) > >>> > >>> Ideas? Or am I waaaaay off? > >>> > >>> Thanks in advance. > >>> -Aaron > >>> > >>> -- > >>> ************************************************ > >>> Aaron Hackney > >>> MCP, MCSA, MCSE 2003/NT4, MCT, > >>> Net+, A+, CCNA, CCDA, CCAI > >>> [EMAIL PROTECTED] > >>> http://www.aaronhackney.com > >>> 309-472-7033 > >>> ************************************************ > >>> > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>> For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > >> > > > > -- > ************************************************ > Aaron Hackney > MCP, MCSA, MCSE 2003/NT4, MCT, > Net+, A+, CCNA, CCDA, CCAI > [EMAIL PROTECTED] > http://www.aaronhackney.com > 309-472-7033 > ************************************************ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]