Thanks Harry but the problem is that it is not even trying to load the
Postgres driver - it is not getting that far. It is trying to load JDBC
driver class '' (empty string) and is trying to access JDBC URL of
'null'. It seems that the ResourceParams section is not being used. 

I do have the postgres jar deployed to common/lib.

Thanks.

On Mon, 2004-04-05 at 14:52, Harry Mantheakis wrote:

> Hello
> 
> 
> > My web.xml contains:
> 
> 
> That looks the same as mine (which works) so no problem there. You do not
> actually *need* this element in the deployment descriptor if you are using
> Tomcat 5, but it makes your code portable, should you ever (God forbid!)
> switch to another servlet container.
> 
> 
> > My $TOMCAT_HOME/conf/server.xml contains the following...
> 
> 
> BTW, it is $CATALINA_HOME that matters - $TOMCAT_HOME is not used.
> 
> Looking at your resource definitions, this sub-element:
> 
> 
> <parameter>
>      <name>url</name>
>      <value>
>          jdbc:postgresql://localhost/mydb
>      </value>
> </parameter>
> 
> 
> Maybe should read:
> 
> 
> <parameter>
>      <name>url</name>
>      <value>
>          jdbc:postgresql://localhost:5432/mydb
>      </value>
> </parameter>
> 
> 
> Mine, at least, needs a port number to be specified.
> 
> The rest of the resource element looks okay to me. Also, your look-up code
> looks good too, so my only guess is that you have forgotten to put the
> PostgreSQL JDBC driver under the container's classpath.
> 
> You probably have the driver located under your application's 'WEB-INF/lib'
> directory.
> 
> Try placing the driver in the '$CATALINA_HOME/common/lib' directory, but do
> not have it both places! (Remove it from the 'WEB-INF/lib' directory.)
> 
> Also, make sure you have a driver named 'pg74.1jdbc3.jar'. The one that
> comes bundled with the PostgreSQL 7.4 RPM is out of date. You can download
> the 7.4 driver from PG's JDBC site.
> 
> Good luck.
> 
> Harry Mantheakis
> London, UK
> 
> 
> 
> 
> > Hi,
> > 
> > I am trying to convert my Tomcat web application to use JNDI to lookup a
> > DataSource rather than using DriverManager directly. My application
> > works fine using DriverManager so I know I have my classpath set up
> > correctly. 
> > 
> > The problem I have seems to be a very common one yet I cannot find a
> > solution to it using Google. I am getting the following error message
> > when I attempt to look up a DataSource:
> > 
> > Cannot create JDBC driver of class '' for connect URL 'null'
> > 
> > This implies to me that Tomcat is recognizing my <Resource> declaration
> > in my conf/server.xml but is not loading the associated
> > <ResourceParams>. I get this problem with Tomcat 4.1 and 5.0 on Red Hat
> > 9 with Sun JDK 1.4.2.
> > 
> > My web.xml contains:
> > 
> > <resource-ref>
> >   <description>DB Connection</description>
> >   <res-ref-name>jdbc/mydb</res-ref-name>
> >   <res-type>javax.sql.DataSource</res-type>
> >   <res-auth>Container</res-auth>
> > </resource-ref>
> > 
> > My $TOMCAT_HOME/conf/server.xml contains the following (I have tried
> > defining this within the context of my webapp and also in the
> > GlobalNamingResources section).
> > 
> > <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
> > />
> >                  
> > <ResourceParams name="jdbc/mydb">
> >   <parameter>
> >     <name>factory</name>
> >     <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> >   </parameter>
> >   <parameter>
> >     <name>maxActive</name>
> >     <value>100</value>
> >   </parameter>
> >   <parameter>
> >     <name>maxIdle</name>
> >     <value>30</value>
> >   </parameter>
> >   <parameter>
> >     <name>maxWait</name>
> >     <value>10000</value>
> >   </parameter>
> >   <parameter>
> >    <name>username</name>
> >    <value>ebay</value>
> >   </parameter>
> >   <parameter>
> >    <name>password</name>
> >    <value></value>
> >   </parameter>
> >   <parameter>
> >      <name>driverClassName</name>
> >      <value>org.postgresql.Driver</value>
> >   </parameter>
> >   <parameter>
> >     <name>url</name>
> >     <value>jdbc:postgresql://localhost/mydb</value>
> >   </parameter>
> > </ResourceParams>
> > 
> > Lastly, my Java code is as follows:
> > 
> > InitialContext initCtx = new InitialContext();
> > Object obj = initCtx.lookup( "java:comp/env/jdbc/mydb" );
> > DataSource ds = (DataSource) obj;
> > return ds.getConnection();
> > 
> > Does anyone have JNDI working with Tomcat? Any help would be much
> > appreciated!
> > 
> > Thanks,
> > 
> > Andy Grove.
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Reply via email to