Websphere 8.5与JPA 2.1 [英] Websphere 8.5 with JPA 2.1
问题描述
其他人在WAS 8.5中使用过Hibernate 4吗?如果是这样,怎么样?没有功能包,我们就得到了javax.persistence类的NoSuchMethodError。
Hibernate 4.3.7.Final 可以在Websphere Application Server 8.5.5 中使用,具有以下配置: code> hibernate-jpa-2.1.jar ,并将classloader策略设置为PARENT_LAST。 Hibernate 4.3.7.Final与Websphere 8.5.5提供的JPA 2.0 API不兼容。 设置JVM属性 com.ibm.websphere.persistence.ApplicationsExcludedFromJpaProcessing = * 可禁用Websphere JPA初始化。 这将在启动期间获得以下
SAXParseException
,因为Websphere会根据JPA 2.0架构尝试解析persistence.xml。
ul>
导致:org.xml.sax.SAXParseException:expec ted根元素{http://java.sun.com/xml/ns/persistence}persistence
at com.ibm.ws.jpa.management.JaxbUnmarshaller.startElement(JaxbUnmarshaller.java:310)
-
应用解决JPA-4问题。
使用Hibernate的JPA 2 API代替Webspheres JPA 1 API报告问题,而解决方法也适用于Hibernate的JPA 2.1 API,并进行了一些小的更改: / p>
您需要将
HibernatePersistence
替换为HibernatePersistenceProvider
已被弃用。
如果没有这个,您将在启动过程中获得
ClassCastException
,因为Hibernate的JPA 2.1 API将加载所有PersistenceProvider
类,包括在classpath中公开的Websphere类。
导致:java.lang.ClassCastException:com.ibm.websphere.persistence.PersistenceProviderImpl与javax.persistence.spi.PersistenceProvider不兼容$ b $ javax.persistence.Persistence $ 1.isLoaded(Persistence.java:110)
at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56)
IBM used to have a feature pack to put JPA 2.0 into WAS 7. WAS 8.5.5 evidently comes with JPA 2.0. But we have an app we just upgraded to Hibernate 4, which needs JPA 2.1. I can't find a link for a WAS 8.5 feature pack to push to JPA 2.1.
Has anyone else used Hibernate 4 in WAS 8.5? If so, how? Without a feature pack, we get NoSuchMethodError on javax.persistence classes.
Hibernate 4.3.7.Final can be used in Websphere Application Server 8.5.5 with following configuration:
Pack
hibernate-jpa-2.1.jar
in your application and set classloader policy to PARENT_LAST.Hibernate 4.3.7.Final is not compatible with the JPA 2.0 API provided by Websphere 8.5.5
Set JVM property com.ibm.websphere.persistence.ApplicationsExcludedFromJpaProcessing=* to disable Websphere JPA initialization.
Without this you will get following
SAXParseException
during startup as Websphere attempts to parse the persistence.xml according to JPA 2.0 schema.
Caused by: org.xml.sax.SAXParseException: expected root element {http://java.sun.com/xml/ns/persistence}persistence at com.ibm.ws.jpa.management.JaxbUnmarshaller.startElement(JaxbUnmarshaller.java:310)
Apply the work around for issue JPA-4 in your application.
The issue was reported for using Hibernate's JPA 2 API instead of Webspheres JPA 1 API, while the work around is also applicable to Hibernate's JPA 2.1 API with some minor changes:
You need to replace
HibernatePersistence
withHibernatePersistenceProvider
as the former has been deprecated.Without this you will get following
ClassCastException
during startup as Hibernate's JPA 2.1 API will load allPersistenceProvider
classes, including the Websphere one exposed in classpath.
Caused by: java.lang.ClassCastException: com.ibm.websphere.persistence.PersistenceProviderImpl incompatible with javax.persistence.spi.PersistenceProvider at javax.persistence.Persistence$1.isLoaded(Persistence.java:110) at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56)
这篇关于Websphere 8.5与JPA 2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!