0

The Spring Cloud Netflix documentation states that the default forwarding path (/error) for SendErrorFilter can be changed by setting the error.path property. When I do this, I encounter the following error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'basicErrorController' method public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest) to {[/proxyServiceError]}: There is already 'proxyServiceErrorController' bean method public org.springframework.http.ResponseEntity com.acme.controller.ProxyServiceErrorController.error(javax.servlet.http.HttpServletRequest) mapped. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) at com.acme.service.ProxyServiceBootstrap.main(ProxyServiceBootstrap.java:25)

I modeled my error controller off of BasicErrorController. What am I missing?

Keith Bennett
  • 733
  • 11
  • 25

1 Answers1

0

Your ProxyServiceErrorController must implement org.springframework.boot.autoconfigure.web.ErrorController. In spring boot, BasicErrorController will not be registered only if there is already an implementation of ErrorController.

Spring boot source

Changing error.path will also affect BasicErrorController. BasicErrorController and your ProxyServiceErrorController are trying to register controllers on the same path - /proxyServiceError now.

yongsung.yoon
  • 5,489
  • 28
  • 32