【发布时间】:2013-12-24 02:42:20
【问题描述】:
我在让我的应用程序在 WAS 7.0 上使用 JPA 2.0 运行时遇到问题。我正在使用 RSA 8.5 进行开发。我使用 Hibernate 作为提供程序。
这是我到目前为止所做的:
我使用 JPA 2.0 facet 配置了我的项目。
将所有休眠“必需”jar 和 jpa jar 添加到构建中 路径以及清单条目中。
-
我关注了这篇文章:Alternate JPA Providers in WebSphere Application Server 我通过管理控制台更改了默认的持久性提供程序,并且在服务器启动时在日志中看到了这些行:
[12/6/13 9:36:20:529 EST] 00000000 JPAComponentI I CWWJP0026I: The Java Persistence API (JPA) component is initializing. [12/6/13 9:36:20:537 EST] 00000000 JPAComponentI I CWWJP0006I: The org.hibernate.ejb.HibernatePersistence class is loaded as the default Java Persistence API (JPA) provider. -
这是我的应用程序的 persistence.xml:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="biReconWeb"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup"/> 在服务器中,我使用以下 jar 创建了一个共享库,并创建了一个引用此共享库的“应用程序优先”类加载器:
antlr-2.7.7.jar
hibernate-commons-annotations-4.0.2.Final.jar
hibernate-core-4.2.7.SP1.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.1.Final.jar
hibernate-entitymanager-4.2.7.SP1.jar
当我部署应用程序时,我收到此错误:
> Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.1: Value
> '2.0' of attribute 'version' of element 'persistence' is not valid
> with respect to the corresponding attribute use.Attribute 'version'
> has a fixed value of '1.0'.
如果我将持久化版本更改为 1.0,则应用程序可以正常启动。但是我想用JPA 2.0,你能告诉我我做错了什么吗?
PS:我没有做的一件事是我没有将任何 JPA 功能包应用到我的 WAS(版本 7.0.0)。这可能是问题吗?
【问题讨论】: