首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

Struts+hibernate整合有关问题!java.lang.reflect.InvocationTargetException

2012-05-02 
Struts+hibernate整合问题!java.lang.reflect.InvocationTargetException我没什么分,各位大牛请见谅!Strut

Struts+hibernate整合问题!java.lang.reflect.InvocationTargetException
我没什么分,各位大牛请见谅!
Struts、hibernate单独测试ok ,一整合就出现错误!
jar包如下:
hibernate
  |--antlr-2.7.6.jar
  |--commons-collections-3.1.jar
  |--dom4j-1.6.1jar
  |--jta-1.1.jar
  |--slf4j-nop-1.6.4.jar
  |--slf4j-api-1.6.4.jar
  |--hibernate3.jar
Web App Libraries(这里是struts的jar包)
  |--asm-3.1.jar
  |--asm-commons-3.1.jar
  |--asm-tree-3.1.jar
  |--commons-fileupload-1.2.2.jar
  |--commons-io-2.0.1.jar
  |--commons-lang-2.5.jar
  |--freemarker-2.3.16.jar
  |--javassist-3.11.0.GA.jar
  |--ognl-3.0.1.jar
  |--struts2-core-2.2.3.1.jar
  |--xwork-core-2.2.3.1.jar


运行时出现以下信息:

Stacktraces

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:592)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
  com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
  org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  ......(信息太长,这里省略了一些!)
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)


  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
  org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  java.lang.Thread.run(Thread.java:595)
   
java.lang.NoClassDefFoundError: org/hibernate/Session
  com.tcsn.service.LoginService.userLogin(LoginService.java:10)
  com.tcsn.action.LoginAction.userLogin(LoginAction.java:26)
  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:592)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
  com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
  com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
  com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)


  com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
  com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
  com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
  org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
  org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
  org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
  org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
  org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
  org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
  java.lang.Thread.run(Thread.java:595)

[解决办法]
检查下部署项目的时候hibernate3.jar有没有放在lib目录下
[解决办法]
可能因为hibernate的包是后加入的,没有同步到tomcat。看看tomcat的webapps下有没有hibernate3.jar。

如果没有,重新发布就可以了
[解决办法]
问题就是如此奇妙,必然是类的问题,建的user library是放到编译路径,可能编译用main运行都没问题,但是发布到tomcat之类的服务器时就找不到对应的类了,这就是为什么你都放在工程的lib下又没有问题的原因

热点排行