tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neil Youngman" <Neil.Young...@wirefast.com>
Subject [ERROR] Cannot create JDBC driver of class '' for connect URL 'null'
Date Mon, 27 Jul 2009 09:15:08 GMT
I'm using Java 1.6, tomcat 6.0.16/6.0.20 and axis2 1.4.1. I can't get my servlets to talk to
Oracle. All I get is "[ERROR] Cannot create JDBC driver of class '' for connect URL 'null'"

I have tried to get answers on the tomcat users list and the Axis2 users list, but after 2
weeks, I'm very little further forward and I think I'm going to have to dig into the source
code to find out where the problem lies. I would appreciate some pointers to which bits of
the source code are most relevant.

I have created a mimimal servlet purely to investigate this problem.

The code is


package com.example.dbservlet;

import java.lang.Exception;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;


public class DBServlet
{
    private static final String DB_NAME = "jdbc/TestDatabase";
    private static final String CONTEXT_NAME = "java:/comp/env";

    public DBServlet()
    {}

    private Connection getConnection ()
        throws Exception, SQLException
    {
        Context initContext = new InitialContext();
        Context envContext = (Context) initContext.lookup(CONTEXT_NAME);
        DataSource ds = (DataSource)envContext.lookup(DB_NAME);
        return ds.getConnection();
    }

    public String getTime() throws Exception, SQLException
    {
        String time = "";

        Connection conn = getConnection();
        PreparedStatement stat = conn.prepareStatement(
            "SELECT TO_CHAR( SYSDATE, 'YYYY-MM-DD HH24:MI FROM DUAL" );

        ResultSet rSet = stat.executeQuery();

        if( rSet.next() )
        {
            time = rSet.getString(1);
        }

        stat.close();
        rSet.close();

        return time;
    }
}


In servlet-example/webapps/axis2/META-INF/context.xml I have

<Context>
    <Resource name="jdbc/TestDatabase" auth="Container"
              type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
              url="jdbc:oracle:thin:@frogfoot:1521:w2"
              username="********" password="********"
              maxActive="20" maxIdle="10"
              maxWait="-1"/>
</Context>

In servlet-example/webapps/axis2/WEB-INF/web.xml I have

 ...
    <resource-ref>
        <description>Oracle Test Datasource</description>
        <res-ref-name>jdbc/TestDatabase</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
 ...

When I try to call getTime() the full traceback is

[ERROR] Cannot create JDBC driver of class '' for connect URL 'null'
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:165)
        at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class
'' for connect URL 'null'
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at com.example.dbservlet.DBServlet.getConnection(DBServlet.java:44)
        at com.example.dbservlet.DBServlet.getTime(DBServlet.java:51)
        ... 25 more
Caused by: java.lang.NullPointerException
        at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
        at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
        at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
        at java.sql.DriverManager.getDriver(DriverManager.java:253)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
        ... 28 more
[ERROR] Cannot create JDBC driver of class '' for connect URL 'null'
org.apache.axis2.AxisFault: Cannot create JDBC driver of class '' for connect URL 'null'
        at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:158)
        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

I have used strace to see whether it is accessing the context.xml file and it seems to be
checking for it's existence, but not trying t open it, as I see a stat() call, but no open()

/tmp/catalina.trace.3726:stat64("/home/neil/wirefast/dev/tomcat6/servlet-example/webapps/axis2/META-INF/context.xml",
{st_mode=S_IFREG|0644, st_size=343, ...}) = 0

Neil Youngman

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message