正在做毕业设计,碰到一个问题,那位高手给看看是什么问题!
是一个Action!
错误提示:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: could not load an entity: [com.studorm.dao.Students#4]
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.hibernate.exception.GenericJDBCException: could not load an entity: [com.studorm.dao.Students#4]
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:828)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:821)
com.studorm.struts.action.DeletestudentAction.execute(DeletestudentAction.java:54)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------
Apache Tomcat/5.0.28
程序源码:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.studorm.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
//import org.hibernate.HibernateException;
import org.hibernate.Session;
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
import com.studorm.dao.Students;
import com.studorm.dao.HibernateUtil;
/**
* MyEclipse Struts
* Creation date: 04-17-2007
*
* XDoclet definition:
* @struts.action validate= "true "
* @struts.action-forward name= "deletestudentsuccess " path= "/stumain.jsp "
*/
public class DeletestudentAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
// TODO Auto-generated method stub
//private static Log log = LogFactory.getLog(DeletestudentAction.class);
String id = (String)request.getParameter( "student_id ");
//try {
Session s = HibernateUtil.currentSession();
HibernateUtil.beginTransaction();
Students stu = (Students)s.get(Students.class,id);
HibernateUtil.commitTransaction();
//System.out.println(stu.getId());
HibernateUtil.beginTransaction();
s.delete(stu);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
return (mapping.getInputForward());
/*catch (HibernateException e) {
return (mapping.findForward( "deletestudentsuccess "));
}*/
}
}
[解决办法]
看看com.studorm.dao.Students包有没有问题,还有可能是你的hibernate的对象关系映射的xml配置问题
[解决办法]
一看就知道是你的hibernate的问题,你仔细检查下你的hibernate配置文件把!
[解决办法]
hibernate没有配置好
[解决办法]
楼上正解
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html