簡體   English   中英

使用RSA 8.5在Websphere 7.0上發布JPA 2.0問題

[英]JPA 2.0 issue on Websphere 7.0 using RSA 8.5

我在使用WAS 7.0上的JPA 2.0運行應用程序時遇到問題。 我正在使用RSA 8.5進行開發。 我使用Hibernate作為提供者。
這是我到目前為止所做的:

  1. 我用JPA 2.0 facet配置了我的項目。

  2. 將所有hibernate“必需”jar和jpa jar添加到構建路徑以及manifest條目中。

  3. 我遵循了這篇文章: WebSphere Application Server中的備用JPA提供程序 ,我通過管理控制台更改了默認持久性提供程序,我在服務器啟動時看到日志中的這些行:

     [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. 
  4. 這是我的應用程序的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"/> 

  5. 在服務器中,我使用以下jar創建了一個共享庫,並創建了一個引用此共享庫的“應用程序優先”類加載器:

ANTLR-2.7.7.jar

休眠公地的注解,4.0.2.Final.jar

休眠核心,4.2.7.SP1.jar

冬眠-JPA-2.0-API-1.0.1.Final.jar

Javassist進行-3.18.1-GA.jar

JBoss的日志記錄,3.1.0.GA.jar

JBoss的事務,api_1.1_spec-1.0.1.Final.jar

休眠-的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:我還沒有做的一件事是我沒有在我的WAS(版本7.0.0)中應用任何JPA功能包。 這可能是問題嗎?

看起來WAS的JPA 1.0庫(由父類加載器加載)試圖讀取webapp的persistence.xml並且被版本搞糊塗了。

根據這篇文章 (法語),您必須安裝OSGI和JPA 2.0 Feature Pack,或者將您的persistence.xml移動到除META-INF之外的其他地方,以便JPA 1.0庫找不到它。 然后,您需要使用另一種方式加載persistence.xml ,無論是以編程方式還是通過Spring。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM