NullPointerException is thrown when using @FeignClient on Spring Cloud based Apps
search cancel

NullPointerException is thrown when using @FeignClient on Spring Cloud based Apps

book

Article ID: 297146

calendar_today

Updated On:

Products

Support Only for Spring

Issue/Introduction

Symptoms:

You have a Spring Application that is using Spring Cloud as your dependencies. You are using the @FeignClient annotation for your service. An example would be

@FeignClient(name = "my-service")

public interface MyServiceClient {

     @RequestMapping(value = "/transactions/{accountId}", method = RequestMethod.GET, headers = "Accept=application/json")

     public List<MyTransactionDTO> getMyTransactionsByAccountId(@PathVariable("accountId") String accountId) ;

}

Pushing the application to Pivotal Cloud Foundry throws

OUT Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.infosys.icets.microservices.account.service.TransactionsServiceClient': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException

 

 

Environment


Cause

This is an existing bug in Spring Boot that was resolved in 1.4.7 

 

Resolution

Upgrade to Spring Boot version 1.4.7 or higher to fix this issue. It is also recommended that you use Spring Cloud 1.5 / Dalston or higher