带有JPA 2.1的Websphere 8.5

Ent*_*opy 8 websphere hibernate jpa

IBM曾经有一个功能包将JPA 2.0放入WAS 7.WAS 8.5.5显然带有JPA 2.0.但我们有一个应用程序,我们刚刚升级到Hibernate 4,需要JPA 2.1.我找不到WAS 8.5功能包的链接以推送到JPA 2.1.

还有其他人在WAS 8.5中使用过Hibernate 4吗?如果是这样,怎么样?如果没有功能包,我们会在javax.persistence类上获得NoSuchMethodError.

Par*_*ang 11

Hibernate 4.3.7.Final可以在Websphere Application Server 8.5.5中使用,具有以下配置:

  • 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.

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)
  • 应用围绕工作问题JPA-4在应用程序中.

    据报道使用Hibernate的JPA 2 API而不是Webspheres JPA 1 API的问题,而解决方案也适用于Hibernate的JPA 2.1 API,并进行了一些小的改动:

    您需要替换HibernatePersistence,HibernatePersistenceProvider因为前者已被弃用.

    如果没有这个,你将ClassCastException在启动时得到关注,因为Hibernate的JPA 2.1 API将加载所有PersistenceProvider类,包括在类路径中暴露的Websphere.

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)


dun*_*nni 5

Hibernate 4.2.x 实现了 JPA 2.0 规范,我们在 WebSphere 8.5.5 中使用它没有任何问题。我们将Hibernate JAR 打包到WAR 中,并将persistence.xml 中的provider 属性设置为org.hibernate.ejb.HibernatePersistence。

只有 Hibernate 4.3.x 需要 JPA 2.1,并且无法与 WebSphere 8.5.5 一起使用。


gro*_*roo -1

在 WebSphere 中使用您自己的持久性提供程序应该没有问题。我的建议是您在应用程序中打包 JPA 2.1 提供程序,并尝试将类加载器更改为最后一个父级加载器。在这种情况下,您不会使用 WebSphere 提供的默认 OpenJPA 2.0。相反,您将使用您选择的提供商。

http://www-01.ibm.com/support/knowledgecenter/api/content/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/tejb_jpa3rdparty.html

http://www-01.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/trun_classload_server.html?cp=SSAW57_8.5.5%2F3-8-2- 5-1&lang=zh

希望这可以帮助。

来自 IBM 支持门户的另一篇相关文章:http://www-01.ibm.com/support/docview.wss ?uid=swg21672354

  • 从您的链接中:“使用 JPA 函数的 Java EE 应用程序可以使用应用程序服务器中包含的提供程序之外的第三方持久性提供程序。应用程序还可以指定与应用程序服务器中包含的版本不同的 Apache OpenJPA 提供程序。应用服务器,只要支持相同版本的JPA规范即可。” 该操作要求 2.1 而不是 2.0 交换。Hibernate 2.0 就可以工作。Hibernate 2.1 不会。 (2认同)