title: Spring MVC - RestTemplate launch exception when http 404 happens
body: <p>I have a rest service which send an 404 error when the resources is not found.
  Here the source of my controller and the exception which send Http 404.</p>
  <pre><code>@Controller
  @RequestMapping(&quot;/site&quot;)
  public class SiteController
  {
  
      @Autowired
      private IStoreManager storeManager;
  
      @RequestMapping(value = &quot;/stores/{pkStore}&quot;, method = RequestMethod.GET, produces = &quot;application/json&quot;)
      @ResponseBody
      public StoreDto getStoreByPk(@PathVariable long pkStore) {       
          Store s = storeManager.getStore(pkStore);
          if (null == s) {
              throw new ResourceNotFoundException(&quot;no store with pkStore : &quot; + pkStore);
          }
          return StoreDto.entityToDto(s);       
  
      }
  }
   
  @ResponseStatus(value = HttpStatus.NOT_FOUND)
  public class ResourceNotFoundException extends RuntimeException
  {       
      private static final long serialVersionUID = -6252766749487342137L;    
      public ResourceNotFoundException(String message) {
          super(message);
      }    
  }
  </code></pre>
  <p>When i try to call it with RestTemplate with this code :</p>
  <pre><code>ResponseEntity&lt;StoreDto&gt; r = restTemplate.getForEntity(url, StoreDto.class, m);
   System.out.println(r.getStatusCode());
   System.out.println(r.getBody());
  </code></pre>
  <p>I receive this exception :</p>
  <pre><code>org.springframework.web.client.RestTemplate handleResponseError
  ATTENTION: GET request for &quot;http://........./stores/99&quot; resulted in 404 (Introuvable); invoking error handler
  org.springframework.web.client.HttpClientErrorException: 404 Introuvable
  </code></pre>
  <p>I was thinking I can explore my responseEntity Object and do some things with the statusCode. But exception is launch and my app go down.</p>
  <p>Is there a specific configuration for restTemplate to not send exception but populate my ResponseEntity.</p>