5

I have updated spring boot version from 2.7.5 to 3.0.2 . I have updated Jakarta too . Only when trying to fatch url it is getting following error:

java.lang.NoSuchMethodError: 'org.springframework.http.HttpStatus org.springframework.http.client.ClientHttpResponse.getStatusCode()'
at org.springframework.security.oauth2.client.http.OAuth2ErrorHandler.hasError(OAuth2ErrorHandler.java:76) \~\[spring-security-oauth2-2.0.17.RELEASE.jar:na\]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:904) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:864) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:804) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:665) \~\[spring-web-6.0.4.jar:6.0.4\]
at com.mbusa.gm.repository.OneApiRepository.getVehicleFromSWT(OneApiRepository.java:178) \~\[classes/:na\]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) \~\[na:na\]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) \~\[na:na\]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) \~\[na:na\]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) \~\[na:na\]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) \~\[spring-aop-6.0.4.jar:6.0.4\]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) \~\[spring-aop-6.0.4.jar:6.0.4\]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) \~\[spring-aop-6.0.4.jar:6.0.4\]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:752) \~\[spring-aop-6.0.4.jar:6.0.4\]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) \~\[spring-tx-6.0.4.jar:6.0.4\]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) \~\[spring-aop-6.0.4.jar:6.0.4\]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:752) \~\[spring-aop-6.0.4.jar:6.0.4\]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703) \~\[spring-aop-6.0.4.jar:6.0.4\]
at com.mbusa.gm.repository.OneApiRepository$$SpringCGLIB$$0.getVehicleFromSWT(\<generated\>) \~\[classes/:na\]
at com.mbusa.gm.service.GreyMarketService.addVehicleExport(GreyMarketService.java:47) \~\[classes/:na\]
at com.mbusa.gm.controller.GreyMarketController.addVehicleExport(GreyMarketController.java:98) \~\[classes/:na\]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) \~\[na:na\]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) \~\[na:na\]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) \~\[na:na\]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) \~\[na:na\]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:207) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:152) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1080) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:973) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:731) \~\[tomcat-embed-core-10.1.5.jar:6.0\]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) \~\[spring-webmvc-6.0.4.jar:6.0.4\]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814) \~\[tomcat-embed-core-10.1.5.jar:6.0\]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) \~\[tomcat-embed-websocket-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) \~\[spring-web-6.0.4.jar:6.0.4\]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) \~\[tomcat-embed-core-10.1.5.jar:10.1.5\]
at java.base/java.lang.Thread.run(Thread.java:833) \~\[na:na\]

What should i update or change for this error?

kiner_shah
  • 3,939
  • 7
  • 23
  • 37
Davis
  • 51
  • 1
  • 3
  • 1
    What are your dependencies? Did you read the migration guide? https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide – ch4mp Feb 11 '23 at 01:14
  • org.springframework.boot spring-boot-starter-parent 3.0.2 – Davis Feb 16 '23 at 11:32
  • 1
    This is not all dependencies, this a parent. Also, you need to provide your conf and the code throwing that if you expect an answer. Edit your question. – ch4mp Feb 16 '23 at 12:33
  • Looks like spring-security-oauth2-client version is not Spring Boot 3 compatible - directly or via spring-boot-starter-oauth2-client. Needs to be v6. If you post your entire pom file we can investigate. – John Williams Feb 27 '23 at 07:42

2 Answers2

4

You have made a major version jump, from spring-boot 2.X to spring-boot 3.X - you must expect that there will be incompatible changes. Now this offending method has changed the return value, check the source. I think the problem is clear - in JVM bytecode you have a versions of the method with different signatures than you expect (Note, that for JVM return type is a part of the invoke instruction and is a part of signature):

  1. You have different spring-web JARs during your compilation and runtime. It can happen, there is even a concept in CS called dependencies hell. Because this return types change is incompatible so your code shouldn't even compile, but still you was able to do so. You need to ensure that your compilation classpath has the same spring-web jar as runtime classpath.

  2. You have code that is already compiled with old spring-web verison, and now you are launching a jar providing a classpath with newer version of spring-web. It is unlikely, but still, worth mentioning.

Finally, there are some good articles that illustrate the problem that you encountered. Consider taking a look.

Mikhail2048
  • 1,715
  • 1
  • 9
  • 26
0

I was in the same situation, and needed code that could work with both Spring Boot 2 and 3. If that's your case, the simplest solution is to use instead the (now deprecated) method getStatusCodeValue() this will work the same in spring-web from 4.x to 6.x (it returns an int value instead of a String, but you should be able to manage that).

Mind you, there have been lots of other incompatible changes (a ton more than there were between spring-web 4.x and 5.x) so you might still encounter problems...

David G.
  • 161
  • 1
  • 11