Spring Boot Cloud ACTUATOR / конечная точка обновления: исключение: фильтры не могут быть добавлены в контекст /ROOT, так как контекст был инициализирован
Получение следующего исключения при обновлении облачного приложения весенней загрузки из ACTUATOR (/Refresh). Он работает на отдельном сервере Tomcat. Он использует SpringBootServletInitializer.:
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.IllegalStateException: Filters can not be added to context /ROOT as the context has been initialised
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.cloud.context.restart.RestartEndpoint.restart(RestartEndpoint.java:160) [spring-cloud-context-1.1.8.RELEASE.jar:1.1.8.RELEASE]
at org.springframework.cloud.context.restart.RestartEndpoint.invoke(RestartEndpoint.java:94) [spring-cloud-context-1.1.8.RELEASE.jar:1.1.8.RELEASE]
at org.springframework.cloud.context.restart.RestartEndpoint.invoke(RestartEndpoint.java:43) [spring-cloud-context-1.1.8.RELEASE.jar:1.1.8.RELEASE]
at org.springframework.boot.actuate.endpoint.mvc.AbstractEndpointMvcAdapter.invoke(AbstractEndpointMvcAdapter.java:56) [spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke(EndpointMvcAdapter.java:42) [spring-boot-actuator-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.cloud.context.restart.RestartMvcEndpoint.access$001(RestartMvcEndpoint.java:34) [spring-cloud-context-1.1.8.RELEASE.jar:1.1.8.RELEASE]
at org.springframework.cloud.context.restart.RestartMvcEndpoint$1.run(RestartMvcEndpoint.java:51) [spring-cloud-context-1.1.8.RELEASE.jar:1.1.8.RELEASE]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
Caused by: java.lang.IllegalStateException: Filters can not be added to context /ROOT as the context has been initialised
at org.apache.catalina.core.ApplicationContext.addFilter(ApplicationContext.java:1006) ~[catalina.jar:7.0.67]
at org.apache.catalina.core.ApplicationContext.addFilter(ApplicationContext.java:971) ~[catalina.jar:7.0.67]
at org.apache.catalina.core.ApplicationContextFacade.addFilter(ApplicationContextFacade.java:454) ~[catalina.jar:7.0.67]
at org.springframework.boot.web.servlet.AbstractFilterRegistrationBean.onStartup(AbstractFilterRegistrationBean.java:225) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.web.servlet.FilterRegistrationBean.onStartup(FilterRegistrationBean.java:42) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:229) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:89) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:213) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:168) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
... 13 common frames omitted
1 ответ
Spring Boot Cloud ACTUATOR / конечная точка перезапуска: Исключение: невозможно добавить фильтры в контекст /ROOT, так как контекст был инициализирован
Следующие 4 фильтра создавали проблему: errorPageFilter, metricsFilter, webRequestLoggingFilter, applicationContextIdFilter
Вот решение:
public class XXXSpringBootServletInitializer extends SpringBootServletInitializer {
@Override
public WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
// Disable errorPageFilter
setRegisterErrorPageFilter(false);
// Disable metricsFilter
System.setProperty("endpoints.metrics.filter.enabled", "false");
// Disable applicationContextIdFilter
System.setProperty("management.addApplicationContextHeader", "false");
WebApplicationContext oWebApplicationContext = super.createRootApplicationContext(servletContext);
return oWebApplicationContext;
}
}
Отключить webRequestLoggingFilter:
@SpringBootApplication(exclude={TraceWebFilterAutoConfiguration.class})
public class SIGBootApplication {
........
}