0

I’m setting up a Spring Boot microservice infrastructure with a Eureka Service Registry.

I’m using RestTemplate to call another service (resolution done via Eureka) locally it works perfect! But on Cloud Foundry I always get a “301 Moved permanently” errorcode when calling the service.

Anyone knows if there is a specific configuration necessary for RestTemplate to work with Eureka on Cloud Foundry?

@Bean
@LoadBalanced
RestTemplate getRestTemplate() {
    return new RestTemplate();
}

public UserMapping getUserMappingFromRemoteServer(String name_id){
    UserMapping userMappingResponse = mappingTemplate.getForObject("http://user-mapping/user?id=" + name_id, UserMapping.class);
}

My response is always

Setting request Accept header to [application/json, application/*+json] 

Created GET request for "http://user-mapping/user?id=1" 

GET request for "http://user-mapping/user?id=1" resulted in 301 (MOVED_PERMANENTLY)

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.user.SmartCharging.UserMapping] and content type [text/html]]
g00glen00b
  • 41,995
  • 13
  • 95
  • 133
Paul Wein
  • 609
  • 5
  • 9

1 Answers1

0
eureka:
  instance:
    non-secure-port-enabled: false
    secure-port-enabled: true

did the job

Paul Wein
  • 609
  • 5
  • 9