日期:2014-05-17  浏览次数:20715 次

用struts +hibernate 用一个action查询一个表出错,求解
我可以用一个MAIN函数 ,创建数据表Product ,应该 hibernate 和 映射文件都没问题,有大神指点,下面是主要错误:

HTTP Status 500 type Exception report
message 
description The server encountered an internal error () that prevented it from fulfilling this request.
exception 
java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

root cause 
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)
com.SH.util.HibernateUtil.<clinit>(HibernateUtil.java:11)
com.SH.dao.ProductDaoimpl.queryAll(ProductDaoimpl.java:47)
com.SH.service.ProductServiceimpl.queryAllProduct(ProductServiceimpl.java:45)
com.SH.action.showAllaction.execute(showAllaction.java:13)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)

------解决方案--------------------
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory


把jar包加上
------解决方案--------------------
缺少commons-logging.jar
------解决方案--------------------
对,应该是缺少那个jar包,或者是jar包的版本不对
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html