java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver...the same old pr

Hi,

I am a new user in this forum..

I have just installed tomcat and mysql and jdbc fresh on my new system..

first of all here is what i have done...

i have installed mysql integrated in xampp at c:\xampp\mysql

i have installed my tomcat at C:\Programme\Apache Software Foundation\Tomcat 5.5

i have put jdbc <dirver>.jar file copied in all sorts of directories like ....

<tomcat_home>\common\lib

<tomcat_home>\webapps\axis\WEB-INF\lib\ext

<java_home>\lib

<java_home>\jre\lib\ext

my calsspath looks something like this

.;C:\Programme\QuickTime\QTSystem\QTJava.zip;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\mysql-connector-java-5.0.6-bin.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\webapps\axis\WEB-INF\lib\mysql-connector-java-5.0.6-bin.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\servlet-api.jar;C:\Programme\"Apache Software Foundation"\"Tomcat 5.5"\common\lib\jsp-api.jar;C:\Programme\Java\jdk1.5.0_05\jre\lib\ext\mysql-connector-java-5.0.6-bin.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\activation.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\axis-ant.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-discovery-0.2.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\commons-logging-1.0.4.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\jaxrpc.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\log4j-1.2.8.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\mail.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\saaj.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\wsdl4j-1.5.1.jar;C:\Programme\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\lib\mysql-connector-java-5.0.6-bin.jar

which is basically all the jar files in the web-inf\lib folder and references to all the copies of driver as mentioned before

these are results of a lot of desperatio but still the code which i run....

package mypackage;

import java.sql.*;

public class JDBCConnector

{

public static void main(String[] arg) throws Exception

{

System.out.println("Initiating Database Mysql Connection");

//try {

Statement stmt;

//Register the JDBC driver for MySQL.

Class.forName("org.gjt.mm.mysql.Driver ").newInstance();

//Define URL of database server for

// database named mysql on the localhost

// with the default port number 3306.

String url = "jdbc:mysql://wifh-1.fhso.ch:3306/";

//Get a connection to the database for a

// user named root with a blank password.

// This user is the default administrator

// having full privileges to do anything.

Connection con = DriverManager.getConnection(url,"root", "birnExy");

//Display URL and connection information

System.out.println("URL: " + url);

System.out.println("Connection: " + con);

//Get a Statement object

stmt = con.createStatement();

//Create the new database

stmt.executeUpdate("CREATE DATABASE JunkDB3");

//Register a new user named auser on the

// database named JunkDB with a password

// drowssap enabling several different

// privileges.

stmt.executeUpdate("GRANT SELECT,INSERT,UPDATE,DELETE," +"CREATE,DROP " +"ON JunkDB3.* TO 'nishant'@'localhost' " +"IDENTIFIED BY 'nishant';");

con.close();

//}catch( Exception e ) {

//e.printStackTrace();

//}//end catch

//return hook;

}//end main

}//end class JDBCConnector

gives the following error.....

<soapenv:Envelope>

<soapenv:Body>

<soapenv:Fault>

<faultcode>soapenv:Server.userException</faultcode>

<faultstring>

java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver

</faultstring>

<detail>

<ns1:hostname>SADMC0087</ns1:hostname>

</detail>

</soapenv:Fault>

</soapenv:Body>

</soapenv:Envelope>

please help me

[4612 byte] By [Nishant@nishanta] at [2007-11-27 4:55:13]
# 1

> jdbc <dirver>.jar file

Which one? The filename does matter.

Looking to the exception message you aren't using the original manfacturer's driver (or you wasn't aware while the JAR is the manfacturer's one). It might be worth to download the manfacturer's driver and follow the extensive documentation of this driver at the manfacturer's site.

Download: http://www.mysql.com/products/connector/j/ (get 5.0)

Documentation: http://dev.mysql.com/doc/refman/5.0/en/connector-j.html

BalusCa at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

thanks for your reply....i am using mysql connector 5.0.6....and the filename you asked for is mysql-connector-java-5.0.6-bin.jar file..and you are correct, but the correct driver for this version is com.mysql.jdbc.driver....but even with that it gives the same error...please help me sort it our

Nishant@nishanta at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
also to add one more thing...i havent changed any xml files in the installation folders.....so if you know any necessary changes oplease point it out
Nishant@nishanta at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

If you're running Tomcat, then you likely are running a webcontainer. Put this JAR file in the /WEB-INF/lib of the WAR and you're there.

To get an overview of all classpath resources of the currently running Java Virtual Machine environment, add the following debugging piece to the running code:Enumeration resources = Thread.currentThread().getContextClassLoader().getResources("");

while (resources.hasMoreElements()) {

System.out.println(resources.nextElement());

}

The right Tomcat directory might be in there. It's usually the installationpath/lib directory.

BalusCa at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

first if all this same code ran for a simple compilation on the command prompt but when i am running the same code in form of a web service it gave the error.so thats why i am mentioning my way of running the web service

first i compile the source code which is in my webiinf\src\mypackage into a folder web-inf\classes\mypackage.

then i have added a deploy.wsdd in my web-inf folder which looks somehting like this

<deployment xmlns="http://xml.apache.org/axis/wsdd/"

xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<service name="MyWebService" provider="java:RPC">

<parameter name="className" value="mypackage.JDBCConnector" />

<parameter name="allowedMethods" value="*" />

<parameter name="scope" value="Request" />

</service>

</deployment>

then i run this file with the command

java org.apache.axis.client.AdminClient deploy.wsdd

now it gives a correct wsdl fiel but when i access the amin method with the url http://localhost:8080/axis/services/MyWebService?method=main

it gives the error as mentioned before.....

so now if you have a clearer idea ...please sort it out...i tried balus's method of enumerating but on the cmd it added the information and it shows that it found the driver(but only on cmd) ....but back on the url it shows the same error...does it have something to do with the packaging cause the code i use for url packages as i compile with javac -d classes src\mypackage\file.java....just a thought...if you come up with a solutoin try to help me out...

Nishant@nishanta at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
balus..i ahve bnever used eclipse....i just configured it for my tomcat and created a war of the project in which i had my .java file..now what do i do...compile and then send this whle to the war and then copy the jar file as you said?
Nishant@nishanta at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
and how do we compile in eclipse anyways[:D]
Nishant@nishanta at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

20.05.2007 22:43:26 org.apache.catalina.core.AprLifecycleListener lifecycleEvent

INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jdk1.5.0_05\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\QuickTime\QTSystem\;C:\Programme\ATI Technologies\ATI Control Panel;C:\Programme\Java\jdk1.5.0_05\bin;C:\Programme\Apache Software Foundation\Tomcat 5.5\common\lib;

20.05.2007 22:43:27 org.apache.coyote.http11.Http11BaseProtocol init

INFO: Initializing Coyote HTTP/1.1 on http-8080

20.05.2007 22:43:27 org.apache.catalina.startup.Catalina load

INFO: Initialization processed in 1203 ms

20.05.2007 22:43:27 org.apache.catalina.core.StandardService start

INFO: Starting service Catalina

20.05.2007 22:43:27 org.apache.catalina.core.StandardEngine start

INFO: Starting Servlet Engine: Apache Tomcat/5.5.23

20.05.2007 22:43:27 org.apache.catalina.core.StandardHost start

INFO: XML validation disabled

20.05.2007 22:43:28 org.apache.catalina.startup.HostConfig deployWAR

INFO: Deploying web application archive SIpages.war

20.05.2007 22:43:31 org.apache.coyote.http11.Http11BaseProtocol start

INFO: Starting Coyote HTTP/1.1 on http-8080

20.05.2007 22:43:31 org.apache.jk.common.ChannelSocket init

INFO: JK: ajp13 listening on /0.0.0.0:8009

20.05.2007 22:43:31 org.apache.jk.server.JkMain start

INFO: Jk running ID=0 time=0/109 config=null

20.05.2007 22:43:31 org.apache.catalina.storeconfig.StoreLoader load

INFO: Find registry server-registry.xml at classpath resource

20.05.2007 22:43:32 org.apache.catalina.startup.Catalina start

INFO: Server startup in 4813 ms

now this is when i run from eclipse where SIpages.war is my war file to be deployed...which looks something like this

sipages/web-inf/classes

sipages/web-inf/src

sipages/web-inf/lib-this has the jar file as you mentioned

and come other files...nwo where soes my .java file go in this war and how do i compile the java file

Nishant@nishanta at 2007-7-12 10:10:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...