the validate function of the Hibernate Validator seems to be buggy (version hibernate-validator-4.0.2.GA.jar). Do I maybe miss a dependency?
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)
I think it's due to the fact that it thinks you're using JPA2 but in fact you're using JPA1. Remove the jpa-api-2.0.Beta-20090815.jar which is included with the distribution of Hibernate Validator if you don't need it and try again.
This seems to be a bug which have been 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 suggests that Java 5 is being used but I was certain that I was running Java 6.
I also did not have the option to update the validator and I was already running ejb3-persistence-1.0.2.GA.jar which is a proposed solution by @Gaim so I needed to create my own CustomTraversableResolver which forces JPA1. Details on how to do that are available here: http://soadev.blogspot.se/2010/02/jsr-303-bean-validation-error.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With