Announcement Announcement Module
Collapse
No announcement yet.
NumberFormatter and DateFormater and BeanPropertyBindingResult Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NumberFormatter and DateFormater and BeanPropertyBindingResult

    Hi,
    I have some number and date fields annotated with NumberFormatter and DateFormmater and when I insert some value that is not being able to convert I get the following exception:

    Internal Error

    Sorry, we encountered an internal error.

    Details

    org.springframework.validation.BeanPropertyBinding Result: 1 errors Field error in object 'goal' on field 'price': rejected value [i]; codes [typeMismatch.goal.price,typeMismatch.price,typeMis match.java.lang.Float,typeMismatch]; arguments [org.springframework.context.support.DefaultMessage SourceResolvable: codes [goal.price,price]; arguments []; default message [price]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Float' for property 'price'; nested exception is org.springframework.core.convert.ConversionFailedE xception: Unable to convert value "i" from type 'java.lang.String' to type 'java.lang.Float'; nested exception is java.lang.IllegalArgumentException: Unable to parse 'i']
    org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.doBind(HandlerMethodInvoker.jav a:810)
    org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.resolveHandlerArguments(Handler MethodInvoker.java:359)
    org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:153)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:426)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:414)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:304)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    org.springframework.web.filter.ShallowEtagHeaderFi lter.doFilterInternal(ShallowEtagHeaderFilter.java :58)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.doFilterInternal(OpenEntityManager InViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 368)
    org.springframework.security.web.access.intercept. FilterSecurityInterceptor.invoke(FilterSecurityInt erceptor.java:109)
    org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter(FilterSecurityI nterceptor.java:83)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.access.ExceptionT ranslationFilter.doFilter(ExceptionTranslationFilt er.java:97)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.session.SessionMa nagementFilter.doFilter(SessionManagementFilter.ja va:100)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.authentication.An onymousAuthenticationFilter.doFilter(AnonymousAuth enticationFilter.java:78)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.servletapi.Securi tyContextHolderAwareRequestFilter.doFilter(Securit yContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.savedrequest.Requ estCacheAwareFilter.doFilter(RequestCacheAwareFilt er.java:35)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.authentication.http://www.BasicAuthenticationFilter...lter.java:177)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:187)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.authentication.lo gout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.context.SecurityC ontextPersistenceFilter.doFilter(SecurityContextPe rsistenceFilter.java:79)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 380)
    org.springframework.security.web.FilterChainProxy. doFilter(FilterChainProxy.java:169)
    org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:237)
    org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:167)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    org.springframework.web.filter.HiddenHttpMethodFil ter.doFilterInternal(HiddenHttpMethodFilter.java:7 7)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
    org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:224)
    org.apache.catalina.core.StandardContextValve.__in voke(StandardContextValve.java:175)
    org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java)
    org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:164)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:100)
    org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:929)
    org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:405)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:279)
    org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:515)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:302)
    java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
    java.lang.Thread.run(Thread.java:680)

    What I really want is the behavior similar to validation. I want this exception becomes a part of BindingResult as an Error so I can show this error via form:errors tag. Now, I am redirected to the new page that catches all unresolved exceptions and prints it.

    How to achieve behavior similar to validation? Now I see these annotations a bit useless If I cannot handle exceptions gracefully
Working...
X