Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 37061 invoked from network); 2 Feb 2007 18:32:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Feb 2007 18:32:44 -0000 Received: (qmail 91514 invoked by uid 500); 2 Feb 2007 18:32:37 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 91491 invoked by uid 500); 2 Feb 2007 18:32:37 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 91480 invoked by uid 99); 2 Feb 2007 18:32:37 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2007 10:32:37 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [212.67.202.165] (HELO bismuth.webfusion.co.uk) (212.67.202.165) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2007 10:32:28 -0800 Received: from 87-194-39-44.bethere.co.uk ([87.194.39.44] helo=phoenix.config) by bismuth.webfusion.co.uk with esmtpa (Exim 4.54) id 1HD3Cg-0008RU-My for users@tomcat.apache.org; Fri, 02 Feb 2007 18:32:06 +0000 Message-ID: <45C383A6.3010406@pidster.com> Date: Fri, 02 Feb 2007 18:32:06 +0000 From: Pid Reply-To: p@pidster.com Organization: Pid Inc User-Agent: Thunderbird 2.0b2 (Macintosh/20070116) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Context.INITIAL_CONTEXT_FACTORY References: <8748800.post@talk.nabble.com> <8770961.post@talk.nabble.com> In-Reply-To: <8770961.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Fran Varin wrote: > Christopher & Pid-2: > > I actually have something working although I'm not entirely sure I have a > complete understanding; there are still some gaps. I found this article --> > http://wiki.apache.org/tomcat/UsingDataSources and it helped a great > deal. > > Here is what I have done: > > Step 1 - Using Tomcat's admin console I defined the data source which > yielded > the following server.xml > > > > > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/> > className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/> > > > name="simpleValue" > type="java.lang.Integer" > value="30"/> > auth="Container" > description="User database that can be updated and saved" > name="UserDatabase" > type="org.apache.catalina.UserDatabase" > pathname="conf/tomcat-users.xml" > factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/> > name="jdbc/USER" > type="javax.sql.DataSource" > driverClassName="COM.ibm.db2.jdbc.app.DB2Driver" > password="ecomm1" > maxIdle="2" > maxWait="5000" > username="ecomm1" > url="jdbc:db2:USER" > maxActive="4"/> > > name="Catalina"> > port="8080" > redirectPort="8443" > minSpareThreads="25" > connectionTimeout="20000" > maxThreads="150" > maxSpareThreads="75"> > > port="8009" > redirectPort="8443" > protocol="AJP/1.3"> > > defaultHost="localhost" > name="Catalina"> > > appBase="webapps" > name="localhost"> > > > > > > > > Step 2 - Defined the context.xml as part of the web application (described > in the > tutorial mentioned above). > > > > > > type="javax.sql.DataSource" username="xxx" password="xxx" > driverClassName="COM.ibm.db2.jdbc.app.DB2Driver" > url="jdbc:db2:USER" > maxActive="8" > /> > > You're duplicating the Resource definition here. If you define a Global resource, you only need to put a ResourceLink in the context xml file. > Step 3 - Connect to the DB > > I used the datasource name "java:comp/env/jdbc/USER" for the connection and > this worked fine. > > > > > So, this process worked and what I'm looking to do next is to figure out a > way where I can remove the dependency on the context.xml residing in the web > application. According to what I understand from reading > the documentation this should be possible by placing the context.xml entries > in the context.xml file that resides in Tomcat's "conf" directory. Yes. If you want to make the ResourceLink available in all contexts, add the ResourceLink that refers to your global Resource into the conf/context.xml. The other > interesting point will be to see if I can remove the user id and password > from the context.xml entry. We need to externalize those for security > purposes. So, the best place is to configure them in DB2's configuration > manager. Not sure about that. Also, the pieces that I don't quite have a handle on is the actual > look up references (linkages) between all of the moving parts. That is to > say JNDI->datasource definition. Meaning? > Fran > > > > > > > > Fran Varin wrote: >> Hi, >> >> We are in the process of trying to use Tomcat 5.5.20 to access an existing >> DB2 Database. Up until this point the application has been running under >> WebSphere (We are trying to utilize Tomcat for testing purposes). In >> WebSphere we can supply an IBM JNDI Factory Class named >> "com.ibm.websphere.naming.WsnInitialContextFactory" as the >> "Context.INITIAL_CONTEXT_FACTORY". We can then find our driver and all is >> well. >> >> Clearly, in Tomcat the above mentioned class does not exist. I've been all >> over the place trying to find an equivalent class that is part of Tomcat. >> It boils down to my attempt at using >> "org.apache.naming.java.javaURLContextFactory". However, when I do I >> receive "javax.naming.NameNotFoundException: Name jdbc is not bound in >> this Context:". >> >> I need to resolve this issue in order to move forward with using Tomcat >> but, cannot seem to find a good example that explains how to do this. I've >> seen the documents that loosely describe change server.xml and creating a >> context.xml for the application. But, this seems like the wrong path given >> the way that we have always proceeded with creating DB connections. So, it >> has really just added to my confusion. >> >> Any help would be greatly appreciated, >> >> Fran >> >> > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org