title: java.lang.NullPointerException on DiscoveryClient when calling the method from another class
body: <p>When I am calling the method itself through the browser it's working and I am getting the expected <code>JSON</code>. So the method is working and the requested service is registered.</p>
  
  <pre><code>    @RequestMapping("/getArticle/{articleId}")
  public String getArticle(@PathVariable("articleId") Integer articleId) {
      // {"articleId":47,"name":"test","price":5.0}
      List&lt;ServiceInstance&gt; instances = 
  discoveryClient.getInstances("articlemicroservice");    //null when calling 
      ServiceInstance serviceInstance = instances.get(0);
      String baseUrl = serviceInstance.getUri().toString();
  
      baseUrl = baseUrl + "/db/find/" + articleId.toString();
  
      System.out.println("BASEURL: " + baseUrl);
  
      RestTemplate restTemplate = new RestTemplate();
      ResponseEntity&lt;String&gt; response = null;
  
      try {
          response = restTemplate.exchange(baseUrl, HttpMethod.GET, 
  getHeaders(), String.class);
      } catch (Exception ex) {
          System.out.println(ex);
      }
      // {"articleId":47,"name":"test","price":5.0}
      String articleEntity = response.getBody().toString();
      System.out.println("articleEntity: " + articleEntity);
      return articleEntity;
  }
  </code></pre>
  
  <p>When I am calling the method from another class (which is located in the same project) I am getting a <code>NullPointerException</code>.</p>
  
  <pre><code>    @GetMapping(path = "/addCartItemToCart/{cartId}/{articleId}/{quantity}")
  public @ResponseBody String addCartItemToCart(@PathVariable("cartId") 
  Integer cartId,
          @PathVariable("articleId") Integer articleId, 
  @PathVariable("quantity") Integer quantity) {
  
      ArticleMicroserviceRestConnectorRequester n = new 
  ArticleMicroserviceRestConnectorRequester();
  
      String article = n.getArticle(articleId); //calling the method here
      JSONObject json = new JSONObject(article);
      CartItemEntity cartItemEntity = new CartItemEntity();
      cartItemEntity.setArticleId(json.getInt("articleId"));
      cartItemEntity.setQuantity(quantity);
      cartItemEntity.setCartItemId(cartId);
      CartEntity cartEntity = cartRepository.findById(cartId).get();
      cartEntity.addCartItem(cartItemEntity);
      cartEntity.setNumberOfCartItems(cartEntity.getNumberOfCartItems() + 
   cartItemEntity.getQuantity());
      cartRepository.save(cartEntity);
      return "Saved";     
      }
  </code></pre>
  
  <p>Exception: </p>
  
  <p><code>java.lang.NullPointerException: null
      at de.leuphana.jee.connector.jpa.behaviour.ArticleMicroserviceRestConnectorRequester.getArticle(ArticleMicroserviceRestConnectorRequester.java:44) ~[classes/:na]
  ...</code></p>