Remy Maucherat, can you elobarate on this deployer client? You talked about it, but it can nowhere be found. I'm still very stuck on this matter and don't have a way of fixing it... Deploying is a pain in the ass now compared to the convenient way of building with ant...

From: Ilja Hehenkamp <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Re: Tomcat, MySQL & JNDI: java.sql.SQLException: Cannot load JDBC driver class 'null'
Date: Fri, 19 Sep 2003 19:37:46 +0200



Sorry, I don't really understand what you mean?

Do you mean I shouldn't use the build file anymore? If so: that's too bad,
since I like the way of automated updating the tomcat manager...



I'm sure you do. You seem to be stuck on that particular page of the docs, however, which happens to be out of date, and doesn't actually mention what is important. Read the deployer page instead (http://jakarta.apache.org/tomcat/tomcat-5.0-doc/deployer-howto.html ).

But still: I don't know how to fix the problem: why doesn't the jndi
datasource work with the through ant deployed application?

Because I don't think your stuff in server.xml is used at all.


That's much better.

I recommend you use the deployer package instead. The instructions  from
appdev are going to be updated or removed.

I think I know where lies the problem, however I still don't know how to fix
it...


I use the sample build.xml file from Tomcat:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/ build.xml.txt to
install, reload and distribute my sample application.


When I do an ant -install it apparantly installs the application in the
Tomcat manager, however the application doesn't show up in the webapps
directory. That's 1.


So maybe there's a conflict with either the context path, which I don't
think so, since my build file has explicitly set the context path to
/DBTest:


  <property name="app.name"      value="DBTest"/>
  <property name="app.path"      value="/${app.name}"/>
  <property name="app.version"   value=""/>
  <property name="build.home"    value="${basedir}/build"/>
  <property name="catalina.home" value="/Library/Tomcat"/> <!-- UPDATE THIS!
-->
  <property name="dist.home"     value="${basedir}/dist"/>
  <property name="docs.home"     value="${basedir}/docs"/>
  <property name="manager.url"   value=" http://localhost:8080/manager "/>
  <property name="src.home"      value="${basedir}/src"/>
  <property name="web.home"      value="${basedir}/web"/>


Or there's a conflict with the docbase, which I suspect... However I'm not
sure why and how to fix it....


Because when I put the generated war file (when doing an ant -dist) in the
webapps directory the connection works! Although this works, it's not very
convenient, since it defeats the purpose of the automated installing through
ant...


Hope I made myself clear?


Ok, first some configuration information:

Tomcat 5.09
MySQL Driver 3.08 stable
OS: Mac OSX 10.2.6
J2SE 1.4.2

all commons libraries reside in $CATALINA_HOME/common/lib
MySQL Driver resides in $CATALINA_HOME/common/lib as well

I tried setting up a simple JNDI datasource connection but get  the  
following error message:

java.sql.SQLException: Cannot load JDBC driver class 'null'
        at  
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataS ource
.java:529)
        at  
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSour ce.ja
va:312)
        at foo.DBTest.init(DBTest.java:24)
        at foo.TestServlet.doGet(TestServlet.java:34)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
          ....
          ....


The code and examples are taken from  
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-
examples-howto.html

I have searched through tons of archives and websites and mostly this  
error could be resolved by placing the driver and commons in the  
common/lib directory. However in my case they are there, so I cannot  
figure out what's the problem...


server.xml:

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

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

      <Resource name="jdbc/TestDB"
                auth="Container"
                type="javax.sql.DataSource"/>

  <ResourceParams name="jdbc/TestDB">
   <parameter>
    <name>driverClassName</name>
    <value>org.gjt.mm.mysql.Driver</value>
   </parameter>
   <parameter>
    <name>username</name>
    <value>xxx</value>
   </parameter>
   <parameter>
    <name>password</name>
    <value>xxx</value>
   </parameter>
   <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost/javatest?autoReconnect=true</ value>
   </parameter>
  </ResourceParams>
</Context>

web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
     <!DOCTYPE web-app PUBLIC
     "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
     " http://java.sun.com/dtd/web-app_2_3.dtd ">
<web-app>
   <description>MySQL Test App</description>
   <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>

   <servlet>
       <servlet-name>DBTestServlet</servlet-name>
       <description>
         Bla...
       </description>
       <servlet-class>foo.TestServlet</servlet-class>
   </servlet>

   <servlet-mapping>
       <servlet-name>DBTestServlet</servlet-name>
       <url-pattern>/DBTestServlet</url-pattern>
   </servlet-mapping>
</web-app>



_________________________________________________________________ MSN Zoeken, voor duidelijke zoekresultaten! http://search.msn.nl


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



Reply via email to