tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Bowen <>
Subject DataSources and Tomcat (continue thread: Re: How to use connection pool with tomcat 1.2.9)
Date Sun, 15 Jul 2007 01:30:36 GMT
RE(David Smith):  though I'm guessing that this thread is over and 
nobody will read this follow-up. :(
Change to:  :) -- at least one follow-up reader.

RE(Chris Shultz):
   |> As I said, i did declare the tomcat dataSource in server.xml and
   |> WEB-INF/web.xml.
   |Don't do that. Since you're using Tomcat 5.5, you should declare your
   |DataSource in META-INF/context.xml, along with your Realm. Then, you
   |don't ever have to touch server.xml, which is nice.

I also want to get the Tomcat DataSource machinery working.
I'm using Tomcat 5.5.9.

I've slavishly followed the mySQL example in

But I get:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC 
driver of class '' for connect URL 'null'

[I eventually want to follow the advice above, but don't know where to
 locate the descriptions of how to carry out the META-INF type of 
 Right now, I want to understand why the example fails.  ]

I'm working on Windows (not necessarily by choice) and $CATALINA_HOME = 

The following jars (among others) are present in $CATALINA_HOME/common/lib/

The database has been created and populated using the given commands 
(wrapped in a file DBTest.sql:

    GRANT ALL PRIVILEGES ON *.* TO javauser@localhost IDENTIFIED BY 
    create database javatest;
    use javatest;
    create table testdata (id int not null auto_increment primary key, 
foo varchar(25), bar int);
    insert into testdata values(null, 'hello', 12345);
    mysql> select * from testdata;
    | id | foo   | bar   |
    |  1 | hello | 12345 |
    1 row in set (0.00 sec)
    [Connected to mysql using: mysql -u javauser -pjavadude ]

    I copied the Context (cut/paste) into server.xml --- I'll append 
that at the end of the message.

    Here's the web.xml:

    <web-app xmlns=""
      <description>MySQL Test App</description>
          <description>DB Connection</description>

    The jsp is in the file jsp/test_v4.jsp, with folder jsp at the same 
level as WEB-INF:

        <title>DB Test</title>
        foo.DBTest tst = new foo.DBTest();
        Foo <%= tst.getFoo() %><br/>
        Bar <%= tst.getBar() %>

    Here is catalina.out when Tomcat is started:

        exec ./ start -Dcatalina.base= tomcat5.exe
        Using CATALINA_BASE:   c:\Tomcat
        Using CATALINA_HOME:   c:\Tomcat
        Using CATALINA_TMPDIR: c:\Tomcat\temp
        Using JRE_HOME:       c:\Program Files\Java\jdk1.5.0
        usage: java org.apache.catalina.startup.Catalina [ -config 
{pathname} ] [ -nonaming ] { start | stop }
        Jul 14, 2007 9:13:22 PM org.apache.coyote.http11.Http11Protocol init
        INFO: Initializing Coyote HTTP/1.1 on http-8080
        Jul 14, 2007 9:13:22 PM org.apache.catalina.startup.Catalina load
        INFO: Initialization processed in 781 ms
        Jul 14, 2007 9:13:22 PM org.apache.catalina.core.StandardService 
        INFO: Starting service Catalina
        Jul 14, 2007 9:13:22 PM org.apache.catalina.core.StandardEngine 
        INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
        Jul 14, 2007 9:13:22 PM org.apache.catalina.core.StandardHost start
        INFO: XML validation disabled
        Jul 14, 2007 9:13:23 PM org.apache.coyote.http11.Http11Protocol 
        INFO: Starting Coyote HTTP/1.1 on http-8080
        Jul 14, 2007 9:13:23 PM org.apache.jk.common.ChannelSocket init
        INFO: JK: ajp13 listening on /
        Jul 14, 2007 9:13:23 PM org.apache.jk.server.JkMain start
        INFO: Jk running ID=0 time=0/20  config=null
        Jul 14, 2007 9:13:23 PM 
org.apache.catalina.storeconfig.StoreLoader load
        INFO: Find registry server-registry.xml at classpath resource
        Jul 14, 2007 9:13:23 PM org.apache.catalina.startup.Catalina start
        INFO: Server startup in 1131 ms
I point the browser at:   http://localhost:8080/DBTest/jsp/test_v4.jsp

The browser result is:

Foo Not Connected
Bar -1

The (reduced) stacktrace is:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC 
driver of class '' for connect URL 'null'
Caused by: java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getDriver(

And here is the server.xml used:

<Server port="8005" shutdown="SHUTDOWN">

  <!-- Comment these entries out to disable JMX MBeans support used for the
       administration web application -->
className="org.apache.catalina.mbeans.ServerLifecycleListener" />
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources -->

    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
       description="User database that can be updated and saved"
          pathname="conf/tomcat-users.xml" />


  <!-- Define the Tomcat Stand-Alone Service -->
  <Service name="Catalina">

    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080"    maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" enableLookups="false" redirectPort="8443" 
protocol="AJP/1.3" />

    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

          <Context path="/DBTest" docBase="DBTest"
                  debug="5" reloadable="true" crossContext="true">
            <Logger className="org.apache.catalina.logger.FileLogger"
                       prefix="localhost_DBTest_log." suffix=".txt"
            <Resource name="jdbc/TestDB"
            <ResourceParams name="jdbc/TestDB">





I'll really appreciate any help getting over this problem.  [Then I'd 
like to move on
to the META-INF -oriented approach.]

Thanks in advance,
Ken Bowen

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message