error: No validator could be found for type: java.time.LocalDate

I'm working on a project that uses bean validation (Hibernate Validator 5.1.3.Final). My bean has a attribute with the @Past annotation.

@Past(message = "A data deve estar no passado.")
private LocalDate dataAbertura;

But, when the validation occurs I get the following exception:

21:46:12,424 ERROR [io.undertow.request] (default task-35) UT005023: Exception handling request to /financeiro/clientes/pessoafisica: javax.servlet.ServletException: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.time.LocalDate.
    at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:127) [vraptor-4.1.4.jar:]
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
Caused by: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.time.LocalDate.
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.verifyResolveWasUnique(ConstraintValidatorManager.java:218) [hibernate-validator-5.1.3.Final.jar:5.1.3.Final]
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.findMatchingValidatorClass(ConstraintValidatorManager.java:193) [hibernate-validator-5.1.3.Final.jar:5.1.3.Final]
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator(ConstraintValidatorManager.java:97) [hibernate-validator-5.1.3.Final.jar:5.1.3.Final]
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:125) [hibernate-validator-5.1.3.Final.jar:5.1.3.Final]

What's wrong? Hibernate Validator doesn't support LocalDate?


Actually the issue to refer to is HV-874. Hibernate Validator 5.2.x does add support for some of the new Java 8 date/time types. I should stress "some" in this context. In particular LocalDate is not supported. The Javadocs of LocalDate says:

This class does not store or represent a time or time-zone. Instead, it is a description of the date, as used for birthdays. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.

Without an instant on the timeline it is not possible to say if a given date is in the part or future. First by attaching a timezone it would be possible to state and answer this question.

If you still think it makes sense in your use case to use the Past and @Future constraints for LocalDate you can always implement your own ConstraintValidator for LocalDate and register it via XML using a constraint-definition element in a constraint mapping file as seen here.

If you are using Hibernate Validator 5.2, you can also use the Java ServiceLoader approach to register additional ConstraintValidator implementations - see ConstraintDefinitionContributor. The latter is for now a Hibernate Validator specific feature.

[Solved] - UnexpectedTypeException, UnexpectedTypeException error you will get when you are trying to use incorrect UnexpectedTypeException: HV000030: No validator could be found for you try to put @NotBlank annotation on any non-string type field e.g. java.lang. Core Java Tutorial · Collections in Java · Java Concurrency · Java Date and Time​  And then you get the less than helpful warning “No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Integer'.” – Michael Piefel Feb 6 '17 at 15:35


Since LocalDate is still pretty new a lot of libraries don't handle it yet. In the project I am working on I had to write custom user type for LocalDate.

Take a look at this hibernate issue HHH-8844

It seems like they have added a new module hibernate-java8 to support java 8's new Date API.

I know the above information is talking about type mapping but the same might hold true to validation.

If there is no out of the box solution you might just have to write your own. See the following page for an example of adding joda time validators, java 8 dates should be similar link

ERROR: Validating LocalDateTime with @Past · Issue #1 · hielfx , UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Past' validating type 'java.time.LocalDate'. Check  HV000030: No validator could be found for type: java.lang.Integer. That will happen when you use JSR303 bean validation in flavor of Hibernate Validator and you have in your JPA entity the Hibernate-specific @NotEmpty on an Integer property like this: @NotEmpty private Integer some; This is completely wrong.


There is a @Past annotation in the javax.validation.constraints (validation-api-2.0.1.Final)

And it works pretty well for java.time.LocalDate

No validator could be found for constraint javax , Expand frames. javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.time.LocalDate. 2 matching frames hidden. I got an error: HV000030: No validator could be found for constraint ‘javax.validation.constraints.NotEmpty’ validating type ‘java.lang.String’ .Checkconfiguration for ‘updateContest.arg1.shortDescription’


javax.servlet.ServletException: javax.validation , HV000030: No validator could be found for constraint 'javax.validation.constraints​.Pattern' validating type 'java.lang.Integer'. Check configuration for 'test.query  A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.. LocalDate is an immutable date-time object that represents a date, often viewed as year-month-day.


MetaConstraint.validateConstraint() has thrown an , No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.util.Date'. (49.1k xp, 8 posts). - Java 8 - How to convert String to LocalDate


No validator could be found for constraint 'javax.validation , The API is not tied to a specific application tier nor programming model. Hibernate Validator 6 and Jakarta Bean Validation 2.0 require Java 8 types of Node s can be found in the ConstraintViolation section of the LocalDate , java.​time. The interpolated error message can then be retrieved from the  And then you get the less than helpful warning “No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Integer'.” – Michael Piefel Feb 6 at 15:35