Search code examples
spring-mvcspring-roo

Unexpected Date Conversion failure with Spring Roo and Spring MVC


I use Spring MVC together with Spring Roo and I have added a JPA finder to one of my entities. I also have @RooWebScaffold and a @RooWebFinder annotations as follows:

@RooWebScaffold(path = "plis", formBackingObject = Pli.class)
@RooWebFinder

One of my JPA finders uses a java.util.Date and when I run the @RooWebFinder, I systematically get the following exception in the console and I am redirected to a 404:

2012-07-13 14:13:31,515 ["http-bio-8131"-exec-16] DEBUG org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolving exception from handler [public java.lang.String trc.suivi.controller.PliController.findPlisByIdentifiantLikeAndDateReceptionBetweenAndPaiementAndARAndNumeroARLikeAndFDVAndConteneurNumAndStatut(java.lang.String,java.util.Date,java.util.Date,java.lang.Boolean,java.lang.Boolean,java.lang.String,java.lang.Boolean,trc.suivi.domain.ConteneurNum,trc.suivi.domain.StatutPli,org.springframework.ui.Model)]: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.util.Date'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.web.bind.annotation.RequestParam @org.springframework.format.annotation.DateTimeFormat java.util.Date for value '2012-07-04'; nested exception is java.lang.IllegalArgumentException: Invalid format: "2012-07-04" is malformed at "12-07-04"

What am I missing out?


Solution

  • Looks like the date you specified was of the incorrect format: Invalid format: "2012-07-04" is malformed at "12-07-04"

    What is the date formation on the field in the entity object?

    Could try two year date.