当前位置: 代码迷 >> Java Web开发 >> The server encountered an internal error () that prevented it from fulfilling this request.
  详细解决方案

The server encountered an internal error () that prevented it from fulfilling this request.

热度:518   发布时间:2016-04-17 17:22:31.0

hibernate 报错
代码如下:第63行 (LoginDAO loginDAO = new LoginDAO();)
  Login login = new Login();
login.setUsername("ad");
login.setPassword("12");
LoginDAO loginDAO = new LoginDAO();
Transaction tra = loginDAO.getSession().beginTransaction();
loginDAO.attachDirty(login);
tra.commit();
loginDAO.getSession().close();
return null;
如下报错:

type Exception report

message 

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/criterion/Criterion
com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:63)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.lang.ClassNotFoundException: org.hibernate.criterion.Criterion
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
com.yourcompany.struts.action.LoginAction.execute(LoginAction.java:63)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.


------解决方案--------------------
LoginDAO loginDAO = new LoginDAO();中的LoginDAO 是接口还是类?如果是接口,肯定不能new出来了..不然的话我想出来这里怎么会出错..
------解决方案--------------------
java.lang.ClassNotFoundException: org.hibernate.criterion.Criterion

没找到类 不是缺jar包就是有冲突
------解决方案--------------------
LoginDAO loginDAO = new LoginDAO();

这个不能直接new 接口的。帅哥。你要动态绑定实现它的实体类。而不是new 这个借口

应该是这样吧:LoginDAO loginDAO = new LoginDAOImpl();
------解决方案--------------------
org/hibernate/criterion/Criterion

没有这个类,少jar包了吧
------解决方案--------------------

  相关解决方案