JPA 2.0 in WebLogic Server 10.3.6

2019-04-12 09:19发布

问题:

I need to use JPA 2.0 (with the EclipseLink implementation). The problem is that I also need to deploy this app in a WebLogic 10.3.6 server, which implements the Java EE 5 specification, and so, it is not required to support JPA 2.

I know that there are patches that can be used to add support for JPA 2.0 in this version, but the sysadmin doesn't want to change anything in the server at all

I tried adding the javax.persistence-2.1.0.jar file to my war thinking that my app would just use this file instead of the one provided by WebLogic. Does this make any sense? Is there a way to achieve this without having to mess with the server?

回答1:

It isn't supported in earlier versions, but in 10.3.6 you should be able to use your own libraries for JPA2. If you use with the classnames you should be able to override the weblogic class chain loading, and where weblogic normally loads JPA it will use your library supporting JPA-2.0 instead.

Off the top of my head the classnames you need to override are org.eclipse.persistence.* and javax.persistence.*

(Note that this won't work on anything below 10.3.5 should anyone else try this).