title: 406 error when attempting to retrieve JSON from endpoint
body: <p>I saw a couple other questions of this nature but they didn't quite fit the bill.</p>
  
  <p>I am currently trying to return JSON from two different controllers. In one of my controllers, it works with no problem, but when I hit my second endpoint, I get a 406 error and I can't figure out what's wrong. Here's the controller action:</p>
  
  <pre><code>@RequestMapping("/v1/companies/name/{companyName}")
  public @ResponseBody ResultsList&lt;CompanyResult&gt; getCompaniesByName(@PathVariable("companyName") String companyName) {
  
      if (StringUtils.isEmpty(companyName)) {
          throw new HttpMessageNotReadableException("blah");
      }
  
      ResultsList&lt;CompanyResult&gt; results = companySearchService.getCompaniesByName(companyName);
  
      return results;
  }
  </code></pre>
  
  <p>Here's the model I'm attempting to return:</p>
  
  <pre><code>public class ResultsList&lt;T&gt; {
      @XmlElement(name = "results")
      private ArrayList&lt;T&gt; results;
  
      public int resultCount() {
          return this.results.size();
      }
  
      public void addResult(T result) {
          this.results.add(result);
      }
  
      public ResultsList() {
          this.results = new ArrayList&lt;T&gt;();
      }
  }
  </code></pre>
  
  <p>As you can see from the controller code, my ResultsList is made up of CompanyResult objects:</p>
  
  <pre><code>public class CompanyResult implements ICompany {
      @XmlElement(name = "companyName")
      private String companyName;
  
      @XmlElement(name = "symbol")
      private String symbol;
  
      @XmlElement(name = "city")
      private String city;
  
      @XmlElement(name = "state")
      private String state;
  ......
  </code></pre>
  
  <p>So my controller returns a @RequestBody ResultsList, which is annotated with @XmlElement, and the objects contained in the list are also annotated with @XmlElement. This is what I had to do to get the other scenario to work. But this one fails. Can anyone tell me why?</p>