title: java : spring rest WS - Unable to locate object to be marshalled in a model
body: <p>Getting the exception while trying to run rest ws in spring mvc 3.0 with jaxb</p>
  
  <blockquote>
    <p>javax.servlet.ServletException: Unable to locate object to be marshalled in model: 
    {org.springframework.validation.BindingResult.employees=org.springframework.validation.BeanPropertyBindingResult: 0 errors, employees=spring3.rest.bean.EmployeeList@13d1402}</p>
  </blockquote>
  
  <p>My rest-servlet.xml file has jaxb entry as follow</p>
  
  <pre><code>&lt;bean id="employees" class="org.springframework.web.servlet.view.xml.MarshallingView"&gt;
   &lt;constructor-arg ref="jaxbMarshaller" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code> &lt;bean id="employeeController" class="spring3.rest.controller.EmployeeController"&gt;
    &lt;property name="employeeDS" ref="employeeDS" /&gt; 
    &lt;property name="jaxb2Mashaller" ref="jaxbMarshaller" /&gt;
   &lt;/bean&gt;
  </code></pre>
  
  <p>EmployeeController is :</p>
  
  <pre><code>@Controller
  public class EmployeeController {
  
  private EmployeeDS employeeDS;
  
  public void setEmployeeDS(EmployeeDS ds) {
      this.employeeDS = ds;
  }
  
  private Jaxb2Marshaller jaxb2Mashaller;
  
  public void setJaxb2Mashaller(Jaxb2Marshaller jaxb2Mashaller) {
      this.jaxb2Mashaller = jaxb2Mashaller;
  }
  
  @RequestMapping(method=RequestMethod.GET, value="/employee/{id}")
  public ModelAndView getEmployee(@PathVariable String id) {
      Employee e = employeeDS.get(Long.parseLong(id));
      return new ModelAndView("employees", "object", e);
  }
  </code></pre>
  
  <p>In rest-servlet.xml</p>
  
  <p>
   
      
          spring3.rest.bean.EmployeeList
           spring3.rest.bean.Employee 
      
   
  </p>
  
  <p>and both these beans are annoted with @XmlRootElement</p>