Results 1 to 7 of 7
  1. #1
    Mark1234 is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default JDBC class not found when calling a java class in a java project from my JSP in a web

    Hell evrebody

    I have a class ReadFromDB that performs sql commands. This class is in a JAVA project, and I tried running through the java project and it works.

    I have also a dynamic web project and in it a jsp that creates a ReadFromDB class and when it tries to call the read method I get a class not found message on the create connection command.

    I made sure I have the JDBC jar also in the web project but that didn't solve the problem.

    Please throw me a life belt I have run out of ideas and cannot find an answer in the web.

    Thank you.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: JDBC class not found when calling a java class in a java project from my JSP in a

    You ought to give the full error message, but assuming it's the "no suitable driver found" one then the jar file is not on the runtime classpath.
    In a web apps case that means it isn't in the WEB-INF/lib folder.

  3. #3
    Mark1234 is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Re: JDBC class not found when calling a java class in a java project from my JSP in a

    Hi

    This is the error message:


    Stacktrace:] with root cause
    java.lang.ClassNotFoundException: org.sqlite.JDBC
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1521)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at dataBase.ReadFromDB.makeConnection(ReadFromDB.java :14)
    at dataBase.ReadFromDB.read(ReadFromDB.java:21)
    at org.apache.jsp.index_jsp._jspService(index_jsp.jav a:132)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:419)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:391)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:164)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:462)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:164)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:562)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:395)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:250)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:188)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:166)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:302)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)


    The class is:


    public class ReadFromDB {

    private Connection makeConnection() throws ClassNotFoundException, SQLException {
    Class.forName("org.sqlite.JDBC");
    Connection conn = DriverManager.getConnection("jdbc:sqlite:projects. db");
    return conn;
    }
    The error happened in the Class.forName("org.sqlite.JDBC"); command.

  4. #4
    arielb is offline Member
    Join Date
    Jan 2012
    Location
    Panamá
    Posts
    41
    Rep Power
    0

    Default Re: JDBC class not found when calling a java class in a java project from my JSP in a

    If you made and what you said Tolls in the lib folder of Tomcat you must also add the jar.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: JDBC class not found when calling a java class in a java project from my JSP in a

    Yep, as I said, it can't see the jar file, which almost certainly means it's not in the WEB-INF/lib folder of your web app.
    <tomcat-directory>/webapps/<yourapp>/WEB-INF/lib

  6. #6
    Mark1234 is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Re: JDBC class not found when calling a java class in a java project from my JSP in a

    Thank you all

    I added the JAR to the server and everthing is working now.

    Sorry for not sending a response sooner but I haven't been next to an internet computer for the past couple of weeks.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: JDBC class not found when calling a java class in a java project from my JSP in a

    I hope by "server folder" you don't mean the <tomcat>/server/lib, as that's not really the correct place for it.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. Replies: 3
    Last Post: 01-26-2012, 11:20 PM
  2. Error: The java class is not found:
    By Karthika in forum New To Java
    Replies: 2
    Last Post: 01-14-2011, 06:03 AM
  3. Replies: 11
    Last Post: 07-27-2010, 04:08 PM
  4. calling method of different project package class
    By oneofthelions in forum New To Java
    Replies: 3
    Last Post: 02-16-2010, 05:36 PM
  5. man.java class not found
    By oneofthelions in forum Advanced Java
    Replies: 0
    Last Post: 12-14-2009, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •