Martin's advice made a difference.  When I pulled in the tc 4.1 common/lib
jars to my tc 4.04 common/lib I got past my problem for the first time.
The new contents of common/lib are: activation.jar,
commons-collections.jar, commons-dbcp.jar, commons-pool.jar,
jdbc2_0-stdext.jar, jndi.jar, jta-spec1_0_1.jar, mail.jar,
mysql-connector-java-2.0.14-bin.jar, naming-common.jar, naming-factory.jar,
naming-resources.jar, servlet.jar, tools.jar, xerces.jar.

Now I have a new problem which hopefully is easy to correct:

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:32)

I've tried setting driverName to  com.mysql.jdbc.Driver,
org.gjt.mm.mysql.Driver, and even to
com.mysql.jdbc.jdbc2.optional.MysqlDataSource. I also tried adding
Class.forName(...).newInstance() to my code, but it was no help either.

Here is my code:
Class.forName("com.mysql.jdbc.Driver").newInstance();
Context ctx = new InitialContext();
          ctx.addToEnvironment(Context.INITIAL_CONTEXT_FACTORY,
               "org.apache.naming.factory.DbcpDataSourceFactory");
                //"com.sun.jndi.fscontext.RefFSContextFactory");
      if(ctx == null )throw new Exception("Boom - No Context");
      DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
      if (ds != null) {
        Connection conn = ds.getConnection();                   <--- Blows
up here

Here is my host/context:
...
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix
=".txt"
                 pattern="common"/>
        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
             timestamp="true"/>
        <!-- Tomcat Root Context -->
        <!--
          <Context path="" docBase="ROOT" debug="0"/>
        -->

        <!-- Tomcat Manager Context -->
        <Context path="/manager" docBase="manager"
         debug="0" privileged="true"/>

        <!-- Security Test -->
         <Context path="/stewart" docBase="stewart" debug="0"
                  reloadable="true" crossContext="true">
           <Logger className="org.apache.catalina.logger.FileLogger"
                      prefix="localhost_examples_log." suffix=".txt"
            timestamp="true"/>
          <Manager className
="org.apache.catalina.session.PersistentManager"
              debug="0"
              saveOnRestart="true"
              maxActiveSessions="-1"
              minIdleSwap="-1"
              maxIdleSwap="-1"
              maxIdleBackup="-1">
                <Store className="org.apache.catalina.session.FileStore"/>
          </Manager>
        </Context>
        <!-- Test JDBC to MySql -->
            <Context path="/DBTest" docBase="DBTest"
                    debug="5" reloadable="true" crossContext="true">

              <Logger className="org.apache.catalina.logger.FileLogger"
                         prefix="localhost_DBTest_log." suffix=".txt"
                         timestamp="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>maxActive</name>
                  <value>100</value>
                </parameter>
                <parameter>
                  <name>maxIdle</name>
                  <value>30000</value>
                </parameter>
                <parameter>
                  <name>maxWait</name>
                  <value>100</value>
                </parameter>
                <parameter>
                 <name>username</name>
                 <value>javauser</value>
                </parameter>
                <parameter>
                 <name>password</name>
                 <value>javadude</value>
                </parameter>
                <parameter>
                   <name>driverClassName</name>
                     <!-- <value>org.gjt.mm.mysql.Driver</value>-->
                    <!-- <value>
com.mysql.jdbc.jdbc2.optional.MysqlDataSource</value>-->
                   <value>com.mysql.jdbc.Driver</value>
                </parameter>
                <parameter>
                  <name>driverName</name>
                  <value>jdbc:mysql://localhost:3306/javatest</value>
                </parameter>
              </ResourceParams>
     </Content>
      </Host>
    </Engine>
  </Service>

Any thoughts?

Steve



                                                                           
           Martin Jacobson                                                 
           <[EMAIL PROTECTED]                                              
           t>                                                           To 
                                     Tomcat Users List                     
           08/30/2002 06:01          <[EMAIL PROTECTED]>      
           AM                                                           cc 
                                                                           
                                                                   Subject 
           Please respond to         Re: Trouble configuring Tomcat 4.0.4  
             "Tomcat Users           JNDI connection to MySQL              
                 List"                                                     
           <tomcat-user@jakar                                              
             ta.apache.org>                                                
                                                                           
                                                                           
                                                                           




[EMAIL PROTECTED] wrote:

> Vance,
>
> Good eye.  It use to be driverName but got changed along the way to URL.
> Probably when I started following the 4.1 how-to.  In any case, I changed
> back to driverName and, alas, same problem.
>
> Vance, do you get the same error?
>
> javax.naming.NamingException: Exception creating DataSource:
> org.hsql.jdbcDriver
>      at org.apache.naming.NamingContext.lookup(NamingContext.java:842)
>      at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
>      at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
>      at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
>      at foo.DBTest1.init(DBTest1.java:20)
>      at org.apache.jsp.DbTest1$jsp._jspService(DbTest1$jsp.java:60)
>


Hi, I had this problem for ages, and resolved it by retrofitting the
DataSource factory (& connection pool) from tc4.1. The basic problem is
that Tyrex is broken; it happened to work for some people, but not for
me and many others :-(

At this point, Craig will probably come in and say to move to tc 4.1,
and I'd say, 'fine, as long as you don't use SSL with a standalone
tomcat, because the Coyote connector is broken in this respect.'

What you can do is download 4.1.9, remove tyrex...jar from common/lib in
4.0.4, and drop in the commons-*.jar files from 4.1.

Here is what I have in /usr/local/tomcat/common/lib
activation.jar
commons-collections.jar
commons-dbcp.jar
commons-pool.jar
jdbc2_0-stdext.jar
jndi.jar
jta-spec1_0_1.jar
mail.jar
mm.mysql-2.0.14-bin.jar
naming-common.jar
naming-factory.jar
naming-resources.jar
servlet.jar
xerces.jar

HTH
Martin

PS: dont forget that the <user> parameter is <username> with DBCP



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





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

Reply via email to