Discussions

Web tier: servlets, JSP, Web frameworks: Error configuring JNDI DataSource

  1. Error configuring JNDI DataSource (5 messages)

    I've tried to port my webapp from Tomcat 5.0.18 on Windows 2000 to Tomcat 5.5 on Windows 2003 server, with jdk1.5.
    I get this error: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

    I set the datasource inside server.xml:
    <Context ...>
    <Resource name="jdbc/glprod" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/glprod">
    <parameter>
    <name>url</name>
    <value>jdbc:oracle:thin:@sunlander:1521:GLTEST</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>10000</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>GL_DYNAMO</value>
    </parameter>
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>minIdle</name>
    <value>2</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>GL_DYNAMO</value>
    </parameter>
    </ResourceParams>
    </Context>

    This works on Tomcat 5.0, but it seems that doesn't works with Tomcat 5.5. Why?
    What is the correct place of jdbc driver?
    WEB-INF/lib or common/lib?

    Thanks all

    Threaded Messages (5)

  2. Error configuring JNDI DataSource[ Go to top ]

    Hi Aldo,

    I believe the driver class needs to be in $CATALINA_HOME/common/lib for the tomcat-level JNDI datasource stuff to work. If you put it there, your application should be able to see it, too.

    HTH,

    P
  3. Error configuring JNDI DataSource[ Go to top ]

    Thanks, now it works.
    I use the syntax:

    <Context>
    .....
    <Resource name="jdbc/glprod" type="javax.sql.DataSource" password="YYYYY" driverClassName="oracle.jdbc.driver.OracleDriver" maxIdle="2" maxWait="5000" username="XXXXX" url="jdbc:oracle:thin:@128.3.128.60:1521:GLTEST" maxActive="4"/>
    </Context>

    Another question about monitoring/management:
    I have to set, to enable remote management the property
    com.sun.management.jmxremote.port=portNum

    But tomcat doesn't start ... on event viewer I find this message

    The Apache Tomcat service terminated unexpectedly. It has done this 7 time(s).

    If I set com.sun.management.jmxremote (for local management) Tomcat starts, but I can't see nothig to manage (with JConsole as example).

    Any suggests?
  4. Tomcat JXM[ Go to top ]

    Another question about monitoring/management:I have to set, to enable remote management the property com.sun.management.jmxremote.port=portNum
    But tomcat doesn't start
    I have a similar problem and haven't been able to find a solution so far. I try to connect to MC4J to Tomcat 5.5.4 on Windows XP with J2SE 5.0 Update 1.
    Any help would be really appreciated.
  5. I am trying to setup an oracle JNDI datasource in Tomcat 5.5 but I get the following error when creating the datasource :

         SQLNestedException
         SQLException: No suitable Driver
         DriverManager.getDriver
         BasicDataSource.createDataSource

    I already downloaded ojdbc14.jar and placed them in the \common\lib directory but the problem still occurs.

    I also tried to include the code
    Class.forName("oracle.jdbc.driver.OracleDriver");
    before creating the datasource but an error still occurs, though at that time the error was different, something about acceptsURL.

    I suspect the ojdbc14.jar I am using only works for jdk1.4, does someone know where I can get an Oracle 10g JDBC Driver for j2sdk 1.5?

    But when I run the code using the jar in a standard java application it works. I used the following code

         OracleDataSource dsrc = new OracleDataSource();
         dsrc.setDriverType("thin");
         dsrc.setServerName("<server>");
         dsrc.setDatabaseName("AIX");
         dsrc.setPortNumber(1521);
         dsrc.setUser("<username>");
         dsrc.setPassword("<password>");

         con = dsrc.getConnection();

    Does anyone know of a solution? Thanks in advance.
  6. Error configuring JNDI DataSource[ Go to top ]

    Ok, I may be a bit late on this but it seems that in Tomcat 5.5, the way you configure your context.xml has changed. This is what I had for 4.1. I don't know about 5.0 but from the original post, it looks like the same as 4.1.

    <Context debug="0" docBase="/blah" path="/blah" reloadable="true">
        <!-- Development Database -->
        <Resource name="jdbc/blahdb" auth="Container" type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/blahdb">
          <parameter>
             <name>username</name>
             <value>johndoe</value>
          </parameter>
           <parameter>
              <name>password</name>
              <value>johndoepw</value>
           </parameter>
            <parameter>
              <name>driverClassName</name>
              <value>oracle.jdbc.driver.OracleDriver</value>
            </parameter>
            <parameter>
                <name>url</name>
                <value>jdbc:oracle:thin:@db.fubar.com:1521:db</value>
            </parameter>
        </ResourceParams>
    </Context>

    in 5.5 is:

    <Context debug="0" docBase="/blah" path="/blah" reloadable="true">
        <!-- Development Database -->
        <Resource name="jdbc/blahdb" auth="Container"
        type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.driver.OracleDriver"
        url="jdbc:oracle:thin:@db.fubar.com:1521:fubar"
        user="johndoe"
        password="johndoepw"/>
    </Context>

    Also, I found that in going from 4.0 to 4.1, username became user, and driverName became url.

    This post is not based on any expertise, just a lot of head banging on wall trial and error.

    Regards,

    John