title: @LoadBalanced RestTemplate to call nested context endpoints
body: <p>The below guide page is great and works as a base case for ribbon in a spring boot application. </p>
  
  <p><a href="https://spring.io/guides/gs/client-side-load-balancing/" rel="nofollow">https://spring.io/guides/gs/client-side-load-balancing/</a></p>
  
  <p>The example stops working as soon as the endpoint mappings become nested - e.g. adding </p>
  
  <blockquote>
    <p>@RequestMapping(value = "/welcome")</p>
  </blockquote>
  
  <p>at the class level</p>
  
  <pre><code>@RestController
  @SpringBootApplication
  @RequestMapping(value = "/welcome") //&lt;------------- ADDED ---&gt;
  public class SayHelloApplication {
  
    private static Logger log = LoggerFactory.getLogger(SayHelloApplication.class);
  
    @RequestMapping(value = "/greeting")
    public String greet() {
  </code></pre>
  
  <p>And then change the @LoadBalanced RestTemplate call in the client from</p>
  
  <pre><code>String greeting = this.restTemplate.getForObject("http://say-hello/greeting", String.class);
  </code></pre>
  
  <p>to </p>
  
  <pre><code>String greeting = this.restTemplate.getForObject("http://say-hello/welcome/greeting", String.class);
  </code></pre>
  
  <p>Calls are failing with attached stacktrace while directly acessing <a href="http://localhost:8090/welcome/greeting" rel="nofollow">http://localhost:8090/welcome/greeting</a> still works fine. What would be the appropriate way to configure ribbon to load balance requests to long and nested URL endpoints such as domain.com/x/y/z/p/q?</p>
  
  <p>Stacktrace:</p>
  
  <pre><code>java.lang.IllegalStateException: No instances available for say-hello
      at org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:79) ~[spring-cloud-netflix-core-1.1.4.RELEASE.jar:1.1.4.RELEASE]
      at org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor.intercept(LoadBalancerInterceptor.java:46) ~[spring-cloud-commons-1.1.1.RELEASE.jar:1.1.1.RELEASE]
      at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:85) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:69) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:596) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:557) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:264) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE]
      at hello.UserApplication.hi(UserApplication.java:31) ~[classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
      at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
  </code></pre>