On 12/06/2023 16:52, Ying Jin wrote:
BTW, the ojdbc6_g.jar has been put in the Tomcat9.0.75/lib folder as well as in the project's WEB-INF/lib folder.

Don't do that. Put it *only* in $CATALINA_BASE/lib


On Mon, Jun 12, 2023 at 10:41 AM Ying Jin <jiny4...@gmail.com <mailto:jiny4...@gmail.com>> wrote:

    Mark,

    Thanks for your reply! Please see below for the details. BTW, I
    removed the database connection info. for security reasons. The same
    data source configuration and jdbc driver "ojdbc6_g" works in the
    Weblogic 14 server.

    web.xml:
       <resource-ref>
      <description>project datasource</description>
      <res-ref-name>jdbc/ariesDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>

    Tomcat 9.0.75 conf/context.xml:

Putting it there means you have created one instance of the resource for each deployed web application. You probably want to put it in:

$CATALINA_BASE/conf/<engine-name>/<host-name>/<context-name>.xml

But maybe wait until you have it working before fixing that.

      <Resource auth="Container"
    driverClassName="oracle.jdbc.OracleDriver" maxIdle="10"
    maxTotal="20" maxWaitMillis="-1" name="jdbc/ariesDS" password="PW"
    type="javax.sql.DataSource"
    url="jdbc:oracle:thin@hostname:portNumber/servic name"
    username="userName"/>

    Datasource lookup code:

        Context initContext = new InitialContext();
         Context envContext  =
    (Context)initContext.lookup("java:/comp/env");
         DataSource ods = (DataSource)envContext.lookup("jdbc/ariesDS");
        if (ods==null)
         {
            System.out.println("ods = (OracleDataSource)
    envCtx.lookup('jdbc/ariesDS') is null");
            throw new Exception ("the data souce is null, error throwed.");
         }else{
            conn = ods.getConnection();
         }

    The database version is Oracle 19C and I found out the Oracle jdbc
    driver should be ojdbc8.jar. If using this version of jar file, any
    code changes need to be done for the data source lookup code?

No. The lookup code should be fine.

    The complete stacktrace:
    image.png

Embedded images don't work. Please paste the full stack trace and/or post it online somewhere we can read it.

Mark



    Your help is greatly appreciated!

    Thanks,
    Jenny

    On Mon, Jun 12, 2023 at 3:26 AM Mark Thomas <ma...@apache.org
    <mailto:ma...@apache.org>> wrote:

        On 11/06/2023 19:33, Ying Jin wrote:
         > Hello,
         >
         > We have an old java servlet web application which uses the
        "ojdbc6_g" jar
         > as Oracle jdbc driver and it works in Weblogic 14 server.
        Recently, we need
         > to try to see if this application can be deployed to Tomcat
        or not.
         >
         > The JDBC data source has been configured in Tomcat 9.0.75
        server according
         > to instructions below,
         >
         >
        https://tomcat.apache.org/tomcat-9.0-doc/jndi-resources-howto.html 
<https://tomcat.apache.org/tomcat-9.0-doc/jndi-resources-howto.html>
         >
         > Please see below for the error we encountered in the Tomcat 9
        deployment
         > and help shed some light on this problem. The Oracle database
        version is
         > 19c.
         >
         > Error: Cannot create JDBC driver of class
        'oracle.jdbc.OracleDriver' for
         > connect URL 'jdbc:oracle:thin@xxx
         >
         > java.sql.SQLException: Cannot create JDBC driver of class
         > 'oracle.jdbc.OracleDriver' for connect URL 'jdbc:oracle:thin@
         >
        <http://jdbc:oracle%3at...@vdb04ld.hs.it.vumc.io:10920/ARDEV.vumc.vanderbilt 
<http://jdbc:oracle%3at...@vdb04ld.hs.it.vumc.io:10920/ARDEV.vumc.vanderbilt>>
         > xxxx'
         > at
         >
        
org.apache.tomcat.dbcp.dbcp2.DriverFactory.createDriver(DriverFactory.java:74)
         > at
         >
        
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:465)
         > at
         >
        
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:529)
         > at
         >
        
org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:710)

        And the rest of the stack trace is?

        ojdbc6_g.jar has been placed where in the file system?

        That is a *very* old Oracle JDBC driver. It is also the debug
        version of
        the JAR. You might want to think about using the latest one for
        Oracle 19c.

        The changes to the configuration are? (Yes, I know you said you
        followed
        the docs but we still need to know what you actually changed. Not
        everyone follows the docs correctly.)

        Mark

        ---------------------------------------------------------------------
        To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
        <mailto:users-unsubscr...@tomcat.apache.org>
        For additional commands, e-mail: users-h...@tomcat.apache.org
        <mailto:users-h...@tomcat.apache.org>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to