Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “如何修复”;HTTP状态500-Servlet异常引发异常;_Java_Hibernate_Tomcat_Servlets - Fatal编程技术网

Java “如何修复”;HTTP状态500-Servlet异常引发异常;

Java “如何修复”;HTTP状态500-Servlet异常引发异常;,java,hibernate,tomcat,servlets,Java,Hibernate,Tomcat,Servlets,我有这个爱神,我不知道怎么了 我只想检查用户名和密码,然后进入一个页面,显示它是否登录 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.annotatio

我有这个爱神,我不知道怎么了 我只想检查用户名和密码,然后进入一个页面,显示它是否登录

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

请提供帮助,我真的不明白出了什么问题

您需要将hibernate3.jar放在类路径中,特别是在部署的应用程序的
WEB-INF/lib

在EclipseIDE中,您可以右键单击项目->属性->部署程序集来执行此操作

单击添加。。。按钮,选择Java构建路径条目并单击下一步。然后选择要导出到
WEB-INF/lib
的所需JAR,然后单击Finish。源jar将自动部署在正确的路径中


我希望这有帮助。它为我做了。

删除jar文件并在WEB-INF/lib中再次添加它们

java.lang.ClassNotFoundException:org.hibernate.Session
在类路径中添加所需的jar您需要在我使用的类路径中添加hibernate核心jar“catch(NoSuchAlgorithmException)”但是它有语法错误,你知道为什么吗?我添加了它,但它仍然有相同的问题。我应该如何准确地使用“java.lang.ClassNotFoundException:org.hibernate.Session”呢?我在WEB-INF/lib下有所有JAR,但我的问题没有被重新解决