500 Dispatch to method returned an exception(hibernate错误)
这段代码本来是正确的,但是放到Struts就报错,是怎么回事?
Session session=HibernateSessionFactory.getSession();
int pageSize=5;
int currentPage=2;
Query qy=session.createQuery("from Product");
int count=qy.list().size();
int totalPage=(count-1)/5+1;
System.err.print(totalPage);
qy.setFirstResult((currentPage-1)*pageSize);
qy.setMaxResults(pageSize);
List list=qy.list();
for(int i=0;i <list.size();i++){
Product product=(Product)list.get(i);
System.err.println(product.getMember().getMemberName());
}
报错:
[18:37:47.039] Dispatch[/product] to method pagination returned an exception
[18:37:47.039]
java.lang.reflect.InvocationTargetException [18:37:47.039] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [18:37:47.039] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[18:37:47.039] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[18:37:47.039] at java.lang.reflect.Method.invoke(Method.java:324)
[18:37:47.039] at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
[18:37:47.039] at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
[18:37:47.039] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
[18:37:47.039] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
[18:37:47.039] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
[18:37:47.039] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
[18:37:47.039] at javax.servlet.http.HttpServlet.service(HttpServlet.java:115)
[18:37:47.039] at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
[18:37:47.039] at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
[18:37:47.039] at com.filters.Character.doFilter(Character.java:24)
[18:37:47.039] at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
[18:37:47.039] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178)
[18:37:47.039] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
[18:37:47.039] at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
[18:37:47.039] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389)
[18:37:47.039] at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507)
[18:37:47.039] at com.caucho.util.ThreadPool.run(ThreadPool.java:433)
[18:37:47.039] at java.lang.Thread.run(Thread.java:534)
[18:37:47.039] Caused by:
java.lang.NoClassDefFoundError: antlr/ANTLRException
[18:37:47.039] at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:35)
[18:37:47.039] at org.hibernate.engine.query.HQLQueryPlan. <init>(HQLQueryPlan.java:72)
[18:37:47.039] at org.hibernate.engine.query.HQLQueryPlan. <init>(HQLQueryPlan.java:54)
[18:37:47.039] at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
[18:37:47.039] at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
[18:37:47.039] at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
[18:37:47.039] at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
[18:37:47.039] at com.jgssdw.product.service.ProductDuration.pagination(ProductDuration.java:58)
[18:37:47.039] at com.jgssdw.product.action.ProductAction.pagination(ProductAction.java:41)