Thread: tomcat/postgres problem

tomcat/postgres problem

From
"Jason Dinger"
Date:
I'm trying to load the postgresql driver into tomcat using the server.xml file and web.xml file, but I keep getting the following error:
 
javax.naming.NamingException: DbcpDataSourceFactory: driverClassName is required
 
Here's part of my server.xml file:
 
    <Resource name="jdbc/MyDB" scope="Shareable" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/MyDB">
      <parameter>
        <name>validationQuery</name>
        <value></value>
      </parameter>
      <parameter>
        <name>user</name>
        <value>Jason</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>4</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:postgresql:mydb</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value> </value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>org.postgresql.Driver</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>2</value>
      </parameter>
    </ResourceParams>
 
And here's part of my web.xml file
 
<resource-ref>
  <description>
    Postgresql driver
  </description>
  <res-ref-name>
    jdbc/MyDB
  </res-ref-name>
  <res-type>
    javax.sql.DataSource
  </res-type>
  <res-auth>
    Container
  </res-auth>
</resource-ref>
 
 
I know I can load the driver with Class.forName().  That works too.  But how do I get the driver loaded via the server.xml and web.xml files?  Any suggestions?
 
 
- Jake

Re: tomcat/postgres problem

From
Pedro Salazar
Date:
Hi Jason,

I think this could be a missing <ResourceParams> in your web application
context in your server.xml. I mean, you need to declare your
<ResourceParams> inside your web <Context> element or inside your
<DefaultContext> element? If not, try do it to because I think that what
is happening is that your web.xml declares a <resource-ref> but there is
no <ResourceParams> available to configure it.

So, the first error (exception) is that it cannot find the
driverClassName because it cannot read the <ResourceParams> (like it was
null).

P.S.- I think this is a Tomcat/DBCP forum question...

Regards,
Pedro Salazar.

On Wed, 2003-04-09 at 20:40, Jason Dinger wrote:
> I'm trying to load the postgresql driver into tomcat using the
> server.xml file and web.xml file, but I keep getting the following
> error:
>
> javax.naming.NamingException: DbcpDataSourceFactory: driverClassName
> is required
>
> Here's part of my server.xml file:
>
>     <Resource name="jdbc/MyDB" scope="Shareable"
> type="javax.sql.DataSource"/>
>     <ResourceParams name="jdbc/MyDB">
>       <parameter>
>         <name>validationQuery</name>
>         <value></value>
>       </parameter>
>       <parameter>
>         <name>user</name>
>         <value>Jason</value>
>       </parameter>
>       <parameter>
>         <name>maxWait</name>
>         <value>5000</value>
>       </parameter>
>       <parameter>
>         <name>maxActive</name>
>         <value>4</value>
>       </parameter>
>       <parameter>
>         <name>url</name>
>         <value>jdbc:postgresql:mydb</value>
>       </parameter>
>       <parameter>
>         <name>password</name>
>         <value> </value>
>       </parameter>
>       <parameter>
>         <name>driverClassName</name>
>         <value>org.postgresql.Driver</value>
>       </parameter>
>       <parameter>
>         <name>maxIdle</name>
>         <value>2</value>
>       </parameter>
>     </ResourceParams>
>
> And here's part of my web.xml file
>
> <resource-ref>
>   <description>
>     Postgresql driver
>   </description>
>   <res-ref-name>
>     jdbc/MyDB
>   </res-ref-name>
>   <res-type>
>     javax.sql.DataSource
>   </res-type>
>   <res-auth>
>     Container
>   </res-auth>
> </resource-ref>
>
>
> I know I can load the driver with Class.forName().  That works too.
> But how do I get the driver loaded via the server.xml and web.xml
> files?  Any suggestions?
>
>
> - Jake
--
PS
pedro-b-salazar@ptinovacao.pt
PGP:0E129E31D803BC61