当我提交注册表注册servlet运行但是当我创建一个hibernate会话工厂的对象时,它给我一个异常。" javax.servlet.ServletException:Servlet执行引发异常 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)"。请帮我从这个例外中找到。
package login;
import java.io.IOException;
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 org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;
@WebServlet("/Registration")
public class Registration extends HttpServlet {
private static final long serialVersionUID = 1L;
public Registration() {
super();
// TODO Auto-generated constructor stub
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String username = request.getParameter("username");
String password = request.getParameter("password");
String name = request.getParameter("name");
User u = new User();
u.setUsername(username);
u.setPassword(password);
u.setName(name);
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
}
答案 0 :(得分:0)
在班级路径中添加最新的hibernate.jar