-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Boot 2.5.2 + Netflix Zuul - NoSuchMethodError: ErrorController.getErrorPath() #4008
Comments
I have the same problem with version 2.5.0. org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'java.lang.String org.springframework.boot.web.servlet.error.ErrorController.getErrorPath()'
Caused by: java.lang.NoSuchMethodError: 'java.lang.String org.springframework.boot.web.servlet.error.ErrorController.getErrorPath()' |
do you maybe know when fix version can be expected? |
We are facing exactly the same issue with spring boot 2.5.1. Would someone help have a look at it? Thanks a lot. |
I submitted a PR for this, but it was rejected as the 2.x branch does not support Spring Boot 2.5: #4012 |
Thank you for the info. Is there a way of fixing it outside the lib? For example, override this bean
And use a customised ErrorController? |
We are also facing the same issue with 2.5.2. There is a question on StackOverflow for the same. |
After some googling I found that zuul and ribbon were removed from the springboot main channel in 2.5.x |
Having the same issue... Any news on this? |
Same problem here. @clementdenis hope one day they decide to integrate your fix, meanwhile, after some investigation I was able to make it work, maybe it's a start point to patch it in your projects. Not a fully tested code, but I published this gist if anyone is interested, please see the gist's first comment (improvements are welcome!). After all, I supose that will migrate our project to Spring Cloud Gateway... |
Same issue :( |
Hi @ajitesh-sivakumar, maybe you can try the gist in my comment above. I don't like this kind of solutions but It's working for me. |
Quickly developed an alternative solution in this gist. |
@espartero , thanks. I will give it a try. I am worried that this might be temporary fix, but after Spring team (may) fix this bug in next update, it will crash my application. |
Looks very good! Didn't knew this way to override the beans, I'll try it. Just comment that maybe we can also replace the ERROR_PATH constant by injecting:
to be equivalent to this. @ajitesh-sivakumar I prefer @aldobongio solution, maybe you can try it. |
It worked..Thanks.. |
Closing as there is a workaround and Zuul is no longer supported by Spring Cloud. |
Thank you so much. Your fix worked for me :) |
Thanks a lot @aldobongio !! import org.springframework.beans.factory.config.BeanPostProcessor
import org.springframework.boot.web.servlet.error.ErrorController
import org.springframework.cglib.proxy.*
import org.springframework.cloud.netflix.zuul.filters.RouteLocator
import org.springframework.cloud.netflix.zuul.web.*
import org.springframework.context.annotation.*
/**
* Fix for Zuul configuration with Spring Boot 2.5.x + Zuul - "NoSuchMethodError: ErrorController.getErrorPath()"
*/
@Configuration
class ZuulSpringWorkaround {
@Bean
fun zuulPostProcessor(locator: RouteLocator, controller: ZuulController, errorController: ErrorController?) =
object : BeanPostProcessor {
override fun postProcessAfterInitialization(bean: Any, beanName: String) =
if (errorController != null && bean is ZuulHandlerMapping) {
val constructorTypes = ZuulHandlerMapping::class.java.constructors[0].parameterTypes
Enhancer().apply {
setSuperclass(ZuulHandlerMapping::class.java)
setCallbackFilter { if ("lookupHandler" == it.name) 0 else 1 }
setCallbacks(arrayOf(MethodInterceptor { target, _, args, proxy ->
if ("/error" == args[0]) null else proxy.invokeSuper(target, args)
}, NoOp.INSTANCE))
}.create(constructorTypes, arrayOf(locator, controller))
} else bean
}
} |
@rkeytacked Thanks a bunch, saved me lots of time! :-) |
Has anyone tested the fix on Spring Boot 2.6? |
thanks a lot its working! |
@andresestrella Doesn't seem to be working for 2.6.6 |
I did tried w/ Spring Boot 2.6.6, it's not working |
I did, it worked |
Worked for me in Spring Boot 2.6.7 with:
Make sure you still have |
We definitely discourage using Spring Cloud Zuul. The project is no longer maintained and there might be dependencies with vulnerabilities present. We encourage migrating to Spring Cloud Gateway instead. |
@rkeytacked thanks a lot and share the junit test cases for the same class. |
@pvraju1988 The tests for this configuration class are left as an exercise for junior engineers… 😎 |
Same problem using spring boot 2.7 |
Fix with BeanPostProcessor didn't work for me (I got "java.lang.IllegalStateException: No ServletContext set" due to some circular dependencies. I use Spring Boot 2.6.7, Spring Cloud 2021.0.3, spring-cloud-starter-netflix-zuul:2.2.10.RELEASE), so I wrote my own (hack, but works):
Pasting it here to help other people, who
|
A super simple fix/hack is to place this in your sources:
This will override the interface supplied by Spring. |
@OlgaMaciaszek |
@kurbhatt - it is quite straightforward. The main difference is that you will need to define the routes. There's no specific migration guide, but everything you'll need is in the Gateway documentation. |
@OlgaMaciaszek I think migration to Spring cloud gateway is unfeasible in our case. The reason is that our api-gateway contains several controllers and also uses third-party libraries that are also dependant on spring-mvc. This is a problem since Spring cloud gateway is build on top of reactive stack (spring-webflux) and those two can not coexist in single application as far as I understand. Is my reasoning correct or I am missing something? |
@LukeLaz You are correct. You will have to rewrite all the code that's incompatible with webflux. Worse, if you are forced to use 3rd party closed source code then there is no migration path. It's very unfortunate it was decided that WebFlux should not coexist with MVC/Servlet API. |
I found very simple and clean solution that can be used as long as your app does not use Before After |
After upgrade to Spring Boot 2.5.2 Zuul started to generate the following error:
With Boot 2.4.8 works fine.
This is my dependency in pom.xml.
Don't know for sure if I'm posting this in the correct project. If don't, please, point me in the right direction.
Thanks.
Complete stack trace:
The text was updated successfully, but these errors were encountered: