JPA2.0遇到的问题:NoSuchMethodError... getValidationMode()Ljavax/persistence/ValidationMode;

发布于 2014-05-13 | 更新于 2020-09-20

整合JPA2.0的时候遇到这样的错误:

Invocation of init method failed; nested exce
ption is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.
getValidationMode()Ljavax/persistence/ValidationMode;

原因是getValidationMode()是JavaEE6中才有的,查看下官方文档:

http://docs.oracle.com/javaee/6/api/javax/persistence/spi/PersistenceUnitInfo.html#getValidationMode()

getValidationMode

ValidationMode getValidationMode()

Returns the validation mode to be used by the persistence provider for the persistence unit. The validation mode corresponds to the validation-mode element in the persistence.xml file.

Returns:

the validation mode to be used by the persistence provider for the persistence unit

Since:

Java Persistence 2.0

Tomcat是一个Servlet容器,实现了Servlet规范,并没有实现EJB、JMS、JPA规范,并不是一个完整的Java EE实现。

对于Tomcat,只需要在项目中添加jpa2.0的实现就可以了。

resin可以支持sun的j2ee,实现了如下的规范:

20140513-Java01

为了使用JPA2.0,需要使用实现了JPA2.0规范的resin版本:

http://blog.caucho.com/2010/10/27/are-we-there-yet-resin-4-java-ee-6-web-profile-certification/

本文作者: arthinking

本文链接: https://www.itzhai.comjpa-problem-nosuchmethoderror-getvalidationmode.html

版权声明: 版权归作者所有,未经许可不得转载,侵权必究!联系作者请加公众号。

×
IT宅

关注公众号及时获取网站内容更新。

请帅旋喝一杯咖啡

咖啡=电量,给帅旋充杯咖啡,他会满电写代码!

IT宅

关注公众号及时获取网站内容更新。