Depends on how you are deploying your app. 1) If deploying as an expanded folder, name the context.xml file after your webapp and place it in conf/Catalina/localhost. For example, if your app is called tutorial, it would have it's <Context> element in the file $CATALINA_BASE/conf/Catalina/localhost/tutorial.xml where $CATALINA_BASE is the top level of your tomcat installation.
2) If deploying as a .war file, the file is named 'context.xml' and placed in the META-INF directory of the war archive. Tomcat will read it when deploying the application. --David Mattier, Ricardo wrote: >Where should the context.xml file be placed, and what else should go in >this file? I'll rename my jar file to see if that works too? Thanks! > > >Rick Mattier >Systems Analyst II >Wind River Systems >Canton: 781 364-2002 >Nashua 603 897-2084 >Email: [EMAIL PROTECTED] > >-----Original Message----- >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >Sent: Monday, September 12, 2005 6:16 AM >To: Tomcat Users List >Subject: Re: Trying to connect tomcat5 with postgresql database > >And make sure the driver you downloaded matches your server version. >Also, for some reason, my setup wouldn't work until I renamed the driver >to postgresql.jar from pg74.216.jdbc3.jar. > > > > >>Hi Rick -- >> >><Resource auth="Container" >> description="PostgresSQL Connection Pool" >> name="jdbc/postDB" type="javax.sql.DataSource" >> driverClassName="org.postgresql.Driver" >> url="jdbc:postgresql://localhost:5432/test" >> /> >> >>Good, just make sure you get the rest of the parameters in there like >>username="xxxx" and password="xxxxx". The <ResourceParams> elements >>are not used in tomcat 5.5. Also you mentioned this is in server.xml. >> >> > > > >>It should be inside the <Context> element of the context.xml file used >> >> > > > >>in your deployment. >> >> <resource-ref> >> <res-ref-name>jdbc/postDB</res-ref-name> >> <res-type>javax.sql.DataSource</res-type> >> <res-auth>Container</res-auth> >> </resource-ref> >> >>The web.xml looks good. The only other thing I can think of is to be >>sure the driver jar file is in common/lib. >> >> >>Edoardo Panfili wrote: >> >> >> >>>I miss a part of my web.xml >>> >>>=========================================================== >>><web-app> >>> <resource-ref> >>> <description>postgreSQL Datasource</description> >>> <res-ref-name>jdbc/lisy</res-ref-name> >>> <res-type>javax.sql.DataSource</res-type> >>> <res-auth>Container</res-auth> >>> </resource-ref> >>> >>> <display-name>lisy</display-name> >>> >>>.......... >>> >>>============================================================== >>> >>>Edoardo >>> >>> >>>Mattier, Ricardo wrote: >>> >>> >>> >>>>I duplicated your configuration for the server.xml file, and I came >>>> >>>> > > > >>>>up with the same error. >>>>-----Original Message----- >>>>From: Edoardo Panfili [mailto:[EMAIL PROTECTED] Sent: Saturday, >>>>September 10, 2005 7:49 AM >>>>To: Tomcat Users List >>>>Subject: Re: Trying to connect tomcat5 with postgresql database >>>> >>>>This is my configuration server.xml >>>>============================================================ >>>><Resource name="jdbc/guidebook" auth="Container" >>>>type="javax.sql.DataSource"/> >>>><ResourceParams name="jdbc/lisy"> >>>><parameter> >>>><name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceF >>>>actor >>>>y</value> >>>></parameter> >>>><parameter> >>>><name>driverClassName</name><value>org.postgresql.Driver</value> >>>></parameter> >>>><parameter> >>>><name>url</name><value>jdbc:postgresql://127.0.0.1:5432/lisy</value >>>> >>>> >>>></parameter> >>>><parameter> >>>><name>username</name><value>UNAME</value> >>>></parameter> >>>><parameter> >>>><name>password</name><value>PWD</value> >>>></parameter> >>>><parameter> >>>><name>initialSize</name><value>3</value> >>>></parameter> >>>><parameter> >>>><name>maxActive</name><value>5</value> >>>></parameter> >>>><parameter> >>>><name>maxIdle</name><value>5</value> >>>></parameter> >>>> <parameter> >>>><name>minIdle</name><value>3</value> >>>></parameter> >>>><parameter> >>>><name>maxWait</name><value>-1</value> >>>></parameter> >>>><parameter> >>>><name>removeAbandoned</name><value>true</value> >>>></parameter> >>>><parameter> >>>><name>removeAbandonedTimeout</name><value>60</value> >>>></parameter> >>>><parameter> >>>><name>logAbandoned</name><value>true</value> >>>></parameter> >>>></ResourceParams> >>>> >>>>============================= conde inside the servlet======== >>>> >>>>Context ambiente =( >>>> Context) new InitialContext().lookup("java:comp/env"); >>>> >>>>DataSource pool = (DataSource) ambiente.lookup("jdbc/lisy"); >>>> >>>>Connection c=pool.getConnection(); >>>> >>>>============================================================== >>>> >>>>I am using Postgres 7.4 and Tomcat 5.0 >>>> >>>>Edoardo >>>> >>>> >>>> >>>>Mattier, Ricardo wrote: >>>> >>>> >>>> >>>>>Hello, I'm currently working with Tomcat5 on Solaris10 x86 >>>>>machine. I'm running into problems when trying to access a >>>>>postgresql 8.0.1 database on the local machine. Cannot create JDBC >>>>> >>>>> > > > >>>>>driver of class '' for connect URL null' is the error I receive >>>>>when trying to establish >>>>> >>>>> >>>>a connection. >>>> >>>> >>>> >>>>>Here's the snipet of code I used in my .jsp: >>>>>Context ctx = new InitialConection(); >>>>> >>>>>DataSource ds = >>>>>(DataSource)ctx.lookup("java:comp/env/jdbc/postDB"); >>>>> >>>>>Connection con = ds.getConnection(); >>>>> >>>>> I noticed it would compile fine if I remove the getConnection >>>>> >>>>> >>>>line. >>>> >>>> >>>> >>>>>Once I add it back in, the above error appears. I've followed >>>>>the instructions on the jakarta page, and thought I made the >>>>>correct insertions in both server.xml, and WEB-INF/web.xml. Here >>>>>are the entries >>>>>used: >>>>> server.xml >>>>><Resource auth="Container" >>>>> description="PostgresSQL Connection Pool" >>>>> name="jdbc/postDB" type="javax.sql.DataSource" >>>>> driverClassName="org.postgresql.Driver" >>>>> url="jdbc:postgresql://localhost:5432/test" >>>>> /> >>>>> <ResourceParams name="jdbc/postDB"> >>>>> <parameter> >>>>> <name>driverClassName</name> >>>>> <value>org.postgresql.Driver</value> >>>>> </parameter> >>>>> <parameter> >>>>> <name>url</name> >>>>> >>>>> >>>>> >>>>> ><value>jdbc:postgresql://localhost:5432/test?autoConnect=true</value> > > >>>>> </parameter> >>>>> <parameter> >>>>> <name>username</name> >>>>> <value>postgres</value> >>>>> </parameter> >>>>> <parameter> >>>>> <name>password</name> >>>>> <value>postgres</value> >>>>> </parameter> >>>>> <parameter> >>>>> <name>maxIdle</name> >>>>> <value>2</value> >>>>> </parameter> >>>>> <parameter> >>>>> <name>maxActive</name> >>>>> <value>10</value> >>>>> </parameter> >>>>> </ResourceParams> >>>>>Here is the web.xml: >>>>> <resource-ref> >>>>> <res-ref-name>jdbc/postDB</res-ref-name> >>>>> <res-type>javax.sql.DataSource</res-type> >>>>> <res-auth>Container</res-auth> >>>>> </resource-ref> >>>>> >>>>>Thanks in advance! >>>>>-Rick Mattier >>>>> >>>>>------------------------------------------------------------------ >>>>>--- 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] >>>> >>>> >>>>------------------------------------------------------------------- >>>>-- 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] >>> >>> >>> >>-- >>David Smith >>Network Operations Supervisor >>Department of Entomology >>Cornell University >>2132 Comstock Hall >>Ithaca, NY 14853 >>Phone: (607) 255-9571 >>Fax: (607) 255-0940 >> >> >>--------------------------------------------------------------------- >>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] > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > -- ======================================= David Smith Network Operations Supervisor Department of Entomology College of Agriculture & Life Sciences Cornell University 2132 Comstock Hall Ithaca, NY 14853 Phone: 607.255.9571 Fax: 607.255.0939 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]