Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 27296 invoked from network); 16 Sep 2007 15:40:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Sep 2007 15:40:05 -0000 Received: (qmail 14366 invoked by uid 500); 16 Sep 2007 15:39:46 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 14339 invoked by uid 500); 16 Sep 2007 15:39:46 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 14328 invoked by uid 99); 16 Sep 2007 15:39:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Sep 2007 08:39:46 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 24.24.2.55 is neither permitted nor denied by domain of dns4@cornell.edu) Received: from [24.24.2.55] (HELO ms-smtp-01.nyroc.rr.com) (24.24.2.55) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Sep 2007 15:39:42 +0000 Received: from [192.168.5.102] (cpe-24-59-111-127.twcny.res.rr.com [24.59.111.127]) by ms-smtp-01.nyroc.rr.com (8.13.6/8.13.6) with ESMTP id l8GFdKpN029083 for ; Sun, 16 Sep 2007 11:39:20 -0400 (EDT) Message-ID: <46ED4E28.5020000@cornell.edu> Date: Sun, 16 Sep 2007 11:39:20 -0400 From: David Smith User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Datasource: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' References: <46ED3D10.50707@als.com> In-Reply-To: <46ED3D10.50707@als.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Checked: Checked by ClamAV on apache.org Don't 'copy' the mysql driver from WEB-INF/lib to TOMCAT_HOME/common/lib -- move it. It cannot be in both places at once. Also be sure the permissions are set correctly so tomcat can read the jar and be sure you've restarted tomcat after the move so the classloaders pick it up properly. I have no idea why it works in Windows at all unless the Windows install has a copy of it in common/lib already -- which can cause problems later on if it's also in WEB-INF/lib. As a side note (and this is becoming a mantra with me) please don't use ?autoReconnect=true in your jdbc url. Instead add the attribute validationQuery="select 1" in the Resource element. That tells the pool how to validate the connection and optionally regenerate it before you borrow. --David Ken Bowen wrote: > Hello, > > I'm working on a CENTOS 5 Linux setup. > I'm trying to avoid the pre-loaded tomcat which was installed in > /usr/share/tomcat5. > I downloaded (from apache) and installed tomcat5.5.25 and installed it > in /opt/tomcat5. > I made sure the existing tomcat is not running and I renamed > /usr/share/tomcat5. > > I start it (the new tomcat) with /opt/tomcat5/bin/startup.sh and it > runs fine: > Tomcat manager runs and I can start/stop the built-in apps. > > I have an app which I developed using tomcat5.5.9 on Windows, and I am > trying to > transfer it to this Linux setting. > > I placed my exploded app in webapps. The app wants to use a Mysql > database named sb_data. > The same database as on Windows has been replicated in Mysql in the > Linux setup. > I have the following context.xml in my META-INF folder: > > debug="5" reloadable="true" crossContext="true"> > type="javax.sql.DataSource" > maxActive="100" maxIdle="30" maxWait="10000" > username="sb_normal" password="********" > driverClassName="com.mysql.jdbc.Driver" > > url="jdbc:mysql://localhost:3306/sb_data?autoReconnect=true"/> > > > My application has a registered AppListener in which I establish the > DataSource > in the contextInitialized method and use it to do some initial work > with the database: > > System.out.println("MyApp AppListener: ENTER"); > .... > Context envCtx = (Context) initialContext.lookup("java:comp/env"); > > String key = "jdbc" + "/" + "sb_data"; > DataSource ds = (DataSource)envCtx.lookup(key); > if (ds != null ){ > DAOBaseData.setDataSource(ds); > } > .... > ...CALL to DAOBaseData.getConnection(); HERE > .... > System.out.println("MyApp AppListener: EXIT"); > > The code for getConnection() looks like this: > > public Connection getConnection() throws DAOException > { > Connection connection = null; > if (datasource!= null) { > try { > connection = datasource.getConnection(); > } catch (SQLException e) { > //TODO: Log this > String message = e.getMessage(); > System.out.println("DAOBaseData: "+message); > throw new DAOException(message); > } > } > connCount++; > System.out.println("Connection[data] allocated: > #="+connCount); > return connection; > } > > This works ok on Windows, but in the Linux setting I get the following > error in > the catalina.out log: > > MyApp AppListener: ENTER > DAOBaseData: Cannot load JDBC driver class 'com.mysql.jdbc.Driver' > com.myapp Error: Cannot load JDBC driver class > 'com.mysql.jdbc.Driver' > MyApp AppListener: EXIT > > I'm using the mysql-connector-java-3.1.14-bin.jar and it is present in > WEB-INF/lib. > I tried copying it to /opt/tomcat5/common/lib , but I still get the > same error. > > I'm confused. Why does tomcat on Windows find the JDBC driver, but > not find it on Linux? > > Thanks in advance, > Ken Bowen > > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org