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

@EnableDiscoveryClient doesn't register properly #172

Closed
Kaffeekaethe opened this issue Apr 17, 2016 · 8 comments
Closed

@EnableDiscoveryClient doesn't register properly #172

Kaffeekaethe opened this issue Apr 17, 2016 · 8 comments

Comments

@Kaffeekaethe
Copy link

Kaffeekaethe commented Apr 17, 2016

I hope this is the right place with my issue.

I've set up a Spring Boot Application two Classes.

The ServiceClass has the Annotations

@SpringBootApplication
@EnableDiscoveryClient

And I have a seperate ControllerClass with the Annotations

@EnableAutoConfiguration
@Controller

I run it with SpringApplication.run(ControllerClass.class, args);

If I use the @EnableDiscoveryClient at the ControllerClass I get the Error:

> Exception in thread "main" 2016-04-17 15:58:29.464  INFO 5816 --- [       Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@c8c12ac: startup date [Sun Apr 17 15:58:28 CEST 2016]; root of context hierarchy
java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.consul.discovery.ConsulDiscoveryClientConfiguration.consulLifecycle
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148)
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:610)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:690)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:970)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:959)
    at com.db.systel.bachelorproject2016.seatmanagementservice.SeatManagementService.main(SeatManagementService.java:26)
Caused by: java.lang.IllegalArgumentException: @ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation)
    at org.springframework.util.Assert.isTrue(Assert.java:65)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanSearchSpec.<init>(OnBeanCondition.java:235)
    at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    ... 16 more

but if I use it for the ServiceClass it compiles and starts.

However, I connect to my Consul-Server, but I do not register. The only thing that is send is:

'2016/04/17 12:33:46 [DEBUG] http: Request GET /v1/kv/config/service/?recurse&token=<hidden> (0) from=127.0.0.1:52166
2016/04/17 12:33:46 [DEBUG] http: Request GET /v1/kv/config/application/?recurse&token=<hidden> (0) from=127.0.0.1:52166'

but from what I understand, my service would actually need to send a Post Request with the information in JSON-Format.

I do not really understand where I am going wrong or if there's something wrong with the annotation.

@n3integration
Copy link

n3integration commented Apr 20, 2016

I ran into the same issue. In my case, it happened because of a collision with a transitive dependency. I had to setup an exclusion rule for the transitive dependency:

compile("org.springframework.cloud:spring-cloud-starter-consul-all") {
    exclude(group: 'org.springframework.cloud', module: 'spring-cloud-netflix-core')
}

@spencergibb
Copy link
Member

@n3integration that's actually bad, because you won't get ribbon support. Are you using the spring boot dependency management plugin?

@spencergibb
Copy link
Member

@Kaffeekaethe can you show your configuration?

@n3integration
Copy link

n3integration commented Apr 26, 2016

@spencergibb - Thanks for the tip and being so responsive. In one of my use cases, I may need ribbon support. Also, I am using the spring boot dependency management plugin. I was receiving a similar stack trace as @Kaffeekaethe, because of the Eureka and Consul discovery clients, so I excluded the netflix-core dependency to work around the conflict. Is there another way around this without excluding the dependency?

@spencergibb
Copy link
Member

You'll have to share a project that duplicates the problem.

@n3integration
Copy link

I apologize for the delay in getting back. In my case, I am also importing spring-cloud-starter-zuul, which also imports the ribbon dependency. So I should be all set, correct?

@spencergibb
Copy link
Member

You should be, but if you're still having the problem, I'll need to see a sample project.

@spencergibb
Copy link
Member

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

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

3 participants