Skip to content

Feign client failing #121

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

Closed
kabennett opened this issue Dec 11, 2015 · 9 comments
Closed

Feign client failing #121

kabennett opened this issue Dec 11, 2015 · 9 comments

Comments

@kabennett
Copy link

Using Brixton, I am trying to get a Feign client working with the following code in place:

interface CustomerService {
        @RequestLine("GET /customer/check/{customerId}")
        @Headers(value={"Content-Type: application/json","Accept: application/json"})
        Boolean customerExists(@Param("customerId") String customerId);
    }

    CustomerService customerService = Feign.builder().encoder(new JacksonEncoder()).decoder(new JacksonDecoder()).client(RibbonClient.create()).target(CustomerService.class, "http://customerService");

I am receiving the following error:

com.netflix.client.ClientException: Load balancer does not have available server for client: customerService

Looking at https://github.com/spring-cloud/spring-cloud-consul/blob/master/docs/src/main/asciidoc/spring-cloud-consul.adoc, it is mentioned that Feign can be used with Spring Cloud and Consul, and I'd rather use this approach than the DiscoveryClient approach. Using DiscoveryClient seems heavyweight with the use of RestTemplates, and the DiscoveryClient keeps returning host:port ServiceInstances that are no longer up, causing my code to fail unless I manually deregister the failed services in Consul.

@spencergibb
Copy link
Member

@kabennett
Copy link
Author

That link shows that @EnableEurekaClient is required. Is that true?

@spencergibb
Copy link
Member

No, just @EnableDiscoveryClient.

@spencergibb
Copy link
Member

Is this still an issue?

@kabennett
Copy link
Author

No, it's not a problem. However, I have run into a really weird issue. If I use a Feign client as you referred to in an earlier comment AND Swagger, the Boot service fails to start. If I comment out the Feign client code, the Boot service starts fine. My parent POM is Brixton.M3. Have you experienced this problem?

@kabennett
Copy link
Author

Here's the stack trace (ObjectMapper is null):

Caused by: java.lang.NullPointerException: null
    at com.mangofactory.swagger.models.property.field.FieldModelPropertyProvider.propertiesForSerialization(FieldModelPropertyProvider.java:54) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.property.provider.DefaultModelPropertiesProvider.propertiesForSerialization(DefaultModelPropertiesProvider.java:34) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.ModelDependencyProvider.propertiesFor(ModelDependencyProvider.java:119) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.ModelDependencyProvider.resolvedPropertiesAndFields(ModelDependencyProvider.java:94) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.ModelDependencyProvider.resolvedDependencies(ModelDependencyProvider.java:75) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.ModelDependencyProvider.resolvedTypeParameters(ModelDependencyProvider.java:83) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.ModelDependencyProvider.resolvedDependencies(ModelDependencyProvider.java:74) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.ModelDependencyProvider.dependentModels(ModelDependencyProvider.java:37) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.models.DefaultModelProvider.dependencies(DefaultModelProvider.java:82) ~[swagger-models-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.readers.ApiModelReader.populateDependencies(ApiModelReader.java:215) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.readers.ApiModelReader.execute(ApiModelReader.java:80) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.readers.ApiModelReader.execute(ApiModelReader.java:39) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.core.CommandExecutor.execute(CommandExecutor.java:13) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.scanners.ApiListingScanner.scan(ApiListingScanner.java:100) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.core.SwaggerApiResourceListing.initialize(SwaggerApiResourceListing.java:72) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin.initialize(SwaggerSpringMvcPlugin.java:427) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.plugin.SwaggerPluginAdapter.onApplicationEvent(SwaggerPluginAdapter.java:51) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at com.mangofactory.swagger.plugin.SwaggerPluginAdapter.onApplicationEvent(SwaggerPluginAdapter.java:21) ~[swagger-springmvc-1.0.2.jar:1.0.2]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:380) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:386) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:854) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.cloud.netflix.feign.FeignClientFactory.createContext(FeignClientFactory.java:108) ~[spring-cloud-netflix-core-1.1.0.M2.jar:1.1.0.M2]
    at org.springframework.cloud.netflix.feign.FeignClientFactory.getContext(FeignClientFactory.java:75) ~[spring-cloud-netflix-core-1.1.0.M2.jar:1.1.0.M2]
    at org.springframework.cloud.netflix.feign.FeignClientFactory.getInstance(FeignClientFactory.java:113) ~[spring-cloud-netflix-core-1.1.0.M2.jar:1.1.0.M2]
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getOptional(FeignClientFactoryBean.java:120) ~[spring-cloud-netflix-core-1.1.0.M2.jar:1.1.0.M2]
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.feign(FeignClientFactoryBean.java:71) ~[spring-cloud-netflix-core-1.1.0.M2.jar:1.1.0.M2]
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:143) ~[spring-cloud-netflix-core-1.1.0.M2.jar:1.1.0.M2]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    ... 40 common frames omitted

@spencergibb
Copy link
Member

Nope. Don't use swagger. I remember someone else having a similar problem. There was a bug in swagger if I recall.

@kabennett
Copy link
Author

FYI, to resolve the issue, I had to invoke jacksonSwaggerSupport() on SpringSwaggerConfig.

@nirajthanki6
Copy link

Hi @kabennett : I am facing some issue while working with the mangofactory swagger, below is the error i see while running the project, not sure why it's saying 2 beans founds.

Parameter 1 of constructor in com.mangofactory.swagger.models.property.provider.DefaultModelPropertiesProvider required a single bean, but 2 were found: - constructorModelPropertyProvider: defined in URL [jar:file:/Users/nthanki/.gradle/caches/modules-2/files-2.1/com.mangofactory/swagger-models/1.0.2/f564dccc0f4a97fdfe390608a74ad4de8c40fff7/swagger-models-1.0.2.jar!/com/mangofactory/swagger/models/property/constructor/ConstructorModelPropertyProvider.class] - fieldModelPropertyProvider: defined in URL [jar:file:/Users/nthanki/.gradle/caches/modules-2/files-2.1/com.mangofactory/swagger-models/1.0.2/f564dccc0f4a97fdfe390608a74ad4de8c40fff7/swagger-models-1.0.2.jar!/com/mangofactory/swagger/models/property/field/FieldModelPropertyProvider.class]

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