Yes I have..I have been trying for the last week
to figure it out. I have found the same thing that
BasicDataSource does not load the driverClassName.
I have put my jdbcdriver.jar file in the common/lib
dir..and I know it's in the classpath of tomcat as I
can write a jsp page with a Class.forName and have
it work fine.The problem only surfaces when doing
jndi Datasource lookups. The driverClassName from
the server.xml file is never passed to BasicDataSource.

If anyone can spot errors in my configuration please
let me know, thanks..


I know that the server.mxl is being read from my logs:

2003-01-10 11:22:29 NamingContextListener[/Apache/localhost/intranet]: Creating JNDI 
naming context
2003-01-10 11:22:29 NamingContextListener[/Apache/localhost/intranet]:   Resource 
parameters for jdbc/TestDB = ResourceParams[name=jdbc/TestDB, 
parameters={factory=org.apache.commons.dbcp.BasicDataSourceFactory, password=user, 
url=jdbc:jtds:sqlserver://ns1:1433/WebDB, 
driverClassName=net.sourceforge.jtds.jdbcx.TdsDataSource, username=webuser}]
2003-01-10 11:22:29 NamingContextListener[/Apache/localhost/intranet]:   Adding 
resource ref jdbc/TestDB
2003-01-10 11:22:29 NamingContextListener[/Apache/localhost/intranet]:   
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=password,content=user},{type=url,content=jdbc:jtds:sqlserver://ns1:1433/WebDB},{type=driverClassName,content=net.sourceforge.jtds.jdbcx.TdsDataSource},{type=username,content=webuser}]

Here is the error from catalina.out:

new context
ctx lookup
gonna try a ds.getConnection
java.sql.SQLException: Cannot load JDBC driver class 'null'
        at 
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529)
        at 
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
        at foo.DBTest.init(DBTest.java:34)
        at org.apache.jsp.test_jsp._jspService(test_jsp.java:49)


Here is my server.xml:

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

  <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
  </GlobalNamingResources>

  <Service name="Tomcat-Apache">

    <Connector className="org.apache.catalina.connector.warp.WarpConnector"
     port="8008" minProcessors="5" maxProcessors="75"
     enableLookups="true" appBase="webapps"
     acceptCount="10" debug="5"/>

    <!-- Replace "localhost" with what your Apache "ServerName" is set to -->
    <Engine className="org.apache.catalina.connector.warp.WarpEngine"
     name="Apache" debug="5">

      <Host name="localhost" debug="5" appBase="webapps"
       unpackWARs="true" autoDeploy="true">

        <Context path="/intranet" docBase="intranet"
           debug="5" reloadable="true" crossContext="true">

          <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/TestDB">
            <parameter>
              <name>factory</name>
              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
            </parameter>
            <parameter>
              <name>driverClassName</name>
              <value>net.sourceforge.jtds.jdbcx.TdsDataSource</value>
            </parameter>
            <parameter>
              <name>url</name>
              <value>jdbc:jtds:sqlserver://ns1:1433/WebDB</value>
            </parameter>
            <parameter>
             <name>username</name>
             <value>webuser</value>
            </parameter>
            <parameter>
             <name>password</name>
             <value>user</value>
            </parameter>
          </ResourceParams>

          <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="intranet_log." suffix=".txt"
                  timestamp="true"/>

        </Context>

      </Host>
    </Engine>
  </Service>

</Server>

And here is the webapps/intranet/WEB-INF/web.xml:

<?xml version="1.0"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd";>

<web-app>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/TestDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
</web-app>





> Has anyone else experienced this????
> I have read a couple of posts that I found off google,
> and basically what they are saying is non of the information in
> the server.xml file is being passed to the Datasource or something of
> that nature.

> The suggested fix was to hardcode everything but that kind of defeats
> the purpose.
>
> > I have experience that before, but that was my fault rather than tomcat.
> > I put the source jar instead of the driver binary. Other than that  DBCP
> >  worked as described in the tomcat documents. Cannot load JDBC driver
> > class null usually means that it couldn't find the jdbc driver that you
> > specified in the server.xml .
>
> that is strange cause I have it in
> $CATALINA_HOME/common/lib
>
> And it is exactly the same class that I used when I was using JDBC
> non-jndi.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to