0

I have configured a service and client and deployed into PCF Cloud. I have also bind both apps to Service Registry. As I have bind services with Service Registry, I am trying to access service app in client using it's name configuredd in bootstrap.yml file. I am getting "No instances available for service-app" error.

Below are configurations I followed. Service:

@SpringBootApplication
@EnableDiscoveryClient
public class Application {}

application.properties:

spring.cloud.services.registrationMethod = route
security.basic.enabled=false

bootstrap.yml:

spring:
  application:
    name: service-app

and a small controller

@RestController
@RequestMapping(value = "/calculate")
public class CalculationService {

    @RequestMapping(value = "/addition", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public int addition(@QueryParam("X") int X, @QueryParam("Y") int Y) {
        return X + Y;
    }

}

Client:

@SpringBootApplication
@EnableDiscoveryClient
public class Application {}

application.properties:

spring.cloud.services.registrationMethod = route
security.basic.enabled=false

bootstrap.yml

spring:
  application:
    name: compute-client

and a controller accessing service with it's name.

@Autowired
    RestTemplate restTemplate;

    @RequestMapping(value = "/addition/{X}/{Y}")
    public int addition(@PathVariable int X, @PathVariable int Y) {

        String uri = "https://service-app/calculate/addition?X=" + X + "&Y=" + Y;

        return restTemplate.getForObject(uri, Integer.class);

    }

        @Bean
        @LoadBalanced
        public RestTemplate restTemplate() {
            return new RestTemplate();
        }

Both these applications are pushed to PCF and bind to Service Registry. I can access service by it's route. When I try accessing client end point it is giving me error

{
    "timestamp": 1524236514920,
    "status": 500,
    "error": "Internal Server Error",
    "exception": "java.lang.IllegalStateException",
    "message": "No instances available for service-app",
    "path": "/calculate/addition/14/13"
}

What I am missing?

user09
  • 920
  • 2
  • 12
  • 38
  • Could you update `POM.xml` for both `service` and `client`? – Kumaresh Babu N S Aug 14 '18 at 13:39
  • @KumareshBabu this issue has been fixed after adding compile ('io.pivotal.spring.cloud:spring-cloud-services-starter-config-client') in place of compile('org.springframework.cloud:spring-cloud-starter-eureka'). Looks service registry needs eureka starter from pivotal not spring cloud – user09 Aug 15 '18 at 17:54

0 Answers0