title: MarshallingView in Spring MVC 3
body: <p>I'm getting this error when I use MarshallingView to marshal my list (java.util.List) of FileManagement objects. This doesn't happen if I just add only one object to the model. So it's working with an object but not with the collection (List).</p>
  
  <p><strong>Exception</strong>:</p>
  
  <pre><code>javax.servlet.ServletException: Model object [[com.afirme.filemanagement.domain.FileManagement@69c, com.afirme.filemanagement.domain.FileManagement@65f, com.afirme.filemanagement.domain.FileManagement@661, com.afirme.filemanagement.domain.FileManagement@69d, com.afirme.filemanagement.domain.FileManagement@662]] retrieved via key [fileManagements] is not supported by the Marshaller
      at org.springframework.web.servlet.view.xml.MarshallingView.locateToBeMarshalled(MarshallingView.java:129)
      at org.springframework.web.servlet.view.xml.MarshallingView.renderMergedOutputModel(MarshallingView.java:98)
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1120)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:890)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:851)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:756)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
  </code></pre>
  
  <p><strong>FileManagement.java</strong>:</p>
  
  <pre><code>@XmlRootElement
  public class FileManagement {
  
      private Long id;
  
      private String code;
      private String name;
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getCode() {
          return code;
      }
  
      public void setCode(String code) {
          this.code = code;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
  }
  </code></pre>
  
  <p><strong>FileManagementService.java</strong>:</p>
  
  <pre><code>public interface FileManagementService {
  
      /**
       * Find all FileManagements.
       * @return
       */
      public List&lt;FileManagement&gt; findAll();
  }
  </code></pre>
  
  <p><strong>FileManagementController.java</strong>:</p>
  
  <pre><code>@Controller
  public class FileManagementController {
  
      @RequestMapping(value="/filemanagements", method=RequestMethod.GET)
      public String list(Model model) {
          model.addAttribute("fileManagements", fileManagementService.findAll());
          return LIST_VIEW;
      }
  
      private static final String LIST_VIEW = "/filemanagements/list" ;
  }
  </code></pre>
  
  <p><strong>servletContext.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
                          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                          http://www.springframework.org/schema/context
                          http://www.springframework.org/schema/context/spring-context-3.1.xsd
                          http://www.springframework.org/schema/mvc
                          http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                          http://www.springframework.org/schema/oxm 
                          http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd"&gt;
  
      &lt;oxm:jaxb2-marshaller id="marshaller"&gt;
          &lt;oxm:class-to-be-bound
              name="com.afirme.filemanagement.domain.FileManagement" /&gt;
      &lt;/oxm:jaxb2-marshaller&gt;
  
      &lt;context:component-scan
          base-package="com.afirme.filemanagement.controller" /&gt;
  
      &lt;bean id="xmlViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver"/&gt;
  
      &lt;bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
        &lt;property name="prefix" value="/WEB-INF/jsp" /&gt;
        &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  
      &lt;mvc:annotation-driven/&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>/WEB-INF/views.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:oxm="http://www.springframework.org/schema/oxm"
      xsi:schemaLocation="http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
          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"&gt;
  
      &lt;bean name="/filemanagement/list" class="org.springframework.web.servlet.view.xml.MarshallingView"&gt;
          &lt;property name="marshaller" ref="marshaller"/&gt;
          &lt;property name="modelKey" value="fileManagements"/&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>