Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I'm using Hibernate validator to validate my beans.
Actually I have this dependencies on my POM
<!-- Hibernate validator - Bean validation API Implementation -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.11.Final</version>
</dependency>
<!-- Verify validation annotations usage at compile time -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>6.0.11.Final</version>
</dependency>
<!-- Unified Expression Language - Spec -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.1-b06</version>
</dependency>
<!-- Unified Expression Language - Implementation -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
And this a pice of my bean
import org.hibernate.annotations.ColumnDefault;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
public class Casa {
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
@Column(name="nomcaac") @NotBlank(message = "{casa.nomcaac.null}") @Size(min = 0, max = 300, message = "{casa.nomcaac.size}")
private String nomcaac;
Now the problem comes when i try to validate my bean, i get this error message
No validator could be found for constraint
'javax.validation.constraints.NotBlank' validating type
'java.lang.String'. Check configuration for 'nomcaac'
I can't figure out whats my problem, I think I have the right dependencies according to this page.
–
@NotBlank
is new in Bean Validation 2.0 so I suspect you have an old Hibernate Validator version (e.g. 5.x) in your classpath somehow.
You should check your dependency tree with mvn dependency:tree
(and your webapp looking for an old jar).
By the way, your javax.el dependencies are incorrect: please refer to https://github.com/hibernate/hibernate-validator/#using-hibernate-validator for the correct one.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.