当前位置:   article > 正文

【异常解决】Handler dispatch failed;nested exception is java.lang.NoClassDefFoundError: org/apache/common_handler dispatch failed; nested exception is java.

handler dispatch failed; nested exception is java.lang.noclassdeffounderror:

本文目录

一、背景描述

二、报错信息

三、解决方案


org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient

Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpClient

其实这样的报错信息内容已经很明确的告诉了我们为什么会报错,ClassNotFoundException(类没有找到异常),org.apache.commons.httpclient.HttpClient(这个就是需要找的类,但是没有找到,所以报类没有找到异常)。

一、背景描述

最近在开发一个项目,依赖了公司开发的jar包,然后按照模式把jar包引入进来,之后项目启动正常,就正常开发其他功能,等冒烟测试时才发现接口调用异常。

二、报错信息

把主要的报错信息摘取出来,如下:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient

Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpClient

详细报错信息内容如下:

  1. org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient
  2. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1054)
  3. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
  4. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
  5. at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
  6. at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
  7. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
  8. at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  9. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  10. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  11. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  12. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  13. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  14. at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
  15. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  16. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  17. at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  18. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  19. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  20. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  21. at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
  22. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  23. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  24. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  25. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
  26. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  27. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  28. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  29. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
  30. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  31. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  32. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  33. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
  34. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  35. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
  36. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
  37. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
  38. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
  39. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
  40. at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
  41. at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  42. at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
  43. at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
  44. at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  45. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  46. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  47. at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  48. at java.lang.Thread.run(Thread.java:748)
  49. Caused by: java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient
  50. at com.uiotsoft.shcs.thirws.client.api.ThirwsClient.reqestData(ThirwsClient.java:40)
  51. at com.uiotsoft.back.smarthome.skill.business.usercase.devicecontrol.DeviceControlV4.deviceControl(DeviceControlV4.java:110)
  52. at com.uiotsoft.back.smarthome.skill.business.usercase.devicecontrol.DeviceControlV4.execute(DeviceControlV4.java:50)
  53. at com.uiotsoft.back.smarthome.skill.business.usercase.devicecontrol.DeviceControlV4$$FastClassBySpringCGLIB$$40637e4d.invoke(<generated>)
  54. at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
  55. at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
  56. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  57. at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56)
  58. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  59. at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
  60. at com.uiotsoft.framework.log.LogAspect.Around(LogAspect.java:49)
  61. at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source)
  62. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  63. at java.lang.reflect.Method.invoke(Method.java:498)
  64. at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
  65. at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
  66. at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
  67. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  68. at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:47)
  69. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  70. at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
  71. at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  72. at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
  73. at com.uiotsoft.back.smarthome.skill.business.usercase.devicecontrol.DeviceControlV4$$EnhancerBySpringCGLIB$$841001a3.execute(<generated>)
  74. at com.uiotsoft.back.smarthome.skill.controller.api.TestDeviceControlControllerApi.deviceControl(TestDeviceControlControllerApi.java:35)
  75. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  76. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  77. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  78. at java.lang.reflect.Method.invoke(Method.java:498)
  79. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
  80. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
  81. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
  82. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
  83. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
  84. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  85. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
  86. ... 46 common frames omitted
  87. Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpClient
  88. at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  89. at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  90. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
  91. at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  92. ... 82 common frames omitted

三、解决方案

根据报错信息 org.apache.commons.httpclient.HttpClient 这个类没有找到,所以果断先去外部库中查找 org.apache.commons.httpclient 库里有没有 HttpClient 类,正如报错信息显示,确实没有找到这个 HttpClient 类,根据图中显示 外部库中连这个 jar包 都没有。而且连 commons 相关的包下也没有。

知道问题了,那就去找这个包吧,打开 https://mvnrepository.com/ 中央仓库的网站,去这里搜索 HttpClient 相关的包。

哇塞,好家伙,有572条结果,到底哪个才是呢,找与报错信息最相关的 org/apache/commons/httpclient/HttpClient ,而根据搜索结果 只有第二个 commons-httpclient » commons-httpclient HttpClient 最符合,所以就先拿这个来试一下吧。

点击进去,找到使用最多的一个版本,Version 3.1,再点击进去,把 maven 依赖拷贝出来放到项目中,重新导入一个 maven 依赖,再次测试,一切正常。

完结!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/98397?site
推荐阅读
相关标签
  

闽ICP备14008679号