eclipse下開發struts+hibernate出現的問題!

mhbjava發表於2005-10-09
下面是個action,我設定斷點來跟蹤程式,發現當執行action裡面的execute()方法時,執行到HelloForm helloForm = (HelloForm) form;這句話後就出現了異常!我不知道原因,請指點,謝謝!異常為:
java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion
com.itfly.struts.action.HelloAction.execute(HelloAction.java:52)
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.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


action為:
package com.itfly.struts.action;

import java.util.List;

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.Query;
import org.hibernate.Session;

import com.itfly.base.BaseUserDAO;
import com.itfly.dao.UserDAO;
import com.itfly.dao._RootDAO;
import com.itfly.struts.form.HelloForm;


public class HelloAction extends Action {


public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
HelloForm helloForm = (HelloForm) form;
// TODO Auto-generated method stub

_RootDAO.initialize();
UserDAO userDAO = new UserDAO();
Session session = userDAO.getSession();
Query hql = session.createQuery("from User where Id=1");
List list = hql.list();
System.out.print(list.size());
request.setAttribute("list",list);

return mapping.findForward("success");
}

}

相關文章