title: Cannot call senderror() after response has been committed Tomcat Spring MVC
body: <p>If I am returning a Employee object in my controller class, I get a response from my REST service. But if I am trying to return a List, then I frequently get this error:</p>
  
  <p>Error:cannot call senderror() after the response has been committed
  (Also atttached the image)
  <a href="https://i.stack.imgur.com/ghvWM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ghvWM.png" alt="enter image description here"></a>
  I am using Eclipse, tomcat, maven and making a spring REST service.</p>
  
  <p>Here is my Controller class code snippetwhich is returning Employee, and everything is fine and I can see my JSON data on browser. But when I change Employee to List as my new return type, I receive the following error and my Eclipse also hangs for few minutes. I think my problem could have to do with the JSON convertor. Please help.</p>
  
  <pre><code>@Controller
  @RequestMapping("/emp")
  public class EMPController {
  
  @Autowired
  EmployeeService empservice;
  @RequestMapping("byname3/{name}")
  @ResponseBody
  public Employee getByName(@PathVariable String name) {
      System.out.println("Inside getByName()..successfully..EMPController");
      .....
      ......
  </code></pre>
  
  <p>My dispatcher-servlet.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
  
      &lt;context:component-scan base-package="com.spice.controller" /&gt;
      &lt;context:component-scan base-package="com.spice.daoImpl" /&gt;
      &lt;context:component-scan base-package="com.spice.serviceImpl " /&gt;
  
      &lt;mvc:annotation-driven /&gt;   &lt;!-- tHIS HELPS IN AUTOMATIC JSON-TO-JAVA AND VICE VERSA CONVERTUION --&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
          &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"&gt;&lt;/property&gt;
          &lt;property name="url" value="jdbc:oracle:thin:@localhost:1521:xe"&gt;&lt;/property&gt;
          &lt;property name="username" value="tiwari"&gt;&lt;/property&gt;
          &lt;property name="password" value="tiwari"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="mysessionFactory"
          class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;!-- eARLIER i WAS USING org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean --&gt;
          &lt;!-- BUT THIS LEADS TO SOME CACHE PROVIDER CLASS NOT FOUND EXCEPTION --&gt;
          &lt;!-- ALSO THIS AnnotationSessionFactoryBean IS NOW REPLACED BY LocalSessionFactoryBean --&gt;
          &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
  
           &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.spice.beans.Employee&lt;/value&gt;
                  &lt;value&gt;com.spice.beans.Address&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
  
  
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt; 
  
      &lt;bean id="transactionManager"  
          class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;!-- THIS CLASS IS COMPATIBLE WITH ABOVE VERSIONS OF SPRING AND HIBERNATE  --&gt;  
          &lt;property name="sessionFactory" ref="mysessionFactory" /&gt;  
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>