facebook

initBinding() having trouble returning SET to Controller

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #307953 Reply

    Jamie Daniel
    Member

    I am trying to pass back a multi-select SET to the controller and I get this: Anyone know why my initBinder() is having issues with this one?

    org.springframework.web.bind.ServletRequestBindingException: Errors binding onto object 'users'; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
    Field error in object 'users' on field 'authoritieses': rejected value [1]; codes [typeMismatch.users.authoritieses,typeMismatch.authoritieses,typeMismatch.java.util.Set,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [users.authoritieses,authoritieses]; arguments []; default message [authoritieses]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.util.Set] for property 'authoritieses'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [com.jamieproject.domain.Authorities] for property 'authoritieses[0]': no matching editors or conversion strategy found]
        org.springframework.web.bind.ServletRequestDataBinder.closeNoCatch(ServletRequestDataBinder.java:121)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.doBind(AnnotationMethodHandlerAdapter.java:568)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:213)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:132)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:326)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:313)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
        com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
        org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    
    root cause
    
    org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
    Field error in object 'users' on field 'authoritieses': rejected value [1]; codes [typeMismatch.users.authoritieses,typeMismatch.authoritieses,typeMismatch.java.util.Set,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [users.authoritieses,authoritieses]; arguments []; default message [authoritieses]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.util.Set] for property 'authoritieses'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [com.jamieproject.domain.Authorities] for property 'authoritieses[0]': no matching editors or conversion strategy found]
        org.springframework.web.bind.ServletRequestDataBinder.closeNoCatch(ServletRequestDataBinder.java:121)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.doBind(AnnotationMethodHandlerAdapter.java:568)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:213)
        org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:132)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:326)
        org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:313)
        org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
        com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
        org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:112)
        org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    
    #308106 Reply

    Heflin Hogan
    Member

    I’m not sure if you’ve figured this out yet, but I seem to recall some issues where the JSP multi-select gets passed back as a String type which needs to be unpacked manually into a Set. That would explain the type mismatch here.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: initBinding() having trouble returning SET to Controller

You must be logged in to post in the forum log in