NoSuchMethodError on Persistence.getPersistenceUtil() when one follows the README file
--------------------------------------------------------------------------------------
Key: HV-286
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-286
Project: Hibernate Validator
Issue Type: Patch
Components: documentation
Affects Versions: 4.0.2.GA
Environment: Hibernate Validator 4.0.2 GA
Hibernate Core 3.5.0-Beta 2 (+ Annotations, no EntityManager)
WebLogic 10MP1 (EE5/JPA1)
JDK5
Reporter: Mathias De Belder
Assignee: Hardy Ferentschik
Priority: Trivial
Attachments: readme.patch
The readme.txt file tells one to add all the libraries from
the lib/ subdirectory of the distribution package on the classpath:
"- Copy hibernate-validator-*.jar together will all jar files from lib into the
classpath of your application. In case you are running on JDK5 you have to also
include
all the jar files from the jdk5 subdirectory."
The lib/ directory in 4.0.2GA contains jpa-api-2.0.Beta-20090815.jar, the public JPA2
API. Included in that jar file is javax/persistence/PersistenceUtil.class.
org.hibernate.validator.engine.resolver.DefaultTraversableResolver is the default
TraversableResolver one gets when one calls Validation.buildDefaultValidationFactory().
In its constructor, DefaultTraversableResolver calls detectJPA(), which looks for
the PersistenceUtil class on the classpath. When this is found (in jpa-api-2.0.jar),
the two methods in the TraversableResolver interface are delegated to
JPATraversableResolver,
which triggers an exception because it calls Persistence.getPersistenceUtil(), which is
not
implemented by JPA1 providers (in this case, WebLogic 10).
See also
http://java.sun.com/javaee/6/docs/api/javax/persistence/Persistence.html#....
The workaround is easy: don't have a javax.persistence.PersistenceUtil class file on
your classpath when you do not have a JPA2 provider on there too.
The attached patch adds a note in the README telling users not to add the jpa2-api
jar if they do not intend to use Hibernate Validation 4 with an JPA2 EntityManager
but instead with Hibernate Core or JPA1, or maybe even without an ORM framework.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira