我得到这个错误,我不知道什么是错的 我只想检查用户名&密码,然后进入一个页面,显示它的登录或不如何解决“HTTP状态500- Servlet异常抛出异常”
package cse;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.Random;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@SuppressWarnings("serial")
@WebServlet(urlPatterns = {"/LogIn"})
public class LogIn extends HttpServlet {
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
User signedInUser = User.login(username, password);
if(!signedInUser.equals(null)){
HttpSession s = request.getSession();
s.setAttribute("signedInKey", (new Date()).getTime() + (new Random()).nextInt(999999999));
request.setAttribute("user", signedInUser);
String url = "http://localhost:8080/java_project/test.jsp";
response.sendRedirect(url);
}
String url = "http://localhost:8080/java_project/notLogIn.jsp";
response.sendRedirect(url);
}
}
,这是错误
HTTP Status 500 - Servlet execution threw an exception
--------------------------------------------------------------------------------
type Exception report
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/hibernate/Session
ir.ac.shirazu.cse.LogIn.doPost(LogIn.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
java.lang.ClassNotFoundException: org.hibernate.Session
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
ir.ac.shirazu.cse.LogIn.doPost(LogIn.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.40 logs.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.40
plz帮助,我真的不明白什么是错
'抛出java.lang.ClassNotFoundException:org.hibernate.Session'在类路径 –
添加所需的jar您需要冬眠核心类路径HTTP罐子: //mirrors.ibiblio.org/pub/mirrors/maven2/org/hibernate/hibernate-core/3.3.0.CR1/hibernate-core-3.3.0.CR1.jar –
我用“catch(NoSuchAlgorithmException e)”,但它有语法错误,你知道为什么吗? – mellodi