title: java.lang.StackOverflowError in spring controller
body: <p>TreesController.java
  This is my controller Methodenter code here</p>
  
  <pre><code>    package com.reveal.web.controller;
  
      import java.util.List;
  
      import org.springframework.http.MediaType;
      import org.springframework.stereotype.Controller;
      import org.springframework.ui.ModelMap;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestMethod;
      import org.springframework.web.bind.annotation.ResponseBody;
  
      import com.reveal.web.controller.EnsureCapacity.Technology;
  
      @Controller
      public class TreesController {
  
          @RequestMapping(value="/mytree",method = RequestMethod.GET)
          public String printWelcome(ModelMap model) {
              return "tree";
          }
          @RequestMapping(value = "/getTechList", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
           public @ResponseBody List&lt;Technology&gt; getTechList(){
  
               return getTechList();
              } 
  
          }
  </code></pre>
  
  <p>This is my Model class EnsureCapacity.java
  From this i am returning values into spring controller from that to my view page,While running getting stackoverflow exception .not understanding where i am wrong</p>
  
  <pre><code>package com.reveal.web.controller;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class EnsureCapacity {
  
      List&lt;Technology&gt; techList = new ArrayList&lt;Technology&gt;(1000);
  
      public List&lt;Technology&gt; getTechList() {
          if(techList.isEmpty()){      
              ((ArrayList&lt;Technology&gt;) techList).ensureCapacity(1000);
              techList.add(new Technology(1, 0,"Node 1"));
              techList.add(new Technology(0, 1,"Node 1.1"));
              techList.add(new Technology(0, 1,"Node 1.2"));
  
              techList.add(new Technology(1, 0,"Node 2"));
              techList.add(new Technology(0, 1,"Node 2.1"));
              techList.add(new Technology(0, 1,"Node 2.2"));
              techList.add(new Technology(0, 1,"Node 2.3"));
              techList.add(new Technology(1, 0,"Node 3"));
              techList.add(new Technology(0, 1,"Node 3.1"));
              techList.add(new Technology(0, 1,"Node 3.2"));
  
  
              techList.add(new Technology(1, 0,"Node 4"));
              techList.add(new Technology(0, 1,"Node 4.2"));
              techList.add(new Technology(0, 1,"Node 4.3"));
              techList.add(new Technology(0, 1,"Node 4.4"));
  
              techList.add(new Technology(1, 0,"Node 5"));
              techList.add(new Technology(0, 1,"Node 4.5"));
              techList.add(new Technology(0, 1,"Node 4.6"));
              techList.add(new Technology(1, 0,"Node 6"));
  
              techList.add(new Technology(0, 1,"Node 6.1"));
  
              techList.add(new Technology(0, 1,"Node 6.2"));
  
              techList.add(new Technology(0, 1,"Node 6.3"));
  
              techList.add(new Technology(0, 1,"Node 6.4"));
  
              techList.add(new Technology(0, 1,"Node 6.5"));
  
              techList.add(new Technology(0, 1,"Node 6.6"));
  
              techList.add(new Technology(0, 1,"Node 6.7"));
  
              techList.add(new Technology(0, 1,"Node 6.8"));
              techList.add(new Technology(1, 0,"Node 7"));
              techList.add(new Technology(0, 1,"Node 7.1"));
              techList.add(new Technology(1, 0,"Node 8"));
              techList.add(new Technology(0, 1,"Node 8.1"));
              techList.add(new Technology(0, 1,"Node 8.2"));
              techList.add(new Technology(0, 1,"Node 8.3"));
              techList.add(new Technology(0, 1,"Node 8.4"));
              techList.add(new Technology(0, 1,"Node 8.5"));
              techList.add(new Technology(0, 1,"Node 8.6"));
              techList.add(new Technology(0, 1,"Node 8.7"));
              techList.add(new Technology(0, 1,"Node 8.8"));
              techList.add(new Technology(0, 1,"Node 8.9"));
  
              techList.add(new Technology(0, 1,"Node 8.10"));
              techList.add(new Technology(0, 1,"Node 8.11"));
              techList.add(new Technology(0, 1,"Node 8.12"));
              techList.add(new Technology(0, 1,"Node 8.12"));
          }
          return techList;
      }
  
  
      public void setTechList(List&lt;Technology&gt; techList) {
          this.techList = techList;
      }
  
      class Technology {
  
          private int Id;
          private int pId;
          private String techName;
  
          public int getId() {
              return Id;
          }
  
          public void setId(int Id) {
              this.Id = Id;
          }
  
          public int getpId() {
              return pId;
          }
  
          public void setpId(int pId) {
              this.pId = pId;
          }
  
          public String getTechName() {
              return techName;
          }
  
          public void setTechName(String techName) {
              this.techName = techName;
          }
  
          public Technology(int Id, int pId, String techName) {
              this.Id = Id;
              this.pId = pId;
              this.techName = techName;
          }
      }
  }`
  </code></pre>