title: Not able to return ResponseEntity with Exception Details in spring
body: <p>I have created a Spring Restful Service and Spring MVC application.</p>
  
  <p>Restful Service :: 
  Restful service returns an entity if its existing in DB. If it doesn't exist It returns a custom Exception information in ResponseEntity object.</p>
  
  <p>It is working as expected tested using Postman.</p>
  
  <pre><code>@GetMapping(value = "/validate/{itemId}", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
  public ResponseEntity&lt;MyItem&gt; validateItem(@PathVariable Long itemId, @RequestHeader HttpHeaders httpHeaders) {
  
      MyItem myItem = myitemService.validateMyItem(itemId);
      ResponseEntity&lt;MyItem&gt; responseEntity = null;
      if (myItem == null) {
          throw new ItemNotFoundException("Item Not Found!!!!");
      }
      responseEntity = new ResponseEntity&lt;MyItem&gt;(myItem, headers, HttpStatus.OK);
      return responseEntity;
  }
  </code></pre>
  
  <p>If the requested Entity does not exist Restful Service returns below.</p>
  
  <pre><code>@ExceptionHandler(ItemNotFoundException.class)
  public ResponseEntity&lt;ExceptionResponse&gt; itemNotFEx(WebRequest webRequest, Exception exception) {
      System.out.println("In CREEH::ItemNFE");
      ExceptionResponse exceptionResponse = new ExceptionResponse("Item Not Found Ex!!!", new Date(), webRequest.getDescription(false));
      ResponseEntity&lt;ExceptionResponse&gt; responseEntity = new ResponseEntity&lt;ExceptionResponse&gt;(exceptionResponse, HttpStatus.NOT_FOUND);
      return responseEntity;
  }
  </code></pre>
  
  <p>But when I am calling the above service from a spring MVC application using RestTemplate, It is returning a valid object if it exists.</p>
  
  <p>If the requested object does not exist Restful service is returning the exception information but its not reaching the calling(spring MVC) application.</p>
  
  <p>Spring MVC application calls Restful Web Service using Rest template</p>
  
  <pre><code>String url = "http://localhost:8080/ItemServices/items/validate/{itemId}";
  ResponseEntity&lt;Object&gt; responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, Object.class, uriParms);
  int restCallStateCode = responseEntity.getStatusCodeValue();
  </code></pre>