facebook

[Closed] ClassNotFoundException: com.mysql.jdbc.Driver

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 14 posts - 16 through 29 (of 29 total)
  • Author
    Posts
  • #249554 Reply

    Riyad Kalla
    Member

    Ok let’s do this.

    File > Switch Workspace > C:\tempworkspace, hit OK

    After the restart, go config MyEclipse Tomcat connector, hit OK. Now try and start Tomcat. Did it work? Try and run your app (assuming it’s still deployed to Tomcat) did it work?

    #249563 Reply

    Kalle-lumi
    Member

    Done!
    When I restart Windows and start Eclipse I get an error:
    Workspace is in use please use another one

    So I can not choose the newly created WorkspaceTemp. I can only choose the old workspace

    What to do?

    #249573 Reply

    Riyad Kalla
    Member

    What is going on here… so you typed in a totally new workspace name that has never existed before and Eclipse told you it was in use? If so, try another name that has never existed before like C:\blahblahtesttest123abc-workspace (copy and paste that). If Eclipse tells you it is in use, then there is some install issue going on here, because that doesn’t make any sense (for Eclipse to say that).

    #249590 Reply

    Kalle-lumi
    Member

    I am creating a package where I have classes such as DbConnector and User. I am placing the package in “proj2/src”. Is that the right location?

    #249593 Reply

    Riyad Kalla
    Member

    Yes that looks fine, but you are skipping over my question about the workspaces, what’s going on there?

    #249596 Reply

    Kalle-lumi
    Member

    oh I think I goofed the first time when I switched workspace. I think I forced Eclipse to quit during the restart that it makes to really switch workspace. I guess it lost the reference by my harsh treatment 😉

    I am going crazy about the dependencies not working 🙁
    I have a shop_login.jsp with a login form that has an form action to login_action.jsp. There I am calling for User.validate(username, password) but User is not found eventhough I have
    <%@ page import=”org.branemark.webshop.*”%> and User has a
    package org.branemark.webshop;

    #249603 Reply

    Riyad Kalla
    Member

    Ok just send me this crazy Project, I am convinced now there is some really easy explanation to all of this. Eport it to a zip and email it to support@genuitec.com ATTN Riyad. If it’s to big, put it up in a web location and PM me a link, I’ll download it and see what is goin on.

    #249605 Reply

    Kalle-lumi
    Member

    <POST ERASED>

    #249606 Reply

    Riyad Kalla
    Member

    Ok I got your project.

    1) I configured my tomcat connector in your workspace
    2) I had to refresh your project because the contents were out of sync with the workbench
    3) Then I cleaned the project
    4) Then I created an exploded deployment in Tomcat
    5) Then I went to test3.jsp and got the output on the screen “Hej” and got this exception in the console because I don’t have MySQL running locally:

    ### Login attempt at Thu Mar 30 16:22:04 GMT-07:00 2006
    from 127.0.0.1
    null/null
    Mar 30, 2006 4:22:04 PM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
    at org.apache.jsp.login_005faction_jsp._jspService(org.apache.jsp.login_005faction_jsp:57)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)
    Connecting to database…
    Error connecting to databasecom.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

    ** BEGIN NESTED EXCEPTION **

    java.net.SocketException
    MESSAGE: java.net.ConnectException: Connection refused: connect

    STACKTRACE:

    java.net.SocketException: java.net.ConnectException: Connection refused: connect
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at org.apache.jsp.test3_jsp._jspService(org.apache.jsp.test3_jsp:49)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:595)

    ** END NESTED EXCEPTION **

    So the end result is that everything is working as it should. I have the MySQL driver under common/lib (mysql-connector-java-3.1.12-bin.jar) and I setup my Tomcat 5 install with the following settings:
    Tomcat Home DIr: C:\Java\apache-tomcat-5.5.15
    Tomcat Base Dir: C:\Java\apache-tomcat-5.5.15
    Tomcat Temp Dir: C:\Java\apache-tomcat-5.5.15\temp
    –> Under JDK I setup and used JDK 1.5.0_06 to launch it

    I think you may be mis-diagnosing the problem.

    #249608 Reply

    Kalle-lumi
    Member

    Ok. Thanks.
    Now we need to go back to the origin question.

    Why can test3.jsp do the Class.forName(“com.mysql.jdbc.Driver”);
    but when an other jsp page calls for DbConnector.java to do the same forName() I get the
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

    #249615 Reply

    Kalle-lumi
    Member

    Now I have rebuild everything from scratch: new workspace, new project, everything is new and now it all works =)

    Of couse it is a bit disturbing not knowing exactly what was the real problem but as you said it was definetely just a minor settings issue.

    Most important is that everything works. You have been wonderful with all your patience. Cheers =)

    #249624 Reply

    Riyad Kalla
    Member

    Thank goodness everything works now, because I was really having a hard time figuring out what was causing the problem. Thanks for hanging in there and being patient, I know this can be frustrating.

    #250660 Reply

    stainbk2
    Member

    I have what seems to be the same problem.

    I have a web app running on Tomcat 5.5.16. I included the database driver file in Tomcat’s common/lib directory (as the Tomcat documentation recommends). If I start up the application using Tomcat, everything loads just fine. However, if I start Tomcat using MyEclipse, I get a ClassNotFoundException trying to locate the driver. Even if I add the driver file to the MyEclipse path for the Tomcat 5 connector, I get the same results.

    I’d like to try and help resolve the issue rather than blowing away my workspace, as I have other projects in the workspace that would be affected.

    What can I do to help research/resolve this issue?

    Thanks,

    – KMS

    #250665 Reply

    stainbk2
    Member

    OK… more specifically, I was attempting to connect to DB2 v8 (Express Edition). When starting Tomcat from MyEclipse, I would always get a ClassNotFoundException for the DB2 driver when I used the jdbc type 2 driver (COM.ibm.jdbc.app.driver.DB2Driver). However, when I switched to using the type 4 driver (com.ibm.db2.jcc.DB2Driver) and use the type 4 specific url (jdbc:db2://<server name here>:50000/<database name here>), it worked fine.

    Of course, this won’t help DB2 users who are still using the type 2 driver…

Viewing 14 posts - 16 through 29 (of 29 total)
Reply To: [Closed] ClassNotFoundException: com.mysql.jdbc.Driver

You must be logged in to post in the forum log in