Friday, July 22, 2016

Spring-boot: java.lang.NoSuchMethodError:org.springframework.core.MethodParameter.hasMethodAnnotation

I was getting below error message for one of my spring-boot application. I realized that it was my POM file entry which was making my beautiful application throw up..

I had below entry in my POM file along with other spring boots related stuff. I removed the entry and my program started working like charm again.

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>4.3.0.RELEASE</version>
</dependency>

I am yet to find the root cause behind. I will update the blog as soon as I have more information on it. The entire stack trace is at the end of the blog.

Enjoy
Manisha 

HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.hasMethodAnnotation(Ljava/lang/Class;)Z

type Exception report
message Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.hasMethodAnnotation(Ljava/lang/Class;)Z
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.springframework.core.MethodParameter.hasMethodAnnotation(Ljava/lang/Class;)Z
 org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1305)
 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:979)
 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
 org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
java.lang.NoSuchMethodError: org.springframework.core.MethodParameter.hasMethodAnnotation(Ljava/lang/Class;)Z
 org.springframework.web.method.annotation.ModelAttributeMethodProcessor.supportsReturnType(ModelAttributeMethodProcessor.java:195)
 org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.selectHandler(HandlerMethodReturnValueHandlerComposite.java:90)
 org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:77)
 org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:126)
 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832)
 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743)
 org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
 org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

2 comments:

  1. Hi Manisha,

    Looks to me as if you had conflicting versions of spring libraries in the classpath - say one set in version ABC loaded by spring boot defaults and a second (non-compatible) version 4.3.0.RELEASE via the direct dependency you quoted.

    I found this which hints into the same direction: http://stackoverflow.com/questions/9496413/java-lang-nosuchmethoderror-org-springframework-core-annotation-annotationutils

    In general in situations like this maven dependency tree (mvn dependency:tree or your favorite IDE's replacement for it) usually helps: try hunting incompatible and/or duplicate libraries in classpath.


    greets from Berlin,
    -m

    ReplyDelete
  2. Aha! next time will definitely going to give it a spin. Vielen dank fur hilfe :).

    ReplyDelete