reset password
Author Message
se1k1h1mawar1
Posts: 121
Posted 10:40 Nov 15, 2014 |

I have mysql-connector-java-5.1.33\mysql-connector-java-5.1.33-bin.jar in apache-tomcat-7.0.55\lib\, and it shows up on my Eclipse Project Explorer under the Dynamic Web Project folder where I have my HelloJDBC.java which is from our course website (Please see the attachment), but when I run the servlet, I get 500 error (I also see the Driver.class under com.mysql.jdbc package under mysql-connector-java-5.1.33-bin.jar):

 

HTTP Status 500 - java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

type Exception report

message java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    cs320mysql.HelloJDBC.init(HelloJDBC.java:39)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)


root cause

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:190)
    cs320mysql.HelloJDBC.init(HelloJDBC.java:35)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:745)

 

Could anybody please point out what I am doing wrong and some things I could try to fix the problem?
Thank you in advance.

-Kae

Last edited by se1k1h1mawar1 at 10:49 Nov 15, 2014.
cysun
Posts: 2935
Posted 12:07 Nov 15, 2014 |

Is the jar file directly under Tomcat's lib folder or is it under a subfolder /mysql-connector-java-5.1.33 under /lib? It needs to be directly under /lib.

se1k1h1mawar1
Posts: 121
Posted 12:29 Nov 15, 2014 |

If I understand it correctly, it is situated directly under /lib (Please see the attached).
 

cysun
Posts: 2935
Posted 12:32 Nov 15, 2014 |
se1k1h1mawar1 wrote:

If I understand it correctly, it is situated directly under /lib (Please see the attached).
 

It's not. You need to move the jar file out of the mysql-connector-java-5.1.33 folder and put it directly under /lib like the other jar files. In fact I'm surprised that your JSTL worked because it looks like your JSTL jar files are also under a subfolder.

se1k1h1mawar1
Posts: 121
Posted 12:33 Nov 15, 2014 |
cysun wrote:

Is the jar file directly under Tomcat's lib folder or is it under a subfolder /mysql-connector-java-5.1.33 under /lib? It needs to be directly under /lib.

Oh, I'm sorry, it WAS under the subdirectly.
Still shows 500 errors, but it no longer complains about not finding the Driver class.

Thank you.

se1k1h1mawar1
Posts: 121
Posted 12:37 Nov 15, 2014 |
se1k1h1mawar1 wrote:
cysun wrote:

Is the jar file directly under Tomcat's lib folder or is it under a subfolder /mysql-connector-java-5.1.33 under /lib? It needs to be directly under /lib.

Oh, I'm sorry, it WAS under the subdirectly.
Still shows 500 errors, but it no longer complains about not finding the Driver class.

Thank you.

And now it is fixed.
Thank you for your help!

-Kae