Upgrading GlassFish 3.1.2.2 to use JPA 2.1

2020-02-01 17:43发布

I am working with GlassFish 3.1.2.2 (I can not upgrade to 4 due to OS restrictions).

I'm interested in upgrading JPA 2.0 to JPA 2.1 GlassFish 3.1.2.2. How can I achieve this?

3条回答
贪生不怕死
2楼-- · 2020-02-01 17:58

I'm using Hibernate 4.3.8 (requires JPA 2.1) with Glassfish 3.1.2.2.

Note: I'm not using any services provided by glassfish. All the libraries I use are in the WEB-INF/lib.

1 - Override all JPA classes (package javax.persistence) in glassfish/modules/javax.persistence.jar with JPA 2.1 version. You should not replace the entire JAR, only override the classes. This JAR has an OSGI manifest and other classes that must remain there.

2 - Remove all javassist classes (package javasssist) from glassfish/modules/weld-osgi-bundle.jar. This solves a possible incompatibility if you are using Hibernate.

查看更多
家丑人穷心不美
3楼-- · 2020-02-01 18:15

This is most likely not possible at all. JPA 2.1 is part of EE 7 and therefore not fully integrated with EE 6 GF 3.1.2.2.

查看更多
Rolldiameter
4楼-- · 2020-02-01 18:24

Did you try just replacing the EclipseLink and JPA jar files in Glassfish?

It will probably work, but if you use managed persistence units they will not expose any JPA 2.1 API, you would need to unwrap the EntiyManager to access these.

查看更多
登录 后发表回答