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.

02-22-2012, 10:49 AM

Tolls

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.

02-22-2012, 09:28 PM

Mark1234

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)