Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Development/JPA 2.0/glassfish"
< EclipseLink | Development | JPA 2.0
m (→Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)) |
m (→Resources) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)= | =Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)= | ||
+ | *You can run JPA 2.0 including everything in the JPA 2.0 XSD for persistence.xml in Glassfish V3 | ||
+ | *You can run JPA 2.0 - <font color="red">but you are limited to the JPA 1.0 XSD for persistence.xml</font> in Glassfish V2.1 | ||
+ | |||
===Test Conditions=== | ===Test Conditions=== | ||
*- verify JPA 2.0 interface call with implementation shipped in EclipseLink 1.2 = entityManager.getMetamodel() | *- verify JPA 2.0 interface call with implementation shipped in EclipseLink 1.2 = entityManager.getMetamodel() | ||
*- verify JPA 2.0 interface call with implementation only in EclipseLink 2.0 = entityManager.getCriteriaBuilder() | *- verify JPA 2.0 interface call with implementation only in EclipseLink 2.0 = entityManager.getCriteriaBuilder() | ||
− | *- verify use of JPA 2.0 XSD and properties like <shared-cache-mode>NONE</shared-cache-mode> in persistence.xml | + | *- verify use of JPA 2.0 XSD and properties like '''<shared-cache-mode>NONE</shared-cache-mode>''' in persistence.xml |
+ | |||
==Glassfish V3== | ==Glassfish V3== | ||
*EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # [http://bugs.eclipse.org/248291 248291] and are the RI for the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial GlassFish V3] JEE6 server. | *EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # [http://bugs.eclipse.org/248291 248291] and are the RI for the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial GlassFish V3] JEE6 server. | ||
Line 10: | Line 14: | ||
*'''''Ideally,we want a way for end users to override the JPA 1.0 library shipped with Glassfish V2 2.1.1 without modifying the server and affecting other applications.''''' | *'''''Ideally,we want a way for end users to override the JPA 1.0 library shipped with Glassfish V2 2.1.1 without modifying the server and affecting other applications.''''' | ||
− | ==Results Matrix== | + | ===V2.1 Results Matrix=== |
− | *The following table summarizes the type of test, server modifications and results | + | *The following table summarizes the type of test, Glassfish V2.1 server modifications and results |
{|{{BMTableStyle}} | {|{{BMTableStyle}} | ||
|-{{BMTHStyle}} | |-{{BMTHStyle}} | ||
Line 21: | Line 25: | ||
! Entities, PU in EJB JAR | ! Entities, PU in EJB JAR | ||
! Entities, PU in WAR | ! Entities, PU in WAR | ||
− | ! EAR | + | ! EAR application xml override |
− | + | ||
! '''Ability to run persistence.xml 1.0 vs 2.0 tags''' | ! '''Ability to run persistence.xml 1.0 vs 2.0 tags''' | ||
! '''Weaving entities''' | ! '''Weaving entities''' | ||
Line 31: | Line 34: | ||
|<font color="green">Application_Managed EAR(WAR only)</font> - working | |<font color="green">Application_Managed EAR(WAR only)</font> - working | ||
||application || Persistence bootstrap || || || PU in WAR | ||application || Persistence bootstrap || || || PU in WAR | ||
− | || | + | || no || none ||<font color="red">1.0 - no 2.0</font> |
||<font color="green">no - off</font> | ||<font color="green">no - off</font> | ||
|| Y || Y | || Y || Y | ||
Line 38: | Line 41: | ||
|''<font color="blue">App-Managed case pending...</font> - unknown | |''<font color="blue">App-Managed case pending...</font> - unknown | ||
||application ||injected @PersistenceUnit EMF on Servlet ||PU in utility JAR || || | ||application ||injected @PersistenceUnit EMF on Servlet ||PU in utility JAR || || | ||
− | || | + | || no || none |
|| <font color="blue">?</font> || ??? | || <font color="blue">?</font> || ??? | ||
|| ??? || ??? | || ??? || ??? | ||
|- bgcolor="#d0efff" | |- bgcolor="#d0efff" | ||
|| 3 | || 3 | ||
− | |<font color="green">Container-Managed EAR(EJB,WAR)</font> - | + | |<font color="green">Container-Managed EAR(EJB,WAR)</font> - in progess |
||container ||injected @PersistenceContext EM on Stateless Session Bean '''(EM is proxied, em.getClass().toString = <font color="green">$Proxy84</font>)''' || || PU in EJB|| | ||container ||injected @PersistenceContext EM on Stateless Session Bean '''(EM is proxied, em.getClass().toString = <font color="green">$Proxy84</font>)''' || || PU in EJB|| | ||
|| || domain.xml (both javax and eclipselink jar refs) | || || domain.xml (both javax and eclipselink jar refs) | ||
− | || <font color="red">1.0</font>|| | + | || <font color="red">1.0 - no 2.0</font>||??? |
|| Y || Y | || Y || Y | ||
|- | |- | ||
Line 52: | Line 55: | ||
|''<font color="blue">Container-Managed EAR(EJB,WAR) as PS2 with override in EAR descriptor</font> - pending | |''<font color="blue">Container-Managed EAR(EJB,WAR) as PS2 with override in EAR descriptor</font> - pending | ||
||container ||injected @PersistenceContext EM on SSB || ||PU in EJB|| | ||container ||injected @PersistenceContext EM on SSB || ||PU in EJB|| | ||
− | || | + | || no || none |
||<font color="blue">???2.0</font>||<font color="blue">???yes</font> | ||<font color="blue">???2.0</font>||<font color="blue">???yes</font> | ||
|| ??? || ??? | || ??? || ??? | ||
Line 69: | Line 72: | ||
==Analysis== | ==Analysis== | ||
*EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # [http://bugs.eclipse.org/248291 248291] and are the RI for the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial GlassFish V3] JEE6 server. In order to use this functionality the 2.0 version of the JPA specification jar - '''javax.persistence.jar''' must be added higher in the Glassfish server classpath see enhancement # [http://bugs.eclipse.org/296269 296269]. | *EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # [http://bugs.eclipse.org/248291 248291] and are the RI for the [http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_Tutorial GlassFish V3] JEE6 server. In order to use this functionality the 2.0 version of the JPA specification jar - '''javax.persistence.jar''' must be added higher in the Glassfish server classpath see enhancement # [http://bugs.eclipse.org/296269 296269]. | ||
+ | ===Running with the JPA 2.0 XSD in persistence.xml=== | ||
+ | *We get the following only on V2.1 | ||
+ | <pre> | ||
+ | deploy: | ||
+ | [exec] CLI171 Command deploy failed : Deploying application in domain failed; Error loading deployment descriptors for module [org.eclipse.persistence.example.jpa.server.glassfishv2.EnterpriseEAR] Line 19 Column 248 -- Deployment descriptor file META-INF/persistence.xml in archive [classes]. 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'. | ||
+ | </pre> | ||
+ | |||
===Use Cases=== | ===Use Cases=== | ||
*Use case partitioning criteria | *Use case partitioning criteria | ||
Line 111: | Line 121: | ||
[[Image:Glassfish_211_with_jpa2_override_via_domain_xml.JPG]] | [[Image:Glassfish_211_with_jpa2_override_via_domain_xml.JPG]] | ||
==Resources== | ==Resources== | ||
− | * | + | *[http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV2_Web_TutorialGlassfish V2 JPA Web Application Tutorial] |
− | * | + | *[http://wiki.eclipse.org/EclipseLink/Examples/JPA/GlassFishV3_Web_TutorialGlassfish V3 JPA Web Application Tutorial] |
+ | *[http://wiki.eclipse.org/EclipseLink/Development/JPA2.0/container_support#General_Solution EE Container Support in EclipseLink] | ||
+ | *[http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic JPA 2.0 on WebLogic 10.3] | ||
+ | *[http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/glassfish JPA 2.0 on Glassfish V2 and V3] |
Latest revision as of 16:18, 10 August 2010
Contents
Running JPA 2.0 API on Glassfish V3 (JEE6 RI) and V2 (JEE5 RI)
- You can run JPA 2.0 including everything in the JPA 2.0 XSD for persistence.xml in Glassfish V3
- You can run JPA 2.0 - but you are limited to the JPA 1.0 XSD for persistence.xml in Glassfish V2.1
Test Conditions
- - verify JPA 2.0 interface call with implementation shipped in EclipseLink 1.2 = entityManager.getMetamodel()
- - verify JPA 2.0 interface call with implementation only in EclipseLink 2.0 = entityManager.getCriteriaBuilder()
- - verify use of JPA 2.0 XSD and properties like <shared-cache-mode>NONE</shared-cache-mode> in persistence.xml
Glassfish V3
- EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # 248291 and are the RI for the GlassFish V3 JEE6 server.
Glassfish V2
- Glassfish V2.1.1 ships with JPA 1.0 support - in order to use JPA 2.0 on this older server some overrides will be required.
- Ideally,we want a way for end users to override the JPA 1.0 library shipped with Glassfish V2 2.1.1 without modifying the server and affecting other applications.
V2.1 Results Matrix
- The following table summarizes the type of test, Glassfish V2.1 server modifications and results
UC# | Test Example-Description | Container-Managed vs Application-Managed | Injected-EMF vs Persistence bootstrap | Entities, PU in utility JAR | Entities, PU in EJB JAR | Entities, PU in WAR | EAR application xml override | Ability to run persistence.xml 1.0 vs 2.0 tags | Weaving entities | Runs JPA2 Impl in EclipseLink 1.2 | Runs JPA2 Impl in EclipseLink 2.0 only | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Application_Managed EAR(WAR only) - working | application | Persistence bootstrap | PU in WAR | no | none | 1.0 - no 2.0 | no - off | Y | Y | ||
2 | App-Managed case pending... - unknown | application | injected @PersistenceUnit EMF on Servlet | PU in utility JAR | no | none | ? | ??? | ??? | ??? | ||
3 | Container-Managed EAR(EJB,WAR) - in progess | container | injected @PersistenceContext EM on Stateless Session Bean (EM is proxied, em.getClass().toString = $Proxy84) | PU in EJB | domain.xml (both javax and eclipselink jar refs) | 1.0 - no 2.0 | ??? | Y | Y | |||
4 | Container-Managed EAR(EJB,WAR) as PS2 with override in EAR descriptor - pending | container | injected @PersistenceContext EM on SSB | PU in EJB | no | none | ???2.0 | ???yes | ??? | ??? |
Problem
- This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application-managed EntityManagers.
- The page is geared to both end users and internal eclipselink.jpa.test server test implementors.
- 1) End users of Glassfish V2 2.1.1
- This involves configuring the server for JPA 1.0 permanently or per-deployment
- Note: This procedure is for application managed deployments - container managed injection will still default to JPA 1.0 for servers that do not ship with 2.0 out of the box
- 2) EclipseLink JPA test users on Glassfish V2 2.1.1
- This involves temporarily configuring the server per-test-deployment
- 1) End users of Glassfish V2 2.1.1
Analysis
- EclipseLink 1.2 and 2.0+ fully implement the JPA 2.0 specification via enhancement # 248291 and are the RI for the GlassFish V3 JEE6 server. In order to use this functionality the 2.0 version of the JPA specification jar - javax.persistence.jar must be added higher in the Glassfish server classpath see enhancement # 296269.
Running with the JPA 2.0 XSD in persistence.xml
- We get the following only on V2.1
deploy: [exec] CLI171 Command deploy failed : Deploying application in domain failed; Error loading deployment descriptors for module [org.eclipse.persistence.example.jpa.server.glassfishv2.EnterpriseEAR] Line 19 Column 248 -- Deployment descriptor file META-INF/persistence.xml in archive [classes]. 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'.
Use Cases
- Use case partitioning criteria
- Application managed EM
- @PersistenceUnit EMF or static bootstrap Persistence.createEntityManagerFactory EMF
- Global scoped datasource
- UC 1 : JTA global scoped datasource
- UC 2 : non-JTA global scoped datasource
- UC 3 : RESOURCE_LOCAL jdbc connector
- Application scoped datasource
- UC 11 : JTA global scoped datasource
- UC 12 : non-JTA global scoped datasource
- UC 13: RESOURCE_LOCAL jdbc connector
- Global scoped datasource
- @PersistenceUnit EMF or static bootstrap Persistence.createEntityManagerFactory EMF
- Container managed EM
- @PersistenceUnit EMF and/or @PersistenceContext EM injection on session bean
- Global scoped datasource
- UC 21 : JTA global scoped datasource
- UC 22 : non-JTA global scoped datasource
- UC 23 : RESOURCE_LOCAL jdbc connector - invalid
- Application scoped datasource
- UC 31 : JTA global scoped datasource
- UC 32 : non-JTA global scoped datasource
- UC 33 : RESOURCE_LOCAL jdbc connector - invalid
- Global scoped datasource
- @PersistenceUnit EMF and/or @PersistenceContext EM injection on session bean
- Application managed EM
Design
Design Issue 1: JSR-317 JPA 2.0 EJB 3.1 Support
DI 1: Problem
- The libs currently shipped with Glassfish 2.1.1 are the following JPA 1.0 compatible versions - these must be overriden in order to run JPA 2.0 API.
- lib/javaee.jar (the javax.persistence package)
- lib/toplink-essentials.jar
- lib/toplink-essentials-agent.jar
- The toplink-essentials jars are no problem as long as we specify the eclipselink persistence provider in all persistence units.
DI 1: Alternative 1: Manual overwrite of eclipselink and javax.persistence libraries in server/lib
- this will not place the JPA 2.0 higher - deprecated
DI 1: Alternative 2: Reference higher in the server classpath via domain.xml
- Add classpath-prefix="${com.sun.aas.installRoot}/lib/eclipselink.jar;${com.sun.aas.installRoot}/lib/javax.persistence_2.0.0.v200911041116.jar"
..doc in progress...
- Workable solution but it has issues
- The server now runs a single version of the two libraries for all applications - this may not be compatible with older applications or other JPA providers running on the server.