JSP MySQL Class.forName error - java

I'm new to JSP. I'm trying to do a basic program of JSP & MySQL connectivity using ADT Eclipse. On running the index.jsp page, I get the following:
HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 24
type Exception report
message An exception occurred processing JSP page /index.jsp at line 24
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 24
21: String sql = "select usertype from userdetail";
22:
23: try {
24: Class.forName("com.mysql.jdbc.Driver");
25: con = DriverManager.getConnection(url, user, password);
26: ps = con.prepareStatement(sql);
27: rs = ps.executeQuery();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.index_jsp._jspService(index_jsp.java:141)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:190)
org.apache.jsp.index_jsp._jspService(index_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.
Apache Tomcat/7.0.30
I downloaded MySQL Connector J jar and included it in the project
Thanks in advance...

Don't add the external jar. Download it and copy in project.
COPY it in WEB-INF--->lib(folder).

The error ,
javax.servlet.ServletException: java.lang.ClassNotFoundException:
com.mysql.jdbc.Driver
says that it couldn't find the class file .
So you should check for the mysql jar to the the project using ,
Project properties-> add jar
before that place the jar in folder somewhere inside the project or add through external jar option.
If you already added . trying remove and adding the jar file again
see how-to-add-mysql-driver-jar-file-in-eclipse and how-to-add-external-jar-without-eclipse for addtional reference

Related

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver

I am trying to run simple code to connect with mysql. I m using eclipse and tomcat.
I have added mysql-connector-java-8.0.1.9.jar in Libraries:
Libraries-->mysql-->mysql-connector-java-8.0.1.9.jar
I have been at it for several hours adding and removing mysql-connector-java-8.0.1.9.jar to build path cannot get it running. Please help. Do I need to add any thing in run configuration??
This is the error on eclipse browser:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:599)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:500)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:917)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:846)
org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:129)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
compute.DB.con(DB.java:21)
org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:100)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root Cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1951)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1794)
compute.DB.con(DB.java:21)
org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:100)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.
This is the output in console:
> Mar 16, 2020 4:57:27 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/Mysql] has started
Mar 16, 2020 4:57:27 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading Context with name [/Mysql] is completed
Mar 16, 2020 4:57:41 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/Mysql] threw exception [javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver] with root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1951)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1794)
at compute.DB.con(DB.java:21)
at org.apache.jsp.regCheck_jsp._jspService(regCheck_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
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:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:165)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1195)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:654)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:319)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Try - 05 Trying to establish con in regCheck.jsp
Con method called Try 5A
Try 05a - Trying to connect
This is DB.java:
package compute;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.*;
public class DB {
final static String DB_URL = "jdbc:mysql://localhost:3306/new";
final static String USER = "admin";
final static String PASS = "admin";
public static Connection con() {
System.out.println("Con method called Try 5A");
Connection con;
try {
System.out.println("Try 05a - Trying to connect");
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
con = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Try 05a- con established ");
return con;
}catch(Exception e) {
System.out.println(e);
return null;
}
}
public static Statement st() {
Statement stmt;
try {
stmt=DB.con().createStatement();
return null;
}catch(Exception e) {
System.out.println(e);
return null;
}
}
}
This is regCheck.jsp:
<%#page import="java.sql.Connection" %>
<%#page import="compute.DB" %>
<%#page import="java.sql.PreparedStatement" %>
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
String user = request.getParameter("username");
System.out.println("Try - 05 Trying to establish con in regCheck.jsp");
Connection con = DB.con();
System.out.println("Preparing Statement in regCheck.jsp");
PreparedStatement p = con.prepareStatement("Insert into register(username)values(?)");
p.setString(1,user);
System.out.println("user::" +user);
int R = p.executeUpdate();
if(R!=0)
response.sendRedirect("index.html");
else
response.sendRedirect("register.jsp");
%>
</body>
</html>
The JDBC driver library is missing from your runtime CLASSPATH i.e. the CLASSPATH where Tomcat looks for the required classes in order to execute your compiled code.
I added mysql-connector-java-8.0.19.jar to Tomcat 7.0/Lib and now it's working find.
I removed it from Library and everywhere and it works.
I created new project with the same code and without adding mysql-connector-java-8.0.19.jar to any library or build path, it's running fine.
I found the instruction to add to tomcat somewhere on youtube.

Error with JSP page - org.apache.jasper.JasperException

<%# page import = "java.sql.*" %>
<!-- Variables Declaration -->
<%!
String connectionURL = "jdbc:mysql://localhost:3306/Tamir";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<!-- Connecting to database "Tamir" -->
<%!
void ConnectDb(){
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL,"root","tamir");
statement = connection.createStatement();
} catch (Exception ex){
System.out.print("Error in connecting");
}
}
%>
<!-- Html Part Starts Here -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1255">
<title> Test Database </title>
</head>
<body>
<h1> test hello </h1>
<%
ConnectDb();
rs = statement.executeQuery("SELECT * FROM users");
out.println(rs.getString("nickname"));
rs.close();
%>
</body>
</html>
Error recieved:
error
and yes, I have the mysql connector in lib of web-inf.
Yes I have a database with the username Tamir and password tamir, and the table Users;
yes, i have tomcat installed and running.
I've been looking in the internet for ages, help would be appriciated. Cheers.
Edit: full error is as the following:
HTTP Status 500 - An exception occurred processing JSP page /select.jsp at line 34
type Exception report
message An exception occurred processing JSP page /select.jsp at line 34
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /select.jsp at line 34
31: <%
32: ConnectDb();
33: rs = statement.executeQuery("SELECT * FROM users");
34: out.println(rs.getString("nickname"));
35: rs.close();
36: %>
37:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
javax.servlet.ServletException: java.sql.SQLException: Before start of result set
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.select_jsp._jspService(select_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause
java.sql.SQLException: Before start of result set
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:790)
com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5212)
com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5135)
com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5174)
org.apache.jsp.select_jsp._jspService(select_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.
Apache Tomcat/7.0.47
enter code here

struts application not working in linux tomcat server

I have a simple struts program working perfectly in windows environment with tomcat 7 as server. But I deployed the application in linux environment with tomcat 7 as server, the application is not running. It shows 404 error. Please help me to resolve the problem.
I am getting error as like this:
type Exception report
Message:
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot
find ActionMappings or ActionFormBeans collection
Description:
The server encountered an internal error that prevented it from
fulfilling this request.
Exception:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.login_jsp._jspService(login_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:747)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:443)
org.apache.jsp.login_jsp._jspx_meth_html_005fform_005f0(login_jsp.java:147)
org.apache.jsp.login_jsp._jspService(login_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.32 logs.
Did your included the jar correctly while creating the war file. Please check following jar are available in the WEB-INF/Lib folder of your project
antlr-2.7.6.jar
commons-beanutils-1.7.0.jar
commons-chain-1.2.jar
commons-collections-3.1.jar
commons-digester-2.0.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
commons-validator-1.3.1.jar
dom4j-1.6.1.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate3.jar
javassist-3.12.0.GA.jar
jstl-api-1.2.jar
jstl-impl-1.2.jar
jta-1.1.jar
mysql-connector-java-5.1.17-bin.jar
ognl-3.0.1.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.2.jar
spring-beans-2.5.6.jar
spring-context-2.5.6.jar
spring-core-2.5.6.jar
spring-test-2.5.6.jar
spring-web-2.5.6.jar
struts2-core-2.2.3.1.jar
xwork-core-2.2.3.1.jar

File reported as missing but it is not

I am working on a java web application using struts that someone else wrote and I was getting errors about an import that was missing in some files so I looked around the project folders and found the file among the jsp files which seemed strange. So, I copied the file into the relevant package and the errors went away. When I went to run the program again on Tomcat I got this error:
org.apache.jasper.JasperException: /index.jsp(3,55) File "/WEB-INF/struts-html.tld" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:166)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1425)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:197)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:339)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
"/WEB-INF/struts-html.tld" still exists and hasn't been changed or moved. I decided to delete the file I moved because the program still worked without it but I still get the error and I'm not sure how I could fix this.
Edit:
So I decided to refresh the webpage and a different error showed up:
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:168)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
java.net.URLClassLoader$1.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(Unknown Source)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:162)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:356)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
The tld (tag library) files and their locations are specified in the web.xml file.
If you need new tlds, the jsp files which are using these tlds will look first in the web.xml to find info and location of the file.
In your web.xml you need to place taglib definitions right after welcome-page definitions. It worked for me.

Hibernate Utils failing to run in JSP Page

This is my first time using Hibernate and I am able to run everything on my local machine just fine, but when I deploy my website to my professor's tomcat web server I get the error message below. All I do in the UsersHelper constructor is get the session from SessionFactory in HibernateUtils.
Here are HibernateUtil: http://www.copypastecode.com/173998/
and UsersHelper: http://www.copypastecode.com/174002/
org.apache.jasper.JasperException: An exception occurred processing JSP page /users.jsp at line 35
32: try{
33:
34:
35: UsersHelper u = new UsersHelper();
36:
37: List<Users> userList = u.getAllUsers();
38:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.myworkspace.hbconnect.HibernateUtil
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.users_jsp._jspService(users_jsp.java:281)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.NoClassDefFoundError: Could not initialize class org.myworkspace.hbconnect.HibernateUtil
org.myworkspace.hbconnect.UsersHelper.<init>(UsersHelper.java:19)
org.apache.jsp.users_jsp._jspService(users_jsp.java:241)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
java.lang.NoClassDefFoundError: Could not initialize class org.myworkspace.hbconnect.HibernateUtil
The mentioned class is missing in the runtime classpath. It must be in the runtime classpath as a standalone class file (.class) or packaged in a JAR file (.jar).
By default the webapp's myWebapp/WEB-INF/lib and myWebapp/WEB-INF/classes folders are covered by the runtime classpath.
Any 3rd party webapp-specific JAR files ought to be placed in myWebapp/WEB-INF/lib. Any webapp-specific classes (servlets, etc..) ought to be placed in myWebapp/WEB-INF/classes.
Check if you have place proper .class files and .jar when deploying.
Hope this helps.

Categories