tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Eriksson" <Dan.Eriks...@springmobil.se>
Subject [SOLVED] tomcat not able to connect to postgresql?
Date Thu, 10 Apr 2008 03:38:35 GMT
Hi Gabe,
Thanks for the fast answer!

-----Original Message-----
From: Gabe Wong [mailto:gabrielw@ngasi.com]
Sent: Thu 4/10/2008 4:29 AM
To: Tomcat Users List
Subject: Re: tomcat not able to connect to postgresql?
 
Dan Eriksson wrote:
>> If I try to connect to my vhost now everything looks ok, no errors anywhere, but
when I try to login I get a message that the database is not online and in my logfile I see
this:
>>
>> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class
'' for connect UR
>>   
>Dan,
>This has been discussed many times before. Usually adding the database 
>driver to $TOMCAT_HOME/lib or $TOMCAT_HOME/common/lib
>solves the problem.
>Also further information maybe found at the following URL from the 
>mailing list archive, which is a good way to search for previously 
>discussed issues and solutions:
>http://marc.info/?l=tomcat-user&m=119454595817475&w=2

Indeed, I missed that one.
Adding everything from my lib dir to common/lib didn't solve it though.

I went through the documentation again,
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations
Under the postgresql there are two different configurations, first a generic resource that
can be shared, which was what I was trying, and one that is specific resource per vhost.
I re-made the configuration to be specific per vhost instead, so my vhost configuration looked
like this instead:

      <Host name="myapp.mydomain.com" appBase="webapps/myapp"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

        <Context path="" docBase="" debug="0" reloadable="true">
    <Resource
              name="jdbc/springmobil_db"
              type="javax.sql.DataSource"
              password="mypasswd"
              driverClassName="org.postgresql.Driver"
              maxIdle="2"
              maxWait="5000"
              validationQuery="SELECT 1"
              username="myapp"
              url="jdbc:postgresql://10.10.120.80/myapp_db"
              maxActive="4"/>
        </Context>
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="vaxeladmin_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
      </Host>

After doing this it started to work as it should.

But if someone can explain why the generic resource didn't work it would be greatly appreciated!

Best regards,
Dan


Mime
View raw message