Hibernate validator error - 4.0.2.GA

the Hibernate Validator authentication feature seems to be a bug (hibernate-validator-4.0.2.GA.jar version). Perhaps I missed the addiction?

Part of my stack trace:

java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil; at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:33) at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:112) at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47) at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:764) at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:331) at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:278) at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:260) at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:213) at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119) 
+4
source share
6 answers

I think this is due to the fact that he thinks that you are using JPA2, but actually you are using JPA1. Remove jpa-api-2.0.Beta-20090815.jar, which is included in the Hibernate Validator distribution, if you do not need it, and try again.

+6
source

This seems to be a bug that was fixed in version 4.2.0.Beta1 of the Hibernate validator according to this Jira: https://hibernate.onjira.com/browse/HV-374

The stack trace is very confusing because it assumes that Java 5 is being used, but I was sure that I was running Java 6.

I also did not have the opportunity to update the validator, and I already ran ejb3-persistence-1.0.2.GA.jar, which is the proposed solution from @Gaim, so I needed to create my own CustomTraversableResolver that forces JPA1. Details on how to do this are available here: http://soadev.blogspot.se/2010/02/jsr-303-bean-validation-error.html

+2
source

I am stuck on this issue today and did some digging on it. I found @Javi's answer helpful, but that did not solve my problem. A few dozen more minutes of the search query made me find out the following:

Hibernate validator version 4.0.2.GA (and probably also in others) detects the JPA version of the javax.persistence.PersistenceUtil class , because this class does NOT contain in JPA 1, but it is in JPA 2. Unfortunately, some libraries implement this class, which makes Hibernate a bit confusing. In this case, he tries to use JPA 2 also in Java 1.5, which throws the exception mentioned in the question.

The solution is simple. Find out the library by adding this class and deleting it. In my case, it was ejb3-persistence-1.0.1.GA.jar . This error was registered a long time ago, and in the version ejb3-persistence-1.0.2.GA.jar it is fixed. There, this update solved the problem in my case.

+1
source

Just now I discovered that java has a current dependency. As soon as I upgraded to java 6, all the errors above disappeared.

http://javaprogrammingtips4u.blogspot.com

0
source

Try adding ejb3-persistence 1.0.2GA to your path to the / maven pom class:

 <dependency> <groupId>org.hibernate</groupId> <artifactId>ejb3-persistence</artifactId> <version>1.0.2.GA</version> </dependency> 

There is a good explanation here: dependency-hell-or-including-jsr303

0
source

Try switching to hibernate-validator 4.2 + version. I had the same problem with hibernate-validator 4.1.0, but when I upgraded to version 4.2.0, the problem disappeared.

  <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator-annotation-processor</artifactId> <version>4.2.0.Final</version> </dependency> 
0
source

All Articles