Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 84540 invoked from network); 23 Aug 2005 16:02:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Aug 2005 16:02:20 -0000 Received: (qmail 20152 invoked by uid 500); 23 Aug 2005 16:02:02 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 19942 invoked by uid 500); 23 Aug 2005 16:02:01 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 19929 invoked by uid 99); 23 Aug 2005 16:02:01 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Aug 2005 09:02:01 -0700 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DNS_FROM_RFC_ABUSE X-Spam-Check-By: apache.org Received-SPF: error (asf.osuosl.org: local policy) Received: from [195.172.82.137] (HELO mail3.qas.com) (195.172.82.137) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Aug 2005 09:02:19 -0700 Received: from orion.qas.com (orion.qas.com) by mail3.qas.com (Content Technologies SMTPRS 4.3.17) with ESMTP id for ; Tue, 23 Aug 2005 17:01:37 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: jndi question Date: Tue, 23 Aug 2005 17:01:37 +0100 Message-ID: <5684A7E6FB10504393A2806C1F4C0210076CE381@orion.qas.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: jndi question Thread-Index: AcWn+a0DuX5X39c6TqOxqP4bYcl5XAAAe99A From: "Allistair Crossley" To: "Tomcat Users List" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Sean, It looks from a quick glance that your JNDI configuration is done globally,= rather than in the Context configuration, and you do not link to it using = a ResourceLink. Try adding=20 Into the Context block, and remove the Resource block you have in there. Th= e other thing to try would be to move the JNDI datasource Resource configur= ation block into the Context block. See how you get on, Allistair. > -----Original Message----- > From: Sean Rowe [mailto:ichabooka@gmail.com] > Sent: 23 August 2005 16:45 > To: Tomcat Users List > Subject: Re: jndi question >=20 >=20 > thank you, i will >=20 > Allistair Crossley wrote: >=20 > >If you could please send > > > >1. server.xml > >2. web.xml > >3. context.xml or yourwebapp.xml > >4. list of files in common/lib > >5. list of files in yourwebapp/WEB-INF/lib > > > >I'd be happy to see if I can spot anything. > > > > =20 > > > >>-----Original Message----- > >>From: Sean Rowe [mailto:ichabooka@gmail.com] > >>Sent: 23 August 2005 16:41 > >>To: Tomcat Users List > >>Subject: Re: jndi question > >> > >> > >>no, that didn't help. thanks though. > >> > >>could this maybe be a class problem? am i using the wrong=20 > >>jar files? i=20 > >>can list the files i'm using if anyone thinks it might be=20 > the problem > >> > >>Allistair Crossley wrote: > >> > >> =20 > >> > >>>Hi, > >>> > >>>The documentation says; > >>> > >>>Context initCtx =3D new InitialContext(); > >>>Context envCtx =3D (Context) initCtx.lookup("java:comp/env"); > >>>DataSource ds =3D (DataSource) > >>> envCtx.lookup("jdbc/EmployeeDB"); > >>> > >>>However, we use; > >>> > >>>try { > >>> Context ctx =3D new InitialContext(); > >>> dataSource =3D (DataSource) ctx.lookup("java:comp/env/jdbc/yourdb"); > >>>} catch (NamingException nE) { > >>> // log somewhere > >>>} catch (NullPointerException npE) { > >>> // log somewhere > >>>} > >>> > >>>Does that work for you? Allistair > >>> > >>>=20 > >>> > >>> =20 > >>> > >>>>-----Original Message----- > >>>>From: Sean Rowe [mailto:ichabooka@gmail.com] > >>>>Sent: 23 August 2005 16:29 > >>>>To: Tomcat Users List > >>>>Subject: Re: jndi question > >>>> > >>>> > >>>>Brian, thank you for replying. I was afraid my topic was=20 > >>>>dead. If you=20 > >>>>could look at my first post, I listed all the files that you have=20 > >>>>suggested I take a look at. I have done everything you have=20 > >>>>suggested,=20 > >>>>but am still getting errors. The error I am getting now is > >>>> > >>>>javax.naming.NameNotFoundException: Name java:comp is not=20 > >>>>bound in this=20 > >>>>Context > >>>> > >>>>I can't find anything on the net or in any books I've=20 > >>>> =20 > >>>> > >>looked at that=20 > >> =20 > >> > >>>>explains this. As far as I can tell, java:comp should just=20 > >>>>be there. =20 > >>>>Any ideas? Thanks again. > >>>> > >>>>Sean > >>>> > >>>>Brian Cook wrote: > >>>> > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>Yes you can use JNDI with out using JSTL. But the only way to=20 > >>>>>configure it is to define the JNDI resources in the web.xml and=20 > >>>>>context.xml files. Technically you should be able to use the=20 > >>>>>globally defined JNDI resources in server.xml, and I have seen=20 > >>>>>configuration set ups doing it when googling. But could=20 > never get=20 > >>>>>them to work. > >>>>> > >>>>>This highlights another area of seemingly unneeded=20 > complication in=20 > >>>>>Java/Unix development. Using JNDI for data sources which=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>was supposed=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>to help you save time requires that you redundantly define=20 > >>>>> =20 > >>>>> > >>the JNDI=20 > >> =20 > >> > >>>>>resource in at lest 2 if not 3 places. > >>>>> > >>>>>The admin tool which was also supposed to help save time=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>defines the=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>JNDI resources in server.xml which does not really seem to=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>be all that=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>helpful. I am sure there is likely a reason for this but I am=20 > >>>>>ignorant of it. The admin tool is also supposed to let=20 > you define=20 > >>>>>JNDI resources per context but it errors out when ever I=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>have tried it. > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>My experience with the Tomcat Admin and Manager tools is=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>that they are=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>worthless. Of the few steps they try to help with more=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>often that not=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>they just return errors when you need to use it. I removed=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>them both=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>and have gone back to doing set ups manually and there has=20 > >>>>> =20 > >>>>> > >>not been=20 > >> =20 > >> > >>>>>much of a time difference doing it this way. > >>>>> > >>>>>Any way for JNDI to work you will have to add the=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>definition for it in=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>both web.xml and context.xml in the < >>>>>Folder>>/conf/Catalina/localhost/ folder. This seems counter=20 > >>>>>productive since it makes your app less portable having the=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>data base=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>configuration details inside the context and by extent the=20 > >>>>> =20 > >>>>> > >>WAR file=20 > >> =20 > >> > >>>>>but it is what you have to do to get it to work right now. > >>>>> > >>>>>I feel your pain I know it is frustrating spending hours=20 > debugging=20 > >>>>>just the DB connection but todate that is the reality of=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>Java web app=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>development. It is why I fear we will all be .Net=20 > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>developers some day. > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>Example : > >>>>> > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-resources > >>>>-howto.html > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>> > >>>>> > >>>>>Context initCtx =3D new InitialContext(); > >>>>>Context envCtx =3D (Context) initCtx.lookup("java:comp/env"); > >>>>>DataSource ds =3D (DataSource) > >>>>> envCtx.lookup("jdbc/EmployeeDB"); > >>>>> > >>>>>Connection conn =3D ds.getConnection(); > >>>>>... use this connection to access the database ... > >>>>>conn.close(); > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> Resource reference to a factory for java.sql.Connection > >>>>> instances that may be used for talking to a particular > >>>>> database that is configured in the server.xml file. > >>>>> > >>>>> > >>>>> jdbc/EmployeeDB > >>>>> > >>>>> > >>>>> javax.sql.DataSource > >>>>> > >>>>> > >>>>> Container > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> >>>>> auth=3D"Container" > >>>>> type=3D"javax.sql.DataSource" > >>>>> username=3D"dbusername" > >>>>> password=3D"dbpassword" > >>>>> driverClassName=3D"org.hsql.jdbcDriver" =20 > >>>>> url=3D"jdbc:HypersonicSQL:database" > >>>>> maxActive=3D"8" > >>>>> maxIdle=3D"4"/> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>Sean Rowe wrote: > >>>>> > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>>>Dirk, I'm sorry I didn't see the difference on the page=20 > >>>>>> =20 > >>>>>> > >>>>>> =20 > >>>>>> > >>>>you sent me=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>>to. However, if there is a way I can do this without=20 > >>>>>> =20 > >>>>>> > >>>>>> =20 > >>>>>> > >>>>having to use=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>>jstl, I would really like to know. I was hoping to put=20 > >>>>>> =20 > >>>>>> > >>>>>> =20 > >>>>>> > >>>>the code in a=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>>class somewhere that my servlets could use. > >>>>>> > >>>>>>thanks, > >>>>>>sean > >>>>>> > >>>>>>Dirk Weigenand wrote: > >>>>>> > >>>>>> =20 > >>>>>> > >>>>>> =20 > >>>>>> > >>>>>>>Sean, > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> =20 > >>>>>>> > >>>>>>> =20 > >>>>>>> > >>>>>>>>--- Urspr=FCngliche Nachricht --- > >>>>>>>>Von: Sean Rowe > >>>>>>>>An: Tomcat Users List > >>>>>>>>Betreff: Re: jndi question > >>>>>>>>Datum: Mon, 22 Aug 2005 09:24:10 -0500 > >>>>>>>> > >>>>>>>>Thanks for responding Dirk. I've practically memorized the=20 > >>>>>>>>documentation on the link you sent: > >>>>>>>> > >>>>>>>>// Obtain our environment naming context > >>>>>>>>Context initCtx =3D new InitialContext(); > >>>>>>>>Context envCtx =3D (Context) initCtx.lookup("java:comp/env"); > >>>>>>>> > >>>>>>>>// Look up our data source > >>>>>>>>DataSource ds =3D (DataSource) > >>>>>>>>envCtx.lookup("jdbc/EmployeeDB"); > >>>>>>>> > >>>>>>>>// Allocate and use a connection from the pool > >>>>>>>>Connection conn =3D ds.getConnection(); > >>>>>>>>... use this connection to access the database ... > >>>>>>>>conn.close(); > >>>>>>>> > >>>>>>>>Whenever I try this, here's what I get (which led me to=20 > >>>>>>>> =20 > >>>>>>>> > >>>>>>>> =20 > >>>>>>>> > >>>>trying it=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>>>>the way > >>>>>>>>I posted): > >>>>>>>> > >>>>>>>>javax.naming.NameNotFoundException: Name java:comp is=20 > >>>>>>>> =20 > >>>>>>>> > >>>>>>>> =20 > >>>>>>>> > >>>>not bound in=20 > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>>>>>>this > >>>>>>>>Context > >>>>>>>> > >>>>>>>>=20 > >>>>>>>> =20 > >>>>>>>> > >>>>>>>> =20 > >>>>>>>> > >>>>>>>No. Did you look at > >>>>>>> > >>>>>>> =20 > >>>>>>> > >>>>>>> =20 > >>>>>>> > >>>>http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasourc > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>e-examples-howto.html?=20 > >>>=20 > >>> > >>> =20 > >>> > >>>>>>I recommend putting the context definition in its own=20 > >>>>>> =20 > >>>>>> > >>content.xml. On > >> =20 > >> > >>>>>>redeploying my application tomcat wouldn't find the=20 > driver class=20 > >>>>>>anymore. > >>>>>> > >>>>>>Mind you not the class itself but the definition of what=20 > >>>>>> =20 > >>>>>> > >>class to load. > >> =20 > >> > >>>>>>This problem was solved by putting the context into context.xml. > >>>>>> > >>>>>>regards > >>>>>> Dirk > >>>>>> > >>>>>> > >>>>>> > >>>>>> =20 > >>>>>> > >>>>>> =20 > >>>>>> > >>>>>----------------------------------------------------------- > >>>>> =20 > >>>>> > >>---------- > >> =20 > >> > >>>>>To unsubscribe, e-mail:=20 > tomcat-user-unsubscribe@jakarta.apache.org > >>>>>For additional commands, e-mail:=20 > >>>>> =20 > >>>>> > >>tomcat-user-help@jakarta.apache.org > >> =20 > >> > >>>>> =20 > >>>>> > >>>>> =20 > >>>>> > >>>>------------------------------------------------------------ > >>>> =20 > >>>> > >>------------ > >> =20 > >> > >>>>------------------------------------------------------------ > >>>> =20 > >>>> > >>--------- > >> =20 > >> > >>>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > >>>>For additional commands, e-mail:=20 > tomcat-user-help@jakarta.apache.org > >>>> > >>>> =20 > >>>> > >>>> =20 > >>>> > >>>----------------------------------------------------------- > ---------- > >>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > >>>For additional commands, e-mail:=20 > tomcat-user-help@jakarta.apache.org > >>> > >>> > >>> > >>>=20 > >>>------------------------------------------------------- > >>>QAS Ltd. > >>>Registered in England: No 2582055 > >>>Registered in Australia: No 082 851 474 > >>>------------------------------------------------------- > >>> > >>> > >>> > >>>----------------------------------------------------------- > ---------- > >>>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > >>>For additional commands, e-mail:=20 > tomcat-user-help@jakarta.apache.org > >>> > >>> > >>>=20 > >>> > >>> =20 > >>> > >>------------------------------------------------------------ > --------- > >>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > >>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > >> > >> > >> =20 > >> > > > > > >=20 > >------------------------------------------------------- > >QAS Ltd. > >Registered in England: No 2582055 > >Registered in Australia: No 082 851 474 > >------------------------------------------------------- > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org > > > > > > =20 > > >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org >=20 >=20 =20 ------------------------------------------------------- QAS Ltd. Registered in England: No 2582055 Registered in Australia: No 082 851 474 ------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org