title: Can ModelAttribute be primitive?
body: <p>I am having a strange problem with ModelAttribute in Spring MVC 3.0. When I deploy the app at localhost, it works fine. But when I deploy the app on a remote server, it fails everytime user access a specific action, with the errors:</p>
  
  <pre><code>ERROR: my.package.application.web.filter.ExceptionFilter - long.&lt;init&gt;()
  java.lang.NoSuchMethodException: long.&lt;init&gt;()
          at java.lang.Class.getConstructor0(Class.java:2706)
          at java.lang.Class.getDeclaredConstructor(Class.java:1985)
          at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:104)
          at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveModelAttribute(HandlerMethodInvoker.java:762)
          at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:356)
          at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:153)
          at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
          at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p>The code that I user to init the ModelAttribute in that controller is:</p>
  
  <pre><code>    @ModelAttribute("id")
      public long getUserId(HttpSession session) {
          UserInfoHolder userHolder = (UserInfoHolder) session
                  .getAttribute("userHolder");
          long userId = userHolder.getUserId();
          return userId;
      }
  </code></pre>
  
  <p>As far as I can tell, the bug can't be reproduced at my local workstation. And it happens before the action get called.</p>
  
  <p>Looking in HandlerMethodInvoker.java (line 762), we see this line:</p>
  
  <pre><code>bindObject = BeanUtils.instantiateClass(paramType);
  </code></pre>
  
  <p>An experienced peer of mine believes that this line causes problem, because that a primitive-type ModelAttribute(long) doesn't have a constructor. I think that reason maybe right, but how can it explain that the web application works fine on my local server?</p>
  
  <p>I tried to search to know if ModelAttribute support primitive data type, but with no good results. Does anyone have experience about this issue?</p>