Skip to content
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

HttpTraceFilter bean missing when using Eureka Server #3528

Closed
marcingrzejszczak opened this issue May 7, 2019 · 2 comments
Closed

HttpTraceFilter bean missing when using Eureka Server #3528

marcingrzejszczak opened this issue May 7, 2019 · 2 comments

Comments

@marcingrzejszczak
Copy link
Contributor

marcingrzejszczak commented May 7, 2019

For latest snapshots, when running the contract samples I started getting

[ERROR] org.springframework.cloud.contract.stubrunner.spring.cloud.eureka.StubRunnerSpringCloudEurekaAutoConfigurationSpec  Time elapsed: 4.376 s  <<< ERROR!
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.cloud.contract.stubrunner.spring.cloud.eureka.StubRunnerSpringCloudEurekaAutoConfigurationSpec.setupSpec(StubRunnerSpringCloudEurekaAutoConfigurationSpec.groovy:79)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.cloud.contract.stubrunner.spring.cloud.eureka.StubRunnerSpringCloudEurekaAutoConfigurationSpec.setupSpec(StubRunnerSpringCloudEurekaAutoConfigurationSpec.groovy:79)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'traceFilterRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.servlet.Filter' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value="httpTraceFilter")}
    at org.springframework.cloud.contract.stubrunner.spring.cloud.eureka.StubRunnerSpringCloudEurekaAutoConfigurationSpec.setupSpec(StubRunnerSpringCloudEurekaAutoConfigurationSpec.groovy:79)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.servlet.Filter' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value="httpTraceFilter")}
    at org.springframework.cloud.contract.stubrunner.spring.cloud.eureka.StubRunnerSpringCloudEurekaAutoConfigurationSpec.setupSpec(StubRunnerSpringCloudEurekaAutoConfigurationSpec.groovy:79)

in order to work around this I needed to add a filter with that name:

@Configuration
    @EnableAutoConfiguration
    @EnableEurekaServer
    static class EurekaServer {

        @Bean
        Filter httpTraceFilter() {
            return new Filter() {
                @Override
                void init(FilterConfig filterConfig) throws ServletException {

                }

                @Override
                void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
                    filterChain.doFilter(servletRequest, servletResponse)
                }

                @Override
                void destroy() {

                }
            }
        }


    }
@ztomic
Copy link

ztomic commented May 9, 2019

I'm having same problem, my workaround:

@ConditionalOnMissingBean
@Bean
public HttpTraceRepository httpTraceRepository() {
  return new InMemoryHttpTraceRepository();
}

Possible caused by: spring-projects/spring-boot@de128fe / spring-projects/spring-boot#15039

@dsyer
Copy link
Contributor

dsyer commented May 13, 2019

Should be easy to fix - just add a @Conditional to that bean definition that is failing.

@dsyer dsyer closed this as completed in e2f1f36 May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants