Solved

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver occurs only when I use AXIS web services, not else!!

Posted on 2003-10-24
3
824 Views
Last Modified: 2013-11-24
Hello!

I've written a Java program that connects to MySQL.
This works fine.

But when I try to use the same Java-file as a .jws file (as a web service on TomCat/AXIS), I get the error(this is pasted from the tomcat cmd-prompt window):

my comment: connect2db failed
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.lang.ClassLoader.findClass(ClassLoader.java:341)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at DAC_v1.connect2db(DAC_v1.java:71)
        at DAC_v1.readData(DAC_v1.java:18)
        at DAC_v1.select(DAC_v1.java:225)
        at DAC_v1.chooseOperation(DAC_v1.java:260)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Meth
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethod
java:39)

It is the same file, and this doesn't happen when I run it as a regular java file.
So as a java-file it connects to MySQL, but when used under AXIS it don't.

I use a MySQL ODBC 3.51, but this is a "User DSN" ODBC, not "System DSN".
The portnumber is default: 3306
My tomcat web server uses port standard 8080.

Could this be the problem?

The problem is also that I can't use the MySQL ODBC as System DSN beacuse I can't find it on the list of availabe ODBC types under "System DSN".

Or is the problem something else?
My classpath is:

.;%SAG_COMMON%\xts.jar;E:
\Program Files\Common Files\Software AG\sagxds.jar;
%SAG_COMMON%\saglic.jar;%SAG_COMMON%\sagxds.jar;E:
\mysql_win2000_jconnect\mysql-connector-java-3.0.9-stable\mysql-connector-java-3.0.9-stable-bin.jar;E:
\tomcat\jtcv2\bin\tomcat-jni.jar;E:\tomcat\jtcv2\common\lib\ant.jar;E:
\tomcat\jtcv2\server\lib\catalina.jar;E:
\tomcat\jtcv2\server\lib\catalina-ant.jar;E:
\tomcat\jtcv2\server\lib\servlets-common.jar;E:
\tomcat\jtcv2\server\lib\tomcat-jk.jar;E:
\tomcat\jtcv2\server\lib\tomcat-jk2.jar;E:
\tomcat\jtcv2\server\lib\tomcat-util.jar;E:
\tomcat\jtcv2\server\webapps\admin\WEB-INF\lib\struts.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\jaxrpc.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\axis.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\commons-logging.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\log4j-1.2.4.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\wsdl4j.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\xml-apis.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\xmlParserAPIs.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\xercesImpl.jar;E:
\tomcat\jtcv2\webapps\axis\WEB-INF\lib\xercesSamples.jar;E:
\AxisBeta322okt2003\axis-1_0\webapps\axis\WEB-INF\lib\jaxrpc.jar;E:
\AxisBeta322okt2003\axis-1_0\lib\axis.jar;E:
\AxisBeta322okt2003\axis-1_0\lib\commons-logging.jar;E:
\AxisBeta322okt2003\axis-1_0\lib\log4j-1.2.4.jar;E:
\AxisBeta322okt2003\axis-1_0\lib\saaj.jar;E:
\AxisBeta322okt2003\axis-1_0\lib\tt-bytecode.jar;E:
\AxisBeta322okt2003\axis-1_0\lib\wsdl4j.jar;E:
\j2sdk1.4.2_02\lib\tools.jar

I'd appretiate any help veery much!!

Thanks in advance!

Regards,
Tom-Erik
0
Comment
Question by:tomerikv
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 9617750
You should probably also have the driver jar in WEB-INF/lib of your web app
0
 
LVL 1

Author Comment

by:tomerikv
ID: 9617866
Hi again!

Now it works!!! Thanks a lot, again!

before it was:
the result name is: 0

Now it is:
the result name is: Tom-Erik Valso

You've made my day! : )

Kind regards,
Tom-Erik
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9617882
Glad to hear it ;-)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 53
hibernate example issues from command prompt 10 42
sql import cannot be resolved jsp 3 23
going to wrong jsp page 2 21
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question