最近一直在写开源小项目,遇到了大大小小的BUG,小BUG也就算了,大BUG(指的是花费很多时间才DEBUG的)需要写一个博客记录一下,避免以后再犯这种错误。
切记,不要因为某些错误,乱导jar包!
报错截图如下:
关键的错误信息:
core.dao.BaseDao.processQuery(BaseDao.java:610)
message Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.beanutils.MethodUtils.getAccessibleMethod
意思是:没有指定的方法,能让我调用
或者说,你给了我太多的可调用方法,我没法选!
解决过程:
1.看到 core.dao.BaseDao.processQuery(BaseDao.java:610) 报错 打开这个java文件
2.看到org.apache.commons.beanutils.MethodUtils.getAccessibleMethod,可以推测出,org.apache.commons.beanutils这个jar包有问题!在java类中找到出错的头文件
3.打开项目lib目录,寻找是否缺少 / 重复 jar文件
4.删除其中一个,推荐删除老版本
因为老版本和新版本绝大多数的方法是重复的,如果两个包同时存在,系统不知道该用哪个包的方法,所以报错。
5.重新编译运行项目 ,成功解决
最后附上报错完整信息:
HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.beanutils.MethodUtils.getAccessibleMethod(Ljava/lang/Class;Ljava/lang/reflect/Method;)Ljava/lang/reflect/Method; type Exception report message Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.beanutils.MethodUtils.getAccessibleMethod(Ljava/lang/Class;Ljava/lang/reflect/Method;)Ljava/lang/reflect/Method; description The server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.beanutils.MethodUtils.getAccessibleMethod(Ljava/lang/Class;Ljava/lang/reflect/Method;)Ljava/lang/reflect/Method; org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) core.web.LoginFilter.doFilter(LoginFilter.java:51) root cause java.lang.NoSuchMethodError: org.apache.commons.beanutils.MethodUtils.getAccessibleMethod(Ljava/lang/Class;Ljava/lang/reflect/Method;)Ljava/lang/reflect/Method; core.util.BeanUtils.describeAvailableParameter(BeanUtils.java:57) core.dao.BaseDao.processQuery(BaseDao.java:610) core.dao.BaseDao.doPaginationQuery(BaseDao.java:441) core.dao.BaseDao.doPaginationQuery(BaseDao.java:432) core.service.BaseService.doPaginationQuery(BaseService.java:183) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:483) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) com.sun.proxy.$Proxy101.doPaginationQuery(Unknown Source) com.forestry.controller.sys.TelController.getHouseList(TelController.java:176) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:483) org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) core.web.LoginFilter.doFilter(LoginFilter.java:51) note The full stack trace of the root cause is available in the Apache Tomcat/8.0.9 logs. Apache Tomcat/8.0.9