Linux server with Apache2, Tomcat7, PHP 5.5.10 are all up and running
Got this project where we have a JavaBridge installed for report generation, I have this working like a charm on my windows pc in an xampp environment, but on the server I am getting a ClassNotFoundException.
I can access the JavaBridge directly from the site by:
http://mysite:8080/JavaBridge/java/Java.inc
However from the PHP I keep getting this error of ClassNotFoundException
//getting Java.inc
//acquired Java.incdisplay
//java propertiesIn Java.inc
[[o:Exception]:"java.lang.Exception: CreateInstance failed: new com.nlrt.reportgenerator.ReportGenerator([o:PhpParserString], [o:PhpParserString], [o:PhpParserString]).
Cause: java.lang.ClassNotFoundException: com.nlrt.reportgenerator.ReportGenerator VM: 1.6.0_27#http://java.sun.com/" at:
#-32 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
#-31 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
#-30 java.lang.Class.forName0(Native Method)
#-29 java.lang.Class.forName(Class.java:266)
#-28 php.java.bridge.Util.classForName(Util.java:1518)
#-27 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:445)
#-26 php.java.bridge.Request.handleRequest(Request.java:458)
#-25 php.java.bridge.Request.handleOneRequest(Request.java:510)
#-24 php.java.servlet.PhpJavaServlet.handleLocalConnection(PhpJavaServlet.java:202)
#-23 php.java.servlet.PhpJavaServlet.handlePut(PhpJavaServlet.java:250)
#-22 php.java.servlet.PhpJavaServlet.doPut(PhpJavaServlet.java:261)
#-21 javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
#-20 javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
#-19 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
#-18 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
#-17 php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
#-16 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
#-15 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
#-14 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
#-13 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
#-12 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
#-11 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) #-10 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) #-9 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) #-8 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) #-7 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) #-6 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
#-5 org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
#-4 org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
#-3 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
#-2 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
#-1 java.lang.Thread.run(Thread.java:679)
#0 /home/dev/public/sanome.com/public/java/Java.inc(232): java_ThrowExceptionProxyFactory->getProxy(1, NULL, 'T', false)
#1 /home/dev/public/sanome.com/public/java/Java.inc(360): java_Arg->getResult(false)
#2 /home/dev/public/sanome.com/public/java/Java.inc(363): java_Client->getWrappedResult(false)
#3 /home/dev/public/sanome.com/public/java/Java.inc(535): java_Client->getInternalResult()
#4 /home/dev/public/sanome.com/public/java/Java.inc(1930): java_Client->createObject('com.nlrt.report...', Array)
#5 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(139): Java->Java('com.nlrt.report...', '372', '/home/dev/publi...', '{"result_id":"4...')
#6 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(65): FileManager->generateAndStreamPDF('1', '372')
#7 /home/dev/public/sanome.com/public/devicePorts/FileManager.class.php(43): FileManager->handleGenerateAndStreamPDF()
#8 /home/dev/public/sanome.com/public/report_generation/download_pdf.php(76): FileManager->__construct(Array, '1')
#9 {main}]
//500 Encountered exception while trying to create ReportGenerator
The PHP code that is accessing the required resources is as follows:
try
{
// we'll be using JavaBridge
echo "getting Java.inc";
require_once('../java/Java.inc');// http://sanome.com:8080/JavaBridge/java/Java.inc
echo "acquired Java.inc";
echo "display java properties";
//echo java("java.lang.System")->getProperties();
$reportGenerator = new java("com.nlrt.reportgenerator.ReportGenerator", $st_usage_id, $report_generator_directory, json_encode($results_array));
echo "created reportGenerator";
}
catch(Exception $exception)
{
var_dump($exception) ;//$exception;
}
The required JAR has been packaged and added to the WEB-INF/lib directory of the JavaBridge.
Also the php.ini file has the config
allow_url_include=On
I have even followed these steps but I am having no luck.
javabridge setup/installation issue
From what I have provided can anyone please help me?
Please don't criticize the solution for it was not my design. I am just trying to get it working, while adding to it.
Thank you.
Related
I have added a new action to the Document Library. My java class extends
ActionExecuterAbstractBase
. Inside code I make an HttpsURLConnection and read response like this :
URL url = new URL("https://...................................Get?username="+Name+"&password="+Password);
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
Outside Alfresco the java script works perfectly but inside it throws the following error :
Web Script Status 405 - Method Not Allowed
The Web Script /alfresco/s/api/action/cosign/formprocessor has responded with a status of 405 - Method Not Allowed.
405 Description: The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.
Message: 08060002 Script url /api/action/cosign/formprocessor does not support the method GET
Exception: org.springframework.extensions.webscripts.WebScriptException - 08060002 Script url /api/action/cosign/formprocessor does not support the method GET
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:179)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)
Server: Community v5.0.0 (d r99759-b2) schema 8.022
Time: 6 Σεπ 2016 11:25:36 πμ
How can I resolve this ?
Finally the problem came from SSL certificate. Alfresco in order to make https url connection should trust the ssl certificate. You can add an SSL in Alfresco/java folder with the following command:
keytool -import -alias test.com -file ../test.cer -keystore ../lib/security/cacerts
As title introduced, the .War file I'm trying to deploy by using Tomcat 7 is not working on a machine running Linux. It does work on Windows and is of course deployed with Tomcat 7.
I've tried to track down the issue alone & searched for related problems on the web including this forum with no success so far. That is why i created this thread asking for help / hints.
The error message I tracked down are the following:
Sep 14, 2015 4:46:05 PM org.apache.catalina.deploy.NamingResources cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SmartHomeReasoner]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:986)
at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:968)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5676)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:141)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1256)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:692)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
It were 2 problems actually causing this issue.
To solve the issue I had to:
*Check the web.xml VERY carefully after any misstakes like e.g. servlets that do not exist our already defined things e.g. driver being defined twice, meaning it's defined somewhere already AND also in the web.xml.
*Remove servlet in the ..\WEB-INF\lib folder of the project. E.g. javax.servlet-api-3.0.1.jar + javax.servlet-api-3.1.0.jar were removed in this case.
NOTE I even had jars that can conflict with each other on project-level but still I was able to deployed successfully on Windows but not on Linux.
Trust me both of the things I mentioned can be a issue, most likely if you take over work from other devs that have done this miss.
Just had the same issue and synchronizing the Java version for the Maven build (from 1.8 to 1.10) and the running environment (1.10) solved it.
I have two projects.
Java SE based let's say abcAPI.
Dynamic Web Project using tomcat server. let's say abc-web
I followed this tutorial automatically build and include one eclipse project into another to include abcAPI into abc-web. So that I have clear separation between these two. I included all necessary dependencies and API's in abcAPI project as well and I believe when using deployment assembly their shouldn't be any problem because underlying referencing project already has reference to it's libraries and dependencies in its libs folder.
I see no error before execution. But after the project runs and BasicDataSource is called I get this exception.
SEVERE: Servlet.service() for servlet [com.trolix.abcAPI.cbf.SrvStart] in context with path [/abc-web] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.commons.dbcp2.BasicDataSource
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at com.trolix.abcAPI.dbcon.DBConnection.<init>(DBConnection.java:38)
at com.trolix.abcAPI.dbcon.DBConnection.getInstance(DBConnection.java:51)
at com.trolix.abcAPI.dao.DAOStart.<clinit>(DAOStart.java:19)
at com.trolix.abcAPI.controller.CtrlStart.<init>(CtrlStart.java:14)
at com.trolix.abcAPI.manager.MgrStart.<init>(MgrStart.java:14)
at com.trolix.abcAPI.cbf.SrvStart.doPost(SrvStart.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Uptil now I have tried many things as suggested by SO community i.e.
Delete Server
Clean server
Restart Eclipse
Build Code
Deploy Again
etc.
But nothing has yet worked for me. Please guide!
I got the same error using iIntelliJ IDEA, Maven, Tomcat Server. As figured out the problem was in Artifacts(The dependency was not included to WEB-INF/lib).
To fix it - open Project Structure -> Artifacts -> drag-and-drop commons-* from Available Elements to lib
I'm working with servlet + spring. The servlet shows this exception in
ApplicationContext context = new ClassPathXmlApplicationContext("my_config.xml");
This is ecxeption text:
28.08.2013 16:27:36 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [my_spring2] in context
with path [/test_spring2] threw exception [Servlet execution threw an
exception] with root cause java.lang.ClassNotFoundException:
org.springframework.context.support.ClassPathXmlApplicationContext at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
at main_package.my_spring.doGet(my_spring.java:34) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source) at java.lang.Thread.run(Unknown Source)
28.08.2013 16:27:59 org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/test_spring2] has started
28.08.2013 16:28:00 org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/test_spring2] is completed
I see that the exception you got is java.lang.ClassNotFoundException
Unless you are involved in dynamic class loading and using the Java Reflection API, chances are that the ClassNotFoundException error you are getting is not from your application code but from a referencing API. Another common problem pattern is a wrong packaging of your application code.
Check to see if all the jars are added to your classpath.
Also some jars depend on other jars for their working. In that case you will have to add those jars too !
look at the line 34 in main_package.my_spring.doGet(my_spring.java:34) and see if it is referenced from local class or from an API?
If project-> build automatically is on on your eclipse if using eclipse, then you must be having class file, else you might see errors in the explorer.
most probably the class that you are referencing is from an API, if not try add jars from your project build path.
This question already has answers here:
How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception
(13 answers)
Closed 7 years ago.
So I have a .jar file for the MySQL JDBC driver, it is under my libraries source folder and I have the following code:
public static Connection getConnection() throws SQLException {
Connection conn = null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://50.56.81.42:3306/GUEST_BOOK";
String user = "user";
String password = "pass";
conn = (Connection) DriverManager.getConnection(url, user, password);
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(InstantiationException e){
e.printStackTrace();
}catch(IllegalAccessException e){
e.printStackTrace();
}
return conn;
}
However, it always gives me this error:
INFO: Server startup in 645 ms
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at gbook.DbHelper.getConnection(DbHelper.java:14)
at gbook.DbHelper.getGuestBook(DbHelper.java:51)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Dec 1, 2011 1:41:05 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/JDBC-MySQL] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Connection] with root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Connection
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at gbook.DbHelper.getGuestBook(DbHelper.java:52)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Here's how I added the jar file. I created a lib folder and put the jar inside and then I go to configure build path in eclipse and added the jar inside the lib folder to the project.
You missed mysql-connector-j jar file in your classpath. Use "java -cp .:mysql.jar...". Ou. It's a webapp! Then put mysql jar file to WEB-INF/lib folder.
Right click Libraries ->Add JAR/Folder and choose mysql-connector-java.jar file
if you are using Apache Tomcat, you may have to add the driver to the path using "Configure Tomcat" in Java Tab.