Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/JPA 2.0/weblogic"

m (Results Matrix)
m (TODO)
 
(101 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
=Running JPA 2.0 API on WebLogic 10.3=
 
=Running JPA 2.0 API on WebLogic 10.3=
WebLogic 10.3.2.0 ships with the JPA 1.0 specification jar - we would like to run JPA 2.0 API on WebLogic.  This document describes the solution to container-managed and application managed deployments and the details in getting their use cases running.
+
 
 +
<div style="border: 3px red solid;" align="center" ><font color="red">DISCLAIMER: This page reflects investigation into how EclipseLink users can evaluate EclipseLink JPA 2.0 within existing WebLogic releases. It does NOT imply any formal certification from Oracle that JPA 2.0 is supported on WebLogic at this time.</font></div>
 +
 
 +
*<font color="green">20110214: See the new [http://wiki.eclipse.org/EclipseLink/Examples/Distributed Distributed EE Case Study Application] that details how to enable and use '''JPA 2.0''' and '''JSF 2.0''' on Oracle '''WebLogic 10.3.4.0''' using '''Eclipse Helios 3.6''' as the IDE.</font>
 +
 
 +
__TOC__
 +
 
 +
==20110515: JPA 2.0 using EclipseLink on WebLogic 10.3.5.0==
 +
*Details in this section are in addition to the section on WebLogic 10.3.4.0
 +
==20110115: JPA 2.0 using EclipseLink on WebLogic 10.3.4.0==
 +
*<Font color="red">This section on WebLogic 10.3.4 was added to the original document that discussed experimental methods of getting a JPA 2.0 based application running on WebLogic 10.3.3.0 - that section is now deprecated with the release of WebLogic 10.3.4.0 on 14 Jan 2011.</font>
 +
*[http://blogs.oracle.com/WebLogicServer/2011/01/weblogic_server_1034_released.html Official Oracle Blog entry / press release for 10.3.4 on 20 Jan 2011]
 +
*<font color="green">'''20100115-Note: the three outstanding issues ''(XSD, Weaving and JPA 2.0 Dependency Injection)'' look to be fixed by applying [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch QWG8] or manually [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support prepending] to the server classpath.'''</font>
 +
 
 +
*WebLogic 10.3.4.0 is [http://forums.oracle.com/forums/thread.jspa?messageID=9288278&#9288278 released on OTN] - the contents of this page will likely be deprecated as specific to 10.3.3.0 and 10.3.2.0 - ''pending a full review''.
 +
*There is a large list of public OTN and [http://www.eclipselink.org EclipseLink] wiki pages, bug/enhancement analysis comments and newsgroup entries that we are now able to discuss.  A full review of all 10.3.3.0 workarounds, updates to all WebLogic JPA 2.0 tutorial configurations and responses to all open WebLogic related JPA classloader and XSD validation issues is in order.  I have prepared a list of these over the last year.
 +
*The main issues were JPA 2.0 XSD validation and JPA 2.0 container managed persistence unit injection.
 +
**In 10.3.3.0 you were required to use the '''FilteringClassLoader''' via the '''<font color="orange"><wls:prefer-application-packages></font>''' addition to your application managed persistence unit - this workaround is now deprecated and ''not required in 10.3.4.0'' for both application and container managed persistence contexts.
 +
*Specifically we will start retesting EE applications using a SSB injected @PersistenceContext container managed JTA transactional JPA 2.0 persistence units with/without JPA 2.0 XSD elements.
 +
*I verified the server and it is using SVN rev# 8635 from 6 Dec 2010  https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8635
 +
*Essentially in order to enable JPA 2.0 functionality on WebLogic 10.3.4 shipped on 14 Jan 2011 - you apply the patch below or manually edit your server classpath to put the JPA 2.0 persistence specification API jar and the '''<font color="purple">com.oracle.jpa2support_1.0.0.0_2-0.jar</font>''' ahead of the other liibraries on the classpath.
 +
<pre>
 +
commEnv.cmd: line 67
 +
 
 +
@rem Set BEA Home
 +
set BEA_HOME=C:\opt\wls1034r20110115
 +
@rem Enable JPA 2.0 functionality on WebLogic Server 10.3.4 with the following patch line for commEnv.cmd:67
 +
set PRE_CLASSPATH=%BEA_HOME%\modules\javax.persistence_1.0.0.0_2-0-0.jar;%BEA_HOME%\modules\com.oracle.jpa2support_1.0.0.0_2-0.jar
 +
</pre>
 +
*Everything is shipped with WebLogic 10.3.4 but JPA 1.0 is enabled by default so that this JEE5 capable server is backwards compatible with JEE5/JPA1 out of the box.  Without the above patch you will see the following.
 +
<pre>
 +
<15-Jan-2011 5:58:40 o'clock PM EST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3.4.0  Fri Dec 17 20:47:33 PST 2010 1384255 >
 +
[EL Info]: 2011-01-15 18:06:38.082--ServerSession(48997950)--Thread(Thread[[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--EclipseLink, version: Eclipse Persistence Services - 2.1.2.v20101206-r8635
 +
[EL Info]: 2011-01-15 18:06:38.082--ServerSession(48997950)--Thread(Thread[[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Server: 10.3.4.0
 +
</pre>
 +
*<font color="green">'''20100115-Note: this issue is fixed by applying [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch QWG8] or manually [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support prepending] to the server classpath.'''</font>
 +
 
 +
*We have the required bundles in the modules directory but the JPA 2.0 specification jar is not above the JPA 1.0 jar by default - the patch will change this...
 +
**'''javax.persistence_1.0.0.0_2-0-0.jar''' (upgraded from 1-0-2)
 +
**'''org.eclipse.persistence_1.0.0.0_2-1.jar''' (upgraded from 2-0)
 +
*A very quick test of a JPA 2.0 container managed app with the following persistence.xml in the ejb.jar works as detailed below - before the patch is applied.
 +
*<font color="green">Note: All testing at this time is on a WebLogic 10.3.4.0 install out-of-the-box (without the [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 QWG8] patch - to verify default JPA 1.0 functionality).  The only modification I made yet was in creating a derby 10.5.3.0 JTA global datasource "localJTA" on the server - and drop a container managed JPA 2.0 app as an EAR in the autodeploy directory on the default user domain.</font>
 +
*There are 3 issues we must check.
 +
**1) JPA 2.0 XSD parsing errors: as expected there are no more JPA 2.0 schema parsing issues.
 +
**2) New JPA 2.0 schema elements like the *<shared-cache-mode>NONE</shared-cache-mode>*  element - this passes validation but we need to verify runtime functionality
 +
**3) JPA 2.0 runtime API like a *entityManager.getMetamodel();* call on the Servlet or Stateless session bean
 +
**4) JPA 2.0 weaving/instrumentation - Again we need to verify something like weaving of Entities contaiing lazy IndirectLists are weaved properly by the container.
 +
 
 +
<source lang="xml">
 +
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
 +
    <persistence-unit name="example" transaction-type="JTA">
 +
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 +
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <!-- we will default to Kodo without specifying the provider only in JPA 1.0 -->
 +
        <jta-data-source>localJTA</jta-data-source>
 +
        <shared-cache-mode>NONE</shared-cache-mode><!-- shared-cache-mode must come after any class definitions (usually SE only) - the JPA schema is ordered -->
 +
        <properties>
 +
            <property name="eclipselink.target-server" value="WebLogic_10"/>
 +
            <property name="eclipselink.target-database" value="Derby"/>           
 +
            <property name="eclipselink.logging.level" value="FINEST"/>
 +
            <!-- new for 10.3.4.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging  -->
 +
            <property name="eclipselink.logging.logger" value="DefaultLogger"/>
 +
            <!-- turn off DDL generation after the model is stable -->           
 +
            <!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
 +
            <!-- property name="eclipselink.ddl-generation.output-mode" value="database"/-->
 +
        </properties>     
 +
    </persistence-unit>
 +
</source>
 +
===JPA 2.0 Container Managed EntityManager Injection===
 +
*<font color="green">'''20100115-Note: the three outstanding issues ''(XSD, Weaving and JPA 2.0 Dependency Injection)'' look to be fixed by applying [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch QWG8] or manually [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support prepending] to the server classpath.'''</font>
 +
*For 3) we get the following exception out of the box on a servlet if we do not apply the above mentioned patch below - because the container defaults to Java EE 5 functionality - or JPA 1.0
 +
**'''http://download.oracle.com/docs/cd/E18476_01/doc.220/e18480/weblogicchap.htm'''
 +
 
 +
<source lang="java">
 +
java.lang.NoSuchMethodError: javax/persistence/EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel;
 +
        at org.eclipse.persistence.example.jpa.server.weblogic.enterprise.presentation.FrontController.processGliderComm
 +
        and(FrontController.java:346)
 +
</source>
 +
 
 +
*or 3) The same exception if we try to run JPA 2.0 on the DI entityManager from the SSB in the EJB container classLoader
 +
<source lang="java">
 +
javax.ejb.EJBException: EJB Exception: : java.lang.NoSuchMethodError: javax/persistence/EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel;
 +
at org.eclipse.persistence.example.jpa.server.business.ApplicationService.insertObjects(ApplicationService.java:66)
 +
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 +
at java.lang.reflect.Method.invoke(Method.java:597)
 +
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
 +
..
 +
at $Proxy74.insertObjects(Unknown Source)
 +
at org.eclipse.persistence.example.jpa.server.business.ApplicationService_5ptwty_ApplicationServiceLocalImpl.__WL_invoke(Unknown Source)
 +
</source>
 +
 
 +
===JPA 2.0 Container Bytecode Weaving/Instrumentation===
 +
*<font color="green">'''20100115-Note: the three outstanding issues ''(XSD, Weaving and JPA 2.0 Dependency Injection)'' look to be fixed by applying [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch QWG8] or manually [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support prepending] to the server classpath.'''</font>
 +
*We also get the Kodo/OpenJPA provider when we attempt to weave.
 +
<source lang="java">
 +
<openjpa-1.1.1-SNAPSHOT-r422266:965591 fatal user error> org.apache.openjpa.util.MetaDataException: "org.eclipse.persistence.example.jpa.server.business.Cell.id" declares generator name "EL_SEQUENCE_CELL", but uses the AUTO generation type.  The only valid generator names under AUTO are "uuid-hex" and "uuid-string".
 +
at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.getGeneratedValueStrategy(AnnotationPersistenceMetaDataParser.java:1226)
 +
</source>
 +
 
 +
*Note: Once the JPA2 patch is applied you no longer need to set the default JPA provider unless you don't specify the provider in your persistence.xml
 +
 
 +
[[Image:Weblogic10340_r20110115_change_default_jpa2_provider_from_kodo_to_toplink.JPG]]
 +
 
 +
*Therefore there is still a little bit of configuration required.
 +
 
 +
===Enabling JPA2 support===
 +
*Note: See the following [http://wiki.eclipse.org/EclipseLink/Examples/Distributed tutorial page] on running EclipseLink as the JSR-317 JPA 2.0 provider for a distributed Java EE enterprise application on WebLogic 10.3.4 or GlassFish 3.1.
 +
*1) Install Oracle WebLogic 10.3.4 or upgrade from 10.3.3
 +
*2a) Install the QWG8 patch using the support download, or
 +
*2b) manually add the <font color="red">'''com.oracle.jpa2support_1.0.0.0_2-0.jar'''</font> ahead of the server classpath by following the instructions in the documentation at
 +
**http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
 +
**or do it manually by modifying the following line directly on your server
 +
<pre>
 +
C:\opt\wls10340_pub110115\wlserver_10.3\common\bin\commEnv.cmd
 +
  set PRE_CLASSPATH=%BEA_HOME%\modules\javax.persistence_1.0.0.0_2-0-0.jar;%BEA_HOME%\modules\com.oracle.jpa2support_1.0.0.0_2-0.jar
 +
</pre>
 +
====Results====
 +
The following code...
 +
<source lang="java">
 +
@Local
 +
@Stateless
 +
public class ApplicationService implements ApplicationServiceLocal {
 +
    @PersistenceContext(unitName="example", type=PersistenceContextType.TRANSACTION)
 +
    private EntityManager entityManager;
 +
 
 +
    public boolean insertObjects(List<Cell> classes) {
 +
        try {
 +
            for(int i=0; i< classes.size(); i++) {
 +
                entityManager.persist(classes.get(i));
 +
            }
 +
            System.out.println("JPA 2.0 Metamodel: " + entityManager.getMetamodel());         
 +
</source>
 +
...prints out the JPA 2.0 EntityManager dependency injected into the SSB proxy for the life of the transaction in the function
 +
<source lang="java">
 +
JPA 2.0 Metamodel: MetamodelImpl@34817119 [ 5 Types: , 2 ManagedTypes: , 2 EntityTypes: , 0 MappedSuperclassTypes: , 0 EmbeddableTypes: ]
 +
[EL Finer]: 2011-01-15 22:36:00.33--UnitOfWork(34913451)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self tuning)',5,Pooled Threads])--TX beforeCompletion callback, status=STATUS_ACTIVE
 +
</source>
 +
 
 +
*You can see that when we debug the stateless session bean $Proxy that has our injected EntityManager... 
 +
<source lang="java">
 +
this ApplicationService_5ptwty_Impl  (id=11616)
 +
__WL_EJBContext SessionEJBContextImpl  (id=11654)
 +
entityManager $Proxy73  (id=11639)
 +
h TransactionalEntityManagerProxyImpl  (id=11638)
 +
appName "org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR" (id=11513)
 +
closeMethod Method  (id=11663)
 +
moduleName "org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar" (id=11515)
 +
persistenceUnit PersistenceUnitInfoImpl  (id=11665)
 +
persistenceUnitName "org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR#org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar#example" (id=11666)
 +
queryMethods HashSet<E>  (id=11668)
 +
transactionAccessMethod Method  (id=11669)
 +
transactionalMethods HashSet<E>  (id=11670)
 +
txHelper TransactionHelperImpl  (id=11523)
 +
txRegistry ServerTransactionManagerImpl  (id=11524)
 +
unqualifiedPersistenceUnitName "example" (id=11672)
 +
</source>
 +
 
 +
*...no longer complains about an unknown '''getMetamodel()''' ''JPA 2.0'' method signature.
 +
<source lang="java">
 +
Oracle WebLogic Server 11gR1 PatchSet 3 r20110115 at localhost [Oracle WebLogic Server]
 +
Java HotSpot(TM) Client VM[localhost:8453]
 +
Daemon Thread [[ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)'] (Running) Daemon Thread [[ACTIVE] ExecuteThread: '18' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended) TransactionalEntityManagerProxyImpl.invoke(Object, Method, Object[]) line: 18
 +
$Proxy59.getMetamodel() line: not available [local variables unavailable]
 +
ApplicationService_5ptwty_Impl(ApplicationService).insertObjects(List<Cell>) line: 60
 +
.. JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 204
 +
$Proxy71.insertObjects(List) line: not available
 +
ApplicationService_5ptwty_ApplicationServiceLocalImpl.__WL_invoke(Object, Object[], int) line: not available
 +
SessionLocalMethodInvoker.invoke(BaseLocalObject, MethodDescriptor, Object[], int, String, Class<?>) line: 39
 +
ApplicationService_5ptwty_ApplicationServiceLocalImpl.insertObjects(List) line: not available
 +
FrontController.generateGlider(PrintWriter) line: 252
 +
.. FrontController(HttpServlet).service(ServletRequest, ServletResponse) line: 820
 +
StubSecurityHelper$ServletServiceAction.run() line: 227
 +
.. ExecuteThread.run() line: 176
 +
 
 +
arg1 Method  (id=11511)
 +
clazz Class<T> (javax.persistence.EntityManager) (id=8312)
 +
name "getMetamodel" (id=11543)
 +
returnType Class<T> (javax.persistence.metamodel.Metamodel) (id=11545)
 +
</source>
 +
 
 +
*For 4) Weaving is occuring as expected on either the JPA 1.0 or JPA 2.0 entities.  We check this by either checking that our '''Entity''' is an instanceof '''org.eclipse.persistence.internal.weaving.PersistenceWeaved''' interface, or debug into the Entity and look for our bytcode instrumented weaved fields that start with '''_persistence'''.  The question is - we need a weaved field or weaved function that was introduced for JPA 2.0.
 +
<source lang="java">
 +
[4] Cell  (id=11571)
 +
_persistence_fetchGroup null
 +
_persistence_primaryKey null
 +
_persistence_session null
 +
_persistence_shouldRefreshFetchGroup false
 +
aCellAttribute null
 +
id null
 +
left null
 +
peers HashSet<E>  (id=11572)
 +
map HashMap<K,V>  (id=11575)
 +
</source>
 +
 
 +
=====com.oracle.jpa2support_1.0.0.0_2-0.jar forensics=====
 +
I had a look at the patch jar '''com.oracle.jpa2support_1.0.0.0_2-0.jar''' that '''WebLogic 10.3.4''' ships with that allows installers to enable ''JPA 2.0 (JSR-317)'' support to superceed the ''default'' JPA 1.0 (JSR-220) support.  It looks like the container proxy code for container managed EntityManagerFactory and EntityManager $Proxy objects has been updated so that a '''JPA 2.0 EntityManager $Proxy object''' get injected with the proper API level object via the InvocationHandlerFactory, FactoryInterceptor.  The Query proxy has been updated as well.  There is a fix for Kodo(OpenJPA) and OpenJPA related to the recent change and deprecation of certain functions of those providers.  The EclipseLink JPA 2.0 provider (as the provider for TopLink) did not need weblogic changes beyond placing the '''JPA javax.peristence 2.0''' specification jar higher on the classpath.
 +
*3) or let Eclipse 3.6 Helios change the order of the javax.persistence library and add the JPA 2.0 patch for container managed dependency injection to work.
 +
[[Image:Enable_jpa2_in_weblogic1034_from_eclipse36.JPG]]
 +
 
 +
 
 +
*The root EclipseLink tracking bug is [http://bugs.eclipse.org/334468 334468]
 +
 
 +
=Older 10.3.3.0 content=
 +
*<font color="green">'''20100115-Note: the three outstanding issues ''(XSD, Weaving and JPA 2.0 Dependency Injection)'' look to be fixed by applying [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch QWG8] or manually [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JEE6.2FJPA2_support prepending] to the WebLogic 10.3.4.0 server classpath.'''</font>
 +
 
 +
*WebLogic 10.3.2.0 and 10.3.3.0 ship with the JPA 1.0 specification jar - we would like to run JPA 2.0 API on WebLogic.  This document describes a potential solution to container-managed and application managed deployments and the details in getting their use cases running.
  
 
==Results Matrix==
 
==Results Matrix==
*The following table summarizes the type of test, server modifications and results
+
*The following table summarizes the type of test, server modifications and results for verious container managed and application managed EntityManager deployments on WebLogic server.
 
{|{{BMTableStyle}}
 
{|{{BMTableStyle}}
 
|-{{BMTHStyle}}
 
|-{{BMTHStyle}}
Line 16: Line 220:
 
! EAR wls:prefer- application-packages mod?
 
! EAR wls:prefer- application-packages mod?
 
! Server modifications?
 
! Server modifications?
! '''Ability to run persistence.xml 1.0 vs 2.0 tags'''
+
! '''persistence.xml 2.0 XSD Schema'''
 
! '''Weaving entities'''  
 
! '''Weaving entities'''  
! '''Runs JPA2 Impl in EclipseLink 1.2'''
+
! '''Runs JPA2 Impl (shipped with EclipseLink 1.2 only)'''
! '''Runs JPA2 Impl in EclipseLink 2.0 only'''
+
! '''Runs JPA2 Impl (shipped with EclipseLink 2.0 only) - IE: CriteriaBuilder'''
 
|- bgcolor="#d0efff"
 
|- bgcolor="#d0efff"
 
|| 1
 
|| 1
|<font color="green">Application_Managed EAR(WAR only)</font> - working  
+
|<font color="green">Application_Managed PU EAR(WAR only)</font> - working  
 
||application || Persistence bootstrap  
 
||application || Persistence bootstrap  
 
|| JTA
 
|| JTA
 
|| || || PU in WAR
 
|| || || PU in WAR
|| Yes || none ||<font color="red">1.0</font>
+
|| Yes || none ||'''<font color="yellow">2.0</font>''' ? 20101202 under investigation in [http://bugs.eclipse.org/331569 331569]
 
||<font color="green">no - off</font>
 
||<font color="green">no - off</font>
 
|| Y || Y
 
|| Y || Y
Line 39: Line 243:
 
|| ??? || ???
 
|| ??? || ???
 
|- bgcolor="#efefcc"
 
|- bgcolor="#efefcc"
|| 3
+
|| 3a
|<font color="green">Container-Managed EAR(EJB,WAR)</font> - working but with server modifications
+
|<font color="green">Container-Managed PU in EAR(EJB,WAR)</font> - working but with server '''script''' modifications
 
||container ||injected @PersistenceContext EM on Stateless Session Bean '''(EM is proxied, em.getClass().toString = <font color="green">$Proxy84</font>)'''  
 
||container ||injected @PersistenceContext EM on Stateless Session Bean '''(EM is proxied, em.getClass().toString = <font color="green">$Proxy84</font>)'''  
 
|| JTA
 
|| JTA
 
|| || PU in EJB||
 
|| || PU in EJB||
 
|| || commEnv.cmd (both javax and eclipselink jar refs)
 
|| || commEnv.cmd (both javax and eclipselink jar refs)
|| <font color="red">1.0</font>||<font color="green">'''Weaved'''</font>
+
|| <font color="red">1.0</font> reverified 20100120 as validation exception||<font color="green">'''Weaved as 1.0'''</font>
 +
|| Y || Y
 +
|- bgcolor="#efefcc"
 +
|| 3b
 +
|<font color="green">Container-Managed PU in EAR(EJB,WAR)</font> - working but with server '''modules jar''' modifications
 +
||container ||injected @PersistenceContext EM on Stateless Session Bean '''(EM is proxied, em.getClass().toString = <font color="green">$Proxy84</font>)'''
 +
|| JTA
 +
|| || PU in EJB||
 +
|| || (overwrite both javax and eclipselink jars with 2.0 versions)
 +
|| <font color="red">1.0</font> ?reverifying 20100120||<font color="green">'''Weaved'''</font>
 
|| Y || Y
 
|| Y || Y
 
|-
 
|-
|| 4
+
|| 4a
|''<font color="blue">Container-Managed EAR(EJB,WAR) with override in EAR descriptor (no server modifications)</font> - pending  
+
|''<font color="blue">Container-Managed PU in EAR(EJB,WAR) with override in EAR descriptor (no server modifications)</font> - pending
 
||container ||injected @PersistenceContext EM on SSB  
 
||container ||injected @PersistenceContext EM on SSB  
 
|| JTA
 
|| JTA
 
|| ||PU in EJB||
 
|| ||PU in EJB||
 +
||'''Yes (javax.persistence.* only)'''|| none
 +
||<font color="blue">???2.0</font>||<font color="blue">???yes</font>
 +
|| ??? || ???
 +
|-
 +
|| 4b
 +
|''<font color="blue">Container-Managed PU in EAR(EJB,WAR) with override in EAR descriptor (no server modifications)</font> - pending
 +
||container ||injected @PersistenceContext EM on Servlet
 +
|| JTA
 +
|| ||PU in WAR||
 
||'''Yes (javax.persistence.* only)'''|| none
 
||'''Yes (javax.persistence.* only)'''|| 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 291:
 
***[EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaved persistence (PersistenceEntity) [org.eclipse.persistence.example.jpa.server.business.Cell].
 
***[EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaved persistence (PersistenceEntity) [org.eclipse.persistence.example.jpa.server.business.Cell].
 
***[EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaved fetch groups (FetchGroupTracker) [org.eclipse.persistence.example.jpa.server.business.Cell].
 
***[EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaved fetch groups (FetchGroupTracker) [org.eclipse.persistence.example.jpa.server.business.Cell].
**<font color="red">persistence.xml 2.0 changes will not pass deployment validation</font>
+
**<font color="red">persistence.xml 2.0 changes will not pass deployment validation only for container managed JPA applications</font>
  
==Problem==
+
==Problem 1: JPA 2.0 API Enablement==
 
*This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application managed EntityManagers.
 
*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.
 
*The page is geared to both end users and internal ''eclipselink.jpa.test'' server test implementors.
 
**1) End users of WebLogic 10.3.2.0
 
**1) End users of WebLogic 10.3.2.0
***This involves configuring the server for JPA 1.0 permanently or per-deployment
+
***This involves configuring the server for JPA 2.0 permanently or per-deployment
 
***<font color="red">'''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'''</font>  
 
***<font color="red">'''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'''</font>  
 
**2) EclipseLink JPA test users on WebLogic 10.3.2.0
 
**2) EclipseLink JPA test users on WebLogic 10.3.2.0
 
***This involves temporarily configuring the server per-test-deployment
 
***This involves temporarily configuring the server per-test-deployment
 
+
*We have the following results for container-managed EM's
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
*This page is slated for immediate editing over 20090120-11 to make the conclusions more clear - however we have the following result for container-managed EM's
+
 
**EclipseLink JPA 2.0 code (CriteriaBuilder and weaving work)
 
**EclipseLink JPA 2.0 code (CriteriaBuilder and weaving work)
 
***[EL Example]: enterprise: JPA 2.0 CriteriaBuilder: org.eclipse.persistence.internal.jpa.querydef.CriteriaBuilderImpl@2225ece
 
***[EL Example]: enterprise: JPA 2.0 CriteriaBuilder: org.eclipse.persistence.internal.jpa.querydef.CriteriaBuilderImpl@2225ece
 
**The EM is a proxy  
 
**The EM is a proxy  
 
***EM: class $Proxy84
 
***EM: class $Proxy84
**<font color="red">But, persistence.xml 2.0 tags like <shared-cache-mode>NONE</shared-cache-mode>
+
==Problem 2: JPA 2.0 persistence.xml XSD Enablement==
will not pass validation on the server</font>
+
*<font color="red">persistence.xml 2.0 tags like <shared-cache-mode>NONE</shared-cache-mode>
 +
will not currently pass validation on the server </font> using the 2.0 header below.
 +
<source lang="xml">
 +
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"><! passes validation >
 +
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"><!fails validation >
 +
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd"><! fails validation>
 +
</source>
 +
<pre>
 
Caused By: weblogic.deployment.EnvironmentException: Error loading the persistence descriptor META-INF/persistence.xml from the module org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar.  See the following stack trace for nested errors: weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
 
Caused By: weblogic.deployment.EnvironmentException: Error loading the persistence descriptor META-INF/persistence.xml from the module org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar.  See the following stack trace for nested errors: weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
 
   F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes\META-INF\persistence.xml:19:3:19:3: problem: cvc-attribute.4: The value '2.0' does not equal the fixed value '1.0' of attribute 'version':<F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes/META-INF/persistence.xml:19:3>
 
   F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes\META-INF\persistence.xml:19:3:19:3: problem: cvc-attribute.4: The value '2.0' does not equal the fixed value '1.0' of attribute 'version':<F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes/META-INF/persistence.xml:19:3>
 
   F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes\META-INF\persistence.xml:28:11:28:11: problem: cvc-complex-type.2.4a: Expected elements 'class@http://java.sun.com/xml/ns/persistence exclude-unlisted-classes@http://java.sun.com/xml/ns/persistence properties@http://java.sun.com/xml/ns/persistence' instead of 'shared-cache-mode@http://java.sun.com/xml/ns/persistence' here in element persistence-unit@http://java.sun.com/xml/ns/persistence:<F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes/META-INF/persistence.xml:28:11>
 
   F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes\META-INF\persistence.xml:28:11:28:11: problem: cvc-complex-type.2.4a: Expected elements 'class@http://java.sun.com/xml/ns/persistence exclude-unlisted-classes@http://java.sun.com/xml/ns/persistence properties@http://java.sun.com/xml/ns/persistence' instead of 'shared-cache-mode@http://java.sun.com/xml/ns/persistence' here in element persistence-unit@http://java.sun.com/xml/ns/persistence:<F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes/META-INF/persistence.xml:28:11>
 
+
</pre>
 
+
 
+
  
  
 
*'''''We want a way for end users to override the JPA 1.0 library shipped with WebLogic Server 10.3.2.0 without modifying the server and affecting other applications.'''''
 
*'''''We want a way for end users to override the JPA 1.0 library shipped with WebLogic Server 10.3.2.0 without modifying the server and affecting other applications.'''''
 
**For a single EAR use [[EclipseLink/Development/JPA_2.0/weblogic#DI_1:_Alternative_3:_Application_Level_Shared_Library_-_In_Use|alternative #3]] below.
 
**For a single EAR use [[EclipseLink/Development/JPA_2.0/weblogic#DI_1:_Alternative_3:_Application_Level_Shared_Library_-_In_Use|alternative #3]] below.
 +
 
==Problem==
 
==Problem==
 
*This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application managed EntityManagers.
 
*This document details a solution for enabling JPA 2.0 API functionality for various enterprise application use cases involving application managed EntityManagers.
Line 158: Line 360:
  
 
==Design==
 
==Design==
===Design Issue 1: JSR-317 JPA 2.0 EJB 3.1 Support===
+
===Design Issue 1: JSR-317 JPA 2.0 Support===
 
====DI 1.1: Problem====
 
====DI 1.1: Problem====
*The modules currently shipped with WebLogic 10.3.2.0 (Patch Set 1) in are the following JPA 1.0 compatible versions - these must be overriden in order to run JPA 2.0 API.
+
*The modules currently shipped with WebLogic 10.3.2.0 (Patch Set 1) are the following JPA 1.0 compatible versions - these must be overriden in order to run JPA 2.0 API.
 
**modules/org.eclipse.persistence_1.0.0.0_1-2-0.jar
 
**modules/org.eclipse.persistence_1.0.0.0_1-2-0.jar
 
**modules/javax.persistence_1.0.0.0_1-0-2.jar
 
**modules/javax.persistence_1.0.0.0_1-0-2.jar
Line 177: Line 379:
 
***where F:/view_w35d == %SVN_TRUNK
 
***where F:/view_w35d == %SVN_TRUNK
 
*Note: do not use the '''javax.persistence_2.0_preview.jar''' - the dated '''javax.persistence_2.0.0.*.jar''' one is the final PFD version for the JPA 2.0 specification.
 
*Note: do not use the '''javax.persistence_2.0_preview.jar''' - the dated '''javax.persistence_2.0.0.*.jar''' one is the final PFD version for the JPA 2.0 specification.
=====<font color="green">'''DI 1.1: Alternative 3: Application Level Shared Library'''</font> - In Use=====
+
====='''DI 1.1: Alternative 3: Application Level Shared Library''' - In Use=====
 +
*<font color="green">'''20110115-Note: the three outstanding issues ''(XSD, Weaving and JPA 2.0 Dependency Injection)'' look to be fixed by applying [http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch QWG8] or manually [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JEE6.2FJPA2_support prepending] to the WebLogic 10.3.4.0 server classpath.'''</font>
 +
 
 
This example uses an application-managed EE injected EMF.
 
This example uses an application-managed EE injected EMF.
  
Line 259: Line 463:
 
**JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.ext.dirs=F:/view_w35d/jpa/plugins/javax.persistence_2.0.0.v*.jar
 
**JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.ext.dirs=F:/view_w35d/jpa/plugins/javax.persistence_2.0.0.v*.jar
  
====DI 1.2: ====
+
====DI 21: Container managed EM with JTA datasource====
=====DI 1.2: Alternative 1:=====
+
*The following exception will occur for any FRD JPA 2.0 API client code deployed to WebLogic if the JPA specification library is at the 1.0 level instead of at the JPA 2.0 level.
 +
<pre>
 +
<Jan 18, 2010 11:33:04 PM EST> <Error> <Deployer> <BEA-149205> <Failed to initialize the application 'WebLogic1032CMEAR' due to error weblogic.application.ModuleException: Exception preparing module: EJBModule(WebLogic1032CMEJB.jar)
 +
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
 +
javax/persistence/criteria/CriteriaBuilder..
 +
weblogic.application.ModuleException: Exception preparing module: EJBModule(WebLogic1032CMEJB.jar)
 +
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
 +
javax/persistence/criteria/CriteriaBuilder.
 +
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:454)
 +
</pre>
 +
*This UC/DI 21 will detail how to enable full JPA 2.0 functionality for container managed entityManagers.
 +
 
 +
=====DI 21: Alternative 1:=====
 +
 
 
====DI 1.3: ====
 
====DI 1.3: ====
 
=====DI 1.3: Alternative 1:=====
 
=====DI 1.3: Alternative 1:=====
Line 271: Line 488:
 
*See the development bug [http://bugs.eclipse.org/296271 #296271] for attached EAR test archives.
 
*See the development bug [http://bugs.eclipse.org/296271 #296271] for attached EAR test archives.
  
===Container Managed Clients===
+
===Container Managed EM Clients===
*Support for container managed applications is as-is with out of the box JPA 1.0 API functionality - however the alternatives above give WebLogic server administratiors options for setting the JPA 2.0 specification library ahead of the shipped 1.0 jar in the server classpath.
+
*Support for container managed EM applications is as-is with out of the box JPA 1.0 API functionality - however the alternatives above give WebLogic server administratiors options for setting the JPA 2.0 specification library ahead of the shipped 1.0 jar in the server classpath.
  
 
===Eclipse IDE Project Details===
 
===Eclipse IDE Project Details===
Line 300: Line 517:
 
*[http://download.oracle.com/docs/cd/E15523_01/web.1111/e13706/libraries.htm Oracle WebLogic 10.3.1.0 OTN - Creating Shared Java EE Libraries and Optional Packages]
 
*[http://download.oracle.com/docs/cd/E15523_01/web.1111/e13706/libraries.htm Oracle WebLogic 10.3.1.0 OTN - Creating Shared Java EE Libraries and Optional Packages]
 
*[http://download.oracle.com/docs/cd/E15051_01/wls/docs103/deployment/understanding.html#wp1052671 WebLogic Server Deployment - Optional Packages]
 
*[http://download.oracle.com/docs/cd/E15051_01/wls/docs103/deployment/understanding.html#wp1052671 WebLogic Server Deployment - Optional Packages]
 +
*[http://forums.oracle.com/forums/thread.jspa?threadID=1093616 OTN user discussion on alternate persistence.xml renaming to bypass automatic JPA 2.0 XSD validation - at least using Spring beans - to be verified]
 +
*[http://forums.oracle.com/forums/thread.jspa?threadID=948811&tstart=120 WebLogic Server OTN Forum Post]
 +
<!--
 
*[http://bugs.eclipse.org/249213 249213]
 
*[http://bugs.eclipse.org/249213 249213]
 
*[http://bugs.eclipse.org/296271 296271]
 
*[http://bugs.eclipse.org/296271 296271]
Line 306: Line 526:
 
*[http://bugs.eclipse.org/296220 296220]
 
*[http://bugs.eclipse.org/296220 296220]
 
*[http://bugs.eclipse.org/296233 296233]
 
*[http://bugs.eclipse.org/296233 296233]
 +
-->
 +
*Official answer http://forums.oracle.com/forums/thread.jspa?messageID=4451546&tstart=0
 +
 +
==Links to this Wiki==
 +
* [http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial EclipseLink WebLogic JPA Tutorial]
 +
[http://www.eisele.net/blog/2010/01/jpa-20-and-oracle-weblogic-10320-11g.html Marcus Eisele]
 +
 +
*[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/glassfish JPA 2.0 on Glassfish V2 and V3]
 +
*http://netbeans.org/kb/docs/web/jsf-jpa-weblogic.html#01e
 +
 +
==TODO==
 +
*'''<font color="red">20110115: all resolved by the public release of WebLogic 10.3.4 on OTN - http://forums.oracle.com/forums/thread.jspa?threadID=2153356&tstart=0</font>'''
 +
*Tracking bug is [http://bugs.eclipse.org/334468 334468]
 +
*There is a lot of unresolved JPA 2.0 deployment issues that need to be answered when the next version ships.
 +
*Oracle WebLogic Server 11gR1 10.3.4 was released on 14 Jan 2011
 +
**Official Documentation
 +
***OTN download
 +
****http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html
 +
****http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html
 +
***Patching
 +
****http://download.oracle.com/docs/cd/E18476_01/doc.220/e18480/weblogicchap.htm
 +
***Documentation
 +
****http://download.oracle.com/docs/cd/E17904_01/web.1111/e13852/toc.htm
 +
***Supported Oracle WebLogic Server Versions
 +
****http://download.oracle.com/docs/cd/E15315_06/help/oracle.eclipse.tools.weblogic.doc/html/SupportedServerVersions.html
 +
***TopLink JPA 2.0 Specific
 +
****http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
 +
 +
*To be updated/reviewed
 +
*The following running WebLogic instance needs to be updated from 10.3.2 to 10.3.4
 +
**http://webservice.bea.com/
 +
*NetBeans 7: Running a JavaServer Faces 2.0 Web Application on Oracle WebLogic Server
 +
**http://netbeans.org/kb/docs/web/jsf-jpa-weblogic.html
 +
**We need to update the line about JPA 2.0 compliance - I have contacted the author(s)
 +
*http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#JSR-317_JPA_2.0_Support
 +
*http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic
 +
*JPA 2: Reverify JPA 2.0 XSD support in persistence.xml on AM/CM app on WebLogic 10.3.3.0
 +
**http://bugs.eclipse.org/331569
 +
*JPA 2.0: Add WebLogic 10.3 configuration process to enable the JPA 2.0 library functionality - updated
 +
**http://bugs.eclipse.org/296271
 +
*http://en.wikipedia.org/wiki/Oracle_WebLogic_Server - updated
 +
*JPA: Add downloadable 60k weblogic.EAR to wiki page (outside of SVN) - '''reopened'''
 +
**http://bugs.eclipse.org/294745
 +
*JPA: support WebLogic 10.3.4.0 introduction of new JPA MBean that changes the default JPA provider
 +
**http://bugs.eclipse.org/312824
 +
*JPA: Update tutorial wiki for WebLogic 10.3 to match the Oracle WebLogic 11g 10.3.3.0 - '''assigned'''
 +
**http://bugs.eclipse.org/310849
 +
 +
*To be answered
 +
*OTN Post: WebLogic Server - Upgrade / Install / Environment / Migration
 +
**11g Release 1 Patch Set 3 (WLS 10.3.4)
 +
***http://forums.oracle.com/forums/thread.jspa?threadID=1112476&tstart=0
 +
*OTN Post: WebLogic 10.0 + JPA 2.0 = errors - updated
 +
**http://forums.oracle.com/forums/message.jspa?messageID=9259147#9259147
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=2153356&tstart=0
 +
*OTN Post: Default JPA provider for Weblogic Server 10.3.2 (11g) - updated
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=1017020&tstart=0
 +
*OTN Post: Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn  - updated
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=2152609&tstart=0
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=1093616
 +
*OTN Post: EJB with Hibernate On Weblogic - updated
 +
**http://forums.oracle.com/forums/thread.jspa?messageID=9266202&tstart=0
 +
*OTN Post: OEPE 1.6 - Oracle WebLogic Server 11gR1 PatchSet 3 requres WLS 10.3.4 - answered
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=1108420
 +
*OTN Post: EJB with Hibernate On Weblogic - updated
 +
**http://forums.oracle.com/forums/message.jspa?messageID=9265781#9265781
 +
*OTN Post: OpenJPA_2.0 NoSuchMethod error (getValidationMode()) - updated
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=2150287&tstart=0
 +
*OTN Post: Migration application to Weblogic 10.3
 +
**http://forums.oracle.com/forums/thread.jspa?messageID=3601607
 +
*OTN Post: Server ignoring APP-INF/lib - updated
 +
**http://forums.oracle.com/forums/thread.jspa?threadID=2137177&tstart=0
 +
*JPA 2.0 features used on WebLogic even if they are not available at runtime - notified
 +
**http://netbeans.org/bugzilla/show_bug.cgi?id=189205
 +
*Option to enable JPA 2.0 for dev WebLogic - notified
 +
**http://netbeans.org/bugzilla/show_bug.cgi?id=189348
 +
*False-positive error badge on project with JPA targeting WebLogic - notified
 +
**http://netbeans.org/bugzilla/show_bug.cgi?id=189626
 +
*Giving up on Hibernate (for now), trying EclipseLink...
 +
**http://forums.netbeans.org/post-94817.html
 +
*http://blogs.sun.com/arungupta/entry/which_java_ee_6_app
 +
*Eclipselink 2.0 + WebLogic 10 => No joy (Unable to get Eclipse link 2.0 working with WebLogic 10) - answered
 +
**http://www.eclipse.org/forums/index.php?t=msg&goto=644000&S=40e13288641c0af5dc8489343b896348#msg_644000
 +
*[eclipselink-users] Problem of eclipselink upgrade (2.0.2) - WebLogic 10.3.3.0  - answered
 +
**http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg04631.html
 +
*Re: EclipseLink + JPA 2 in Weblogic 10.3.0
 +
**http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg04375.html - answered below
 +
*Re: [eclipselink-users] Problems with Eclipselink 2 (JPA 2.0) & WebLogic 10,
 +
**http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05609.html
 +
*[eclipselink-users] Problems with Eclipselink 2 (JPA 2.0) & WebLogic 10 - answered
 +
**http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05639.html
 +
 +
*To be Deprecated
 +
*JPA 2: Reverify JPA 2.0 XSD support in persistence.xml on AM/CM app on WebLogic 10.3.3.0
 +
**http://bugs.eclipse.org/331569
 +
*JPA 2.0: Add WebLogic 10.3 configuration process to enable the JPA 2.0 library functionality
 +
**http://bugs.eclipse.org/296271
 +
*http://forums.oracle.com/forums/thread.jspa?threadID=679739
 +
*Answer question on WebLogic 10.3.3.0
 +
**http://old.nabble.com/FW%3A-Eclipselink-2---JPA-2-with-WebLogic-10.3.3-td33281550.html
 +
**https://forum.hibernate.org/viewtopic.php?f=1&t=1003425&sid=faf10b72a779ad76ed8c0924795134cb

Latest revision as of 17:56, 7 February 2012

Running JPA 2.0 API on WebLogic 10.3

DISCLAIMER: This page reflects investigation into how EclipseLink users can evaluate EclipseLink JPA 2.0 within existing WebLogic releases. It does NOT imply any formal certification from Oracle that JPA 2.0 is supported on WebLogic at this time.

Contents

20110515: JPA 2.0 using EclipseLink on WebLogic 10.3.5.0

  • Details in this section are in addition to the section on WebLogic 10.3.4.0

20110115: JPA 2.0 using EclipseLink on WebLogic 10.3.4.0

  • This section on WebLogic 10.3.4 was added to the original document that discussed experimental methods of getting a JPA 2.0 based application running on WebLogic 10.3.3.0 - that section is now deprecated with the release of WebLogic 10.3.4.0 on 14 Jan 2011.
  • Official Oracle Blog entry / press release for 10.3.4 on 20 Jan 2011
  • 20100115-Note: the three outstanding issues (XSD, Weaving and JPA 2.0 Dependency Injection) look to be fixed by applying patch QWG8 or manually prepending to the server classpath.
  • WebLogic 10.3.4.0 is released on OTN - the contents of this page will likely be deprecated as specific to 10.3.3.0 and 10.3.2.0 - pending a full review.
  • There is a large list of public OTN and EclipseLink wiki pages, bug/enhancement analysis comments and newsgroup entries that we are now able to discuss. A full review of all 10.3.3.0 workarounds, updates to all WebLogic JPA 2.0 tutorial configurations and responses to all open WebLogic related JPA classloader and XSD validation issues is in order. I have prepared a list of these over the last year.
  • The main issues were JPA 2.0 XSD validation and JPA 2.0 container managed persistence unit injection.
    • In 10.3.3.0 you were required to use the FilteringClassLoader via the <wls:prefer-application-packages> addition to your application managed persistence unit - this workaround is now deprecated and not required in 10.3.4.0 for both application and container managed persistence contexts.
  • Specifically we will start retesting EE applications using a SSB injected @PersistenceContext container managed JTA transactional JPA 2.0 persistence units with/without JPA 2.0 XSD elements.
  • I verified the server and it is using SVN rev# 8635 from 6 Dec 2010 https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8635
  • Essentially in order to enable JPA 2.0 functionality on WebLogic 10.3.4 shipped on 14 Jan 2011 - you apply the patch below or manually edit your server classpath to put the JPA 2.0 persistence specification API jar and the com.oracle.jpa2support_1.0.0.0_2-0.jar ahead of the other liibraries on the classpath.
commEnv.cmd: line 67

@rem Set BEA Home
set BEA_HOME=C:\opt\wls1034r20110115
@rem Enable JPA 2.0 functionality on WebLogic Server 10.3.4 with the following patch line for commEnv.cmd:67
set PRE_CLASSPATH=%BEA_HOME%\modules\javax.persistence_1.0.0.0_2-0-0.jar;%BEA_HOME%\modules\com.oracle.jpa2support_1.0.0.0_2-0.jar
  • Everything is shipped with WebLogic 10.3.4 but JPA 1.0 is enabled by default so that this JEE5 capable server is backwards compatible with JEE5/JPA1 out of the box. Without the above patch you will see the following.
<15-Jan-2011 5:58:40 o'clock PM EST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 10.3.4.0  Fri Dec 17 20:47:33 PST 2010 1384255 >
[EL Info]: 2011-01-15 18:06:38.082--ServerSession(48997950)--Thread(Thread[[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--EclipseLink, version: Eclipse Persistence Services - 2.1.2.v20101206-r8635
[EL Info]: 2011-01-15 18:06:38.082--ServerSession(48997950)--Thread(Thread[[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Server: 10.3.4.0
  • 20100115-Note: this issue is fixed by applying patch QWG8 or manually prepending to the server classpath.
  • We have the required bundles in the modules directory but the JPA 2.0 specification jar is not above the JPA 1.0 jar by default - the patch will change this...
    • javax.persistence_1.0.0.0_2-0-0.jar (upgraded from 1-0-2)
    • org.eclipse.persistence_1.0.0.0_2-1.jar (upgraded from 2-0)
  • A very quick test of a JPA 2.0 container managed app with the following persistence.xml in the ejb.jar works as detailed below - before the patch is applied.
  • Note: All testing at this time is on a WebLogic 10.3.4.0 install out-of-the-box (without the QWG8 patch - to verify default JPA 1.0 functionality). The only modification I made yet was in creating a derby 10.5.3.0 JTA global datasource "localJTA" on the server - and drop a container managed JPA 2.0 app as an EAR in the autodeploy directory on the default user domain.
  • There are 3 issues we must check.
    • 1) JPA 2.0 XSD parsing errors: as expected there are no more JPA 2.0 schema parsing issues.
    • 2) New JPA 2.0 schema elements like the *<shared-cache-mode>NONE</shared-cache-mode>* element - this passes validation but we need to verify runtime functionality
    • 3) JPA 2.0 runtime API like a *entityManager.getMetamodel();* call on the Servlet or Stateless session bean
    • 4) JPA 2.0 weaving/instrumentation - Again we need to verify something like weaving of Entities contaiing lazy IndirectLists are weaved properly by the container.
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="example" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <!-- we will default to Kodo without specifying the provider only in JPA 1.0 -->
        <jta-data-source>localJTA</jta-data-source>
        <shared-cache-mode>NONE</shared-cache-mode><!-- shared-cache-mode must come after any class definitions (usually SE only) - the JPA schema is ordered -->
        <properties>
            <property name="eclipselink.target-server" value="WebLogic_10"/>
            <property name="eclipselink.target-database" value="Derby"/>            
            <property name="eclipselink.logging.level" value="FINEST"/>
            <!-- new for 10.3.4.0 http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging#Server_Logging  -->
            <property name="eclipselink.logging.logger" value="DefaultLogger"/>
            <!-- turn off DDL generation after the model is stable -->            
            <!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
            <!-- property name="eclipselink.ddl-generation.output-mode" value="database"/-->
        </properties>       
    </persistence-unit>

JPA 2.0 Container Managed EntityManager Injection

java.lang.NoSuchMethodError: javax/persistence/EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel;
        at org.eclipse.persistence.example.jpa.server.weblogic.enterprise.presentation.FrontController.processGliderComm
        and(FrontController.java:346)
  • or 3) The same exception if we try to run JPA 2.0 on the DI entityManager from the SSB in the EJB container classLoader
javax.ejb.EJBException: EJB Exception: : java.lang.NoSuchMethodError: javax/persistence/EntityManager.getMetamodel()Ljavax/persistence/metamodel/Metamodel;
	at org.eclipse.persistence.example.jpa.server.business.ApplicationService.insertObjects(ApplicationService.java:66)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
..
	at $Proxy74.insertObjects(Unknown Source)
	at org.eclipse.persistence.example.jpa.server.business.ApplicationService_5ptwty_ApplicationServiceLocalImpl.__WL_invoke(Unknown Source)

JPA 2.0 Container Bytecode Weaving/Instrumentation

  • 20100115-Note: the three outstanding issues (XSD, Weaving and JPA 2.0 Dependency Injection) look to be fixed by applying patch QWG8 or manually prepending to the server classpath.
  • We also get the Kodo/OpenJPA provider when we attempt to weave.
<openjpa-1.1.1-SNAPSHOT-r422266:965591 fatal user error> org.apache.openjpa.util.MetaDataException: "org.eclipse.persistence.example.jpa.server.business.Cell.id" declares generator name "EL_SEQUENCE_CELL", but uses the AUTO generation type.  The only valid generator names under AUTO are "uuid-hex" and "uuid-string".
	at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.getGeneratedValueStrategy(AnnotationPersistenceMetaDataParser.java:1226)
  • Note: Once the JPA2 patch is applied you no longer need to set the default JPA provider unless you don't specify the provider in your persistence.xml

Weblogic10340 r20110115 change default jpa2 provider from kodo to toplink.JPG

  • Therefore there is still a little bit of configuration required.

Enabling JPA2 support

  • Note: See the following tutorial page on running EclipseLink as the JSR-317 JPA 2.0 provider for a distributed Java EE enterprise application on WebLogic 10.3.4 or GlassFish 3.1.
  • 1) Install Oracle WebLogic 10.3.4 or upgrade from 10.3.3
  • 2a) Install the QWG8 patch using the support download, or
  • 2b) manually add the com.oracle.jpa2support_1.0.0.0_2-0.jar ahead of the server classpath by following the instructions in the documentation at
C:\opt\wls10340_pub110115\wlserver_10.3\common\bin\commEnv.cmd
  set PRE_CLASSPATH=%BEA_HOME%\modules\javax.persistence_1.0.0.0_2-0-0.jar;%BEA_HOME%\modules\com.oracle.jpa2support_1.0.0.0_2-0.jar

Results

The following code...

@Local
@Stateless
public class ApplicationService implements ApplicationServiceLocal {
    @PersistenceContext(unitName="example", type=PersistenceContextType.TRANSACTION)	
    private EntityManager entityManager;
 
    public boolean insertObjects(List<Cell> classes) {
        try {
            for(int i=0; i< classes.size(); i++) {
                entityManager.persist(classes.get(i));
            }
            System.out.println("JPA 2.0 Metamodel: " + entityManager.getMetamodel());

...prints out the JPA 2.0 EntityManager dependency injected into the SSB proxy for the life of the transaction in the function

JPA 2.0 Metamodel: MetamodelImpl@34817119 [ 5 Types: , 2 ManagedTypes: , 2 EntityTypes: , 0 MappedSuperclassTypes: , 0 EmbeddableTypes: ]
[EL Finer]: 2011-01-15 22:36:00.33--UnitOfWork(34913451)--Thread(Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self tuning)',5,Pooled Threads])--TX beforeCompletion callback, status=STATUS_ACTIVE
  • You can see that when we debug the stateless session bean $Proxy that has our injected EntityManager...
this	ApplicationService_5ptwty_Impl  (id=11616)	
	__WL_EJBContext	SessionEJBContextImpl  (id=11654)	
	entityManager	$Proxy73  (id=11639)	
		h	TransactionalEntityManagerProxyImpl  (id=11638)	
			appName	"org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR" (id=11513)	
			closeMethod	Method  (id=11663)	
			moduleName	"org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar" (id=11515)	
			persistenceUnit	PersistenceUnitInfoImpl  (id=11665)	
			persistenceUnitName	"org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEAR#org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar#example" (id=11666)	
			queryMethods	HashSet<E>  (id=11668)	
			transactionAccessMethod	Method  (id=11669)	
			transactionalMethods	HashSet<E>  (id=11670)	
			txHelper	TransactionHelperImpl  (id=11523)	
			txRegistry	ServerTransactionManagerImpl  (id=11524)	
			unqualifiedPersistenceUnitName	"example" (id=11672)
  • ...no longer complains about an unknown getMetamodel() JPA 2.0 method signature.
Oracle WebLogic Server 11gR1 PatchSet 3 r20110115 at localhost [Oracle WebLogic Server]	
	Java HotSpot(TM) Client VM[localhost:8453]	
		Daemon Thread [[ACTIVE] ExecuteThread: '20' for queue: 'weblogic.kernel.Default (self-tuning)'] (Running)		Daemon Thread [[ACTIVE] ExecuteThread: '18' for queue: 'weblogic.kernel.Default (self-tuning)'] (Suspended)			TransactionalEntityManagerProxyImpl.invoke(Object, Method, Object[]) line: 18	
			$Proxy59.getMetamodel() line: not available [local variables unavailable]	
			ApplicationService_5ptwty_Impl(ApplicationService).insertObjects(List<Cell>) line: 60	
..			JdkDynamicAopProxy.invoke(Object, Method, Object[]) line: 204	
			$Proxy71.insertObjects(List) line: not available	
			ApplicationService_5ptwty_ApplicationServiceLocalImpl.__WL_invoke(Object, Object[], int) line: not available	
			SessionLocalMethodInvoker.invoke(BaseLocalObject, MethodDescriptor, Object[], int, String, Class<?>) line: 39	
			ApplicationService_5ptwty_ApplicationServiceLocalImpl.insertObjects(List) line: not available	
			FrontController.generateGlider(PrintWriter) line: 252	
..			FrontController(HttpServlet).service(ServletRequest, ServletResponse) line: 820	
			StubSecurityHelper$ServletServiceAction.run() line: 227	
..			ExecuteThread.run() line: 176	
 
arg1	Method  (id=11511)	
	clazz	Class<T> (javax.persistence.EntityManager) (id=8312)	
	name	"getMetamodel" (id=11543)	
	returnType	Class<T> (javax.persistence.metamodel.Metamodel) (id=11545)
  • For 4) Weaving is occuring as expected on either the JPA 1.0 or JPA 2.0 entities. We check this by either checking that our Entity is an instanceof org.eclipse.persistence.internal.weaving.PersistenceWeaved interface, or debug into the Entity and look for our bytcode instrumented weaved fields that start with _persistence. The question is - we need a weaved field or weaved function that was introduced for JPA 2.0.
[4]	Cell  (id=11571)	
	_persistence_fetchGroup	null	
	_persistence_primaryKey	null	
	_persistence_session	null	
	_persistence_shouldRefreshFetchGroup	false	
	aCellAttribute	null	
	id	null	
	left	null	
	peers	HashSet<E>  (id=11572)	
		map	HashMap<K,V>  (id=11575)
com.oracle.jpa2support_1.0.0.0_2-0.jar forensics

I had a look at the patch jar com.oracle.jpa2support_1.0.0.0_2-0.jar that WebLogic 10.3.4 ships with that allows installers to enable JPA 2.0 (JSR-317) support to superceed the default JPA 1.0 (JSR-220) support. It looks like the container proxy code for container managed EntityManagerFactory and EntityManager $Proxy objects has been updated so that a JPA 2.0 EntityManager $Proxy object get injected with the proper API level object via the InvocationHandlerFactory, FactoryInterceptor. The Query proxy has been updated as well. There is a fix for Kodo(OpenJPA) and OpenJPA related to the recent change and deprecation of certain functions of those providers. The EclipseLink JPA 2.0 provider (as the provider for TopLink) did not need weblogic changes beyond placing the JPA javax.peristence 2.0 specification jar higher on the classpath.

  • 3) or let Eclipse 3.6 Helios change the order of the javax.persistence library and add the JPA 2.0 patch for container managed dependency injection to work.

Enable jpa2 in weblogic1034 from eclipse36.JPG


  • The root EclipseLink tracking bug is 334468

Older 10.3.3.0 content

  • 20100115-Note: the three outstanding issues (XSD, Weaving and JPA 2.0 Dependency Injection) look to be fixed by applying patch QWG8 or manually prepending to the WebLogic 10.3.4.0 server classpath.
  • WebLogic 10.3.2.0 and 10.3.3.0 ship with the JPA 1.0 specification jar - we would like to run JPA 2.0 API on WebLogic. This document describes a potential solution to container-managed and application managed deployments and the details in getting their use cases running.

Results Matrix

  • The following table summarizes the type of test, server modifications and results for verious container managed and application managed EntityManager deployments on WebLogic server.
UC# DI# Test Example-Description Container-Managed vs Application-Managed Injected-EMF vs Persistence bootstrap JTA, non-JTA, RESOURCE _LOCAL Datasource Entities, PU in utility JAR Entities, PU in EJB JAR Entities, PU in WAR EAR wls:prefer- application-packages mod? Server modifications? persistence.xml 2.0 XSD Schema Weaving entities Runs JPA2 Impl (shipped with EclipseLink 1.2 only) Runs JPA2 Impl (shipped with EclipseLink 2.0 only) - IE: CriteriaBuilder
1 Application_Managed PU EAR(WAR only) - working application Persistence bootstrap JTA PU in WAR Yes none 2.0 ? 20101202 under investigation in 331569 no - off Y Y
2 App-Managed case pending... - unknown application injected @PersistenceUnit EMF on Servlet  ? PU in utility JAR  ?Yes none ?  ???  ???  ???
3a Container-Managed PU in EAR(EJB,WAR) - working but with server script modifications container injected @PersistenceContext EM on Stateless Session Bean (EM is proxied, em.getClass().toString = $Proxy84) JTA PU in EJB commEnv.cmd (both javax and eclipselink jar refs) 1.0 reverified 20100120 as validation exception Weaved as 1.0 Y Y
3b Container-Managed PU in EAR(EJB,WAR) - working but with server modules jar modifications container injected @PersistenceContext EM on Stateless Session Bean (EM is proxied, em.getClass().toString = $Proxy84) JTA PU in EJB (overwrite both javax and eclipselink jars with 2.0 versions) 1.0 ?reverifying 20100120 Weaved Y Y
4a Container-Managed PU in EAR(EJB,WAR) with override in EAR descriptor (no server modifications) - pending container injected @PersistenceContext EM on SSB JTA PU in EJB Yes (javax.persistence.* only) none ???2.0 ???yes  ???  ???
4b Container-Managed PU in EAR(EJB,WAR) with override in EAR descriptor (no server modifications) - pending container injected @PersistenceContext EM on Servlet JTA PU in WAR Yes (javax.persistence.* only) none ???2.0 ???yes  ???  ???

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

Results Summary

  • Container-managed JPA 2.0 entity managers work with the following modifications and constraints.
    • Add both the javax and eclipselink jars to the top of the server classpath
    • Weaving and the new JPA 2.0 interface changes between EclipseLink 1.2 and 2.0 work - see logs
      • [EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Begin weaver class transformer processing class [org.eclipse.persistence.example.jpa.server.business.Cell].
      • [EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaved persistence (PersistenceEntity) [org.eclipse.persistence.example.jpa.server.business.Cell].
      • [EL Finest]: 2009-12-10 15:05:17.055--ServerSession(11840499)--Thread(Thread[[STANDBY] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads])--Weaved fetch groups (FetchGroupTracker) [org.eclipse.persistence.example.jpa.server.business.Cell].
    • persistence.xml 2.0 changes will not pass deployment validation only for container managed JPA applications

Problem 1: JPA 2.0 API Enablement

  • 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 WebLogic 10.3.2.0
      • This involves configuring the server for JPA 2.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 WebLogic 10.3.2.0
      • This involves temporarily configuring the server per-test-deployment
  • We have the following results for container-managed EM's
    • EclipseLink JPA 2.0 code (CriteriaBuilder and weaving work)
      • [EL Example]: enterprise: JPA 2.0 CriteriaBuilder: org.eclipse.persistence.internal.jpa.querydef.CriteriaBuilderImpl@2225ece
    • The EM is a proxy
      • EM: class $Proxy84

Problem 2: JPA 2.0 persistence.xml XSD Enablement

  • persistence.xml 2.0 tags like <shared-cache-mode>NONE</shared-cache-mode>

will not currently pass validation on the server using the 2.0 header below.

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"><! passes validation >
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"><!fails validation >
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd"><! fails validation>
Caused By: weblogic.deployment.EnvironmentException: Error loading the persistence descriptor META-INF/persistence.xml from the module org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB.jar.  See the following stack trace for nested errors: weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
  F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes\META-INF\persistence.xml:19:3:19:3: problem: cvc-attribute.4: The value '2.0' does not equal the fixed value '1.0' of attribute 'version':<F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes/META-INF/persistence.xml:19:3>
  F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes\META-INF\persistence.xml:28:11:28:11: problem: cvc-complex-type.2.4a: Expected elements 'class@http://java.sun.com/xml/ns/persistence exclude-unlisted-classes@http://java.sun.com/xml/ns/persistence properties@http://java.sun.com/xml/ns/persistence' instead of 'shared-cache-mode@http://java.sun.com/xml/ns/persistence' here in element persistence-unit@http://java.sun.com/xml/ns/persistence:<F:\view_w35d\examples\org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB\build\classes/META-INF/persistence.xml:28:11>


  • We want a way for end users to override the JPA 1.0 library shipped with WebLogic Server 10.3.2.0 without modifying the server and affecting other applications.

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 WebLogic 10.3.2.0
      • 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 WebLogic 10.3.2.0
      • This involves temporarily configuring the server per-test-deployment

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 WebLogic server classpath see enhancement # 296271.
  • Now, you may have noticed that the modules/org.eclipse.persistence_1.0.0.0_1-2-0.jar jar contains JPA 2.0 API implementation classes such as org.eclipse.persistence.internal.jpa.metamodel - however this API is not available through interface classes (because only the javax.persistence 1.0 jar is present) and we also are missing the services file for Criteria/Metamodel - in any case a predeploy should fail where the EAR contains JPA 2.0 API out of the box.

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 - alternative #3
          • 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
    • 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

Design

Design Issue 1: JSR-317 JPA 2.0 Support

DI 1.1: Problem

  • The modules currently shipped with WebLogic 10.3.2.0 (Patch Set 1) are the following JPA 1.0 compatible versions - these must be overriden in order to run JPA 2.0 API.
    • modules/org.eclipse.persistence_1.0.0.0_1-2-0.jar
    • modules/javax.persistence_1.0.0.0_1-0-2.jar
DI 1.1: Alternative 1: Manual overwrite of eclipselink and javax.persistence libraries in modules
  • Current solution - this should be deprecated.
DI 1.1: Alternative 2: Reference higher in the server classpath via commEnv.cmd
  • 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.
DI 1.1: Solution
  • In <WEBLOGIC_HOME>\wlserver_10.3\common\bin\commEnv.cmd
    • change
      • set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar...
    • To
      • set WEBLOGIC_CLASSPATH=F:/view_w35d/jpa/plugins/javax.persistence_2.0.0.*.jar;%JAVA_HOME%\lib\tools.jar...
      • where F:/view_w35d == %SVN_TRUNK
  • Note: do not use the javax.persistence_2.0_preview.jar - the dated javax.persistence_2.0.0.*.jar one is the final PFD version for the JPA 2.0 specification.
DI 1.1: Alternative 3: Application Level Shared Library - In Use
  • 20110115-Note: the three outstanding issues (XSD, Weaving and JPA 2.0 Dependency Injection) look to be fixed by applying patch QWG8 or manually prepending to the WebLogic 10.3.4.0 server classpath.

This example uses an application-managed EE injected EMF.

  • 20091202 working standalone Eclipse EAR (WAR only) prototype attached bug 296271 - this procedure has been verified on 2 separate servers on separate machines (in order to filter out any possible leftover configuration experimentation that could skew results)
  • The following artifacts and modifications are required (failure of any one of these will result in a Persistence Unit not found during deployment or runtime)
  • 1) Start with an EAR project containing only a WAR (no ejb-jar) - Eclipse can generate one for you after you install the WebLogic Eclipse Plugin
  • 2) Ship EclipseLink 2.0 and JPA 2.0 in the EAR project (not the WAR)
    • 2a) Add eclipselink.jar V2 (OSGI version is org.eclipse.persistence_1.0.0.0_2-0-0.jar) to EarContent\APP-INF\lib - this will override org.eclipse.persistence_1.0.0.0_1-2-0.jar in the modules dir on the server
    • 2b) Add the JPA 2.0 specification jar - this will override javax.persistence_1.0.0.0_1-0-2.jar.
  • 3) Update the .MANIFEST where the root of the entity classes managed by the EntityManager reside (here the src\META-INF off the WAR) to point to these included jars (relative paths not required if they are in the classpath - which they are)
    • Class-Path: javax.persistence_2.0.0.v200911041116.jar eclipselink.jar
  • 4) Place your persistence.xml descriptor as usual for an application-managed entityManager in the WAR also at the classes root in src\META-INF - this will be exported to the server as classes. (Normally for a container-managed entityManager we would place persistence.xml and all entities in the ejb jar)
    • 4a) make sure to modify the Entity package paths as we are dealing with an SE persistence unit here
  • 5) Add the prefer-application-packages element to weblogic-application.xml so the internal WebLogic API FilteredClassLoader places our library ahead of the modules directory.
<wls:prefer-application-packages>
  <wls:package-name>javax.persistence.*</wls:package-name>
  <wls:package-name>org.eclipse.persistence.*</wls:package-name>
</wls:prefer-application-packages>
  • 6) The EMF is either EE injected or obtained via a static SE Persistence call
    @PersistenceUnit(unitName="example")
    private EntityManagerFactory emf;
or
    private EntityManagerFactory emf;
    emf  = Persistence.createEntityManagerFactory("example);
  • 7) The following configuration elements are not present in this procedure
    • - no web.xml persistence-context-ref
    • - no weblogic-application.xml 'wls:library-ref
    • - no global shared-library EAR on the server either via the console or via the Eclipse IDE.
    • - no overriding javax.persistence or eclipselink.jar in the modules, domain/lib, wlserver_10.3/common/lib or wlserver_10.3/server/lib directories
    • - no scripted override on either wlserver_10.3/common/bin/commEnv.cmd or base_domain/bin/startWebLogic.cmd
  • Note: at this time there is no requirement to add WebLogic platform specific handling for the FilteredClassLoader - we are ok with the XML EAR deployment descriptor change.
Output 1.3
  • Note that the entityManager.getMetamodel() JPA 2.0 call in the application is resolved correctly with this fix.

Weblogic app managed em ear jpa2 server classpath override browser output 296271.JPG

DI 1.1: Alternative 4: Global Level Shared Library

Weblogic shared libraries in eclipse preferences.jpg

  • In this scenario we will require the creation of an EAR deployment application that can be referenced from any other EAR application that requires the EclipseLink override.
DI 1.1: Alternative 5: Domain Extension Template
  • 20091202 - This one suggested by Doug - similar to what is done for other vendor libraries.
  • This method involves copying the JPA 2.0 libraries to the lib directory off the current domain
    • example: %WEBLOGIC_HOME%\user_projects\domains\base_domain\lib
    • is below
    • %WEBLOGIC_HOME%\modules
  • The domain lib override alternative will not work because this lib is below the server classpath and has no effect after 10.3.0.
  • Our current weblogic.xml test script copies the xdb, spatial, jdbc, junit, xmlparserv2 and trunk eclipselink.jar to the domain lib - however this only works if no library is in modules that will override these domain libs.

Since 10.3.1 the user still needs to apply a patch to override modules libs in these lib cases. Therefore this option is deprecated for 10.3.1 and 10.3.2 since we started shipping with the eclipselink jar.

  • Potential modification to weblogic.xml:weblogic-install is (without $ variable prefix)
  <copy file="F:/view_w35d/jpa/plugins/javax.persistence_2.0.0.v200911041116.jar" todir="${weblogic.domain}/lib"/>
  • Another issue to solve is the absence of OSGI functionality - fixed by editing the .MANIFEST - see bug# 296733
<2-Dec-2009 1:09:45 o'clock PM EST> <Notice> <WebLogicServer> <BEA-000395> <Following extensions directory contents added to the end of the classpath:
C:\opt\wls10320\user_projects\domains\base_domain\lib\eclipselink.jar;C:\opt\wls10320\user_projects\domains\base_domain\lib\javax.persistence_2.0.0.v200911041116.jar;F:\view_w35d\jpa\plugins\javax.persistence_2.0.0.v200911041116.jar> 
<2-Dec-2009 1:09:45 o'clock PM EST> <Critical> <WebLogicServer> <BEA-000386> <Server subsystem failed. Reason: 
java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
java.lang.NoClassDefFoundError: org/osgi/framework/BundleActivator
DI 1.1: Alternative 6: Use -Dweblogic.ext.dirs override
  • Like alternative #5 - this one is also appended to the end of the server classpath - so is not of use.
  • base_domain/bin/startWebLogic.cmd
    • JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.ext.dirs=F:/view_w35d/jpa/plugins/javax.persistence_2.0.0.v*.jar

DI 21: Container managed EM with JTA datasource

  • The following exception will occur for any FRD JPA 2.0 API client code deployed to WebLogic if the JPA specification library is at the 1.0 level instead of at the JPA 2.0 level.
<Jan 18, 2010 11:33:04 PM EST> <Error> <Deployer> <BEA-149205> <Failed to initialize the application 'WebLogic1032CMEAR' due to error weblogic.application.ModuleException: Exception preparing module: EJBModule(WebLogic1032CMEJB.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
 javax/persistence/criteria/CriteriaBuilder..
weblogic.application.ModuleException: Exception preparing module: EJBModule(WebLogic1032CMEJB.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
 javax/persistence/criteria/CriteriaBuilder.
	at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:454)
  • This UC/DI 21 will detail how to enable full JPA 2.0 functionality for container managed entityManagers.
DI 21: Alternative 1:

DI 1.3:

DI 1.3: Alternative 1:

DI 1.4:

DI 1.4: Alternative 1:

Implementation

Application Managed Clients

  • The shared-library approach has been prototyped as Alternative #3 and functions fine for EARs that utilize application managed entitymanagers - the Eclipse 1.2 and JPA 1.0 libraries shipped with WebLogic 10.3.2.0 are overriden by the supplied EclipseLink 2.0 and JPA 2.0 libraries in the EAR.
  • See the development bug #296271 for attached EAR test archives.

Container Managed EM Clients

  • Support for container managed EM applications is as-is with out of the box JPA 1.0 API functionality - however the alternatives above give WebLogic server administratiors options for setting the JPA 2.0 specification library ahead of the shipped 1.0 jar in the server classpath.

Eclipse IDE Project Details

  • When creating an EAR project in Eclipse that targets a WebLogic runtime and uses JPA 2.0 functionality - you will receive a compile error on the new JPA 2.0 interface changes for EntityManager and EntityManagerFactory unless you put the JPA 2.0 specification library higher in your compile classpath than the default WebLogic Container Libraries.

Eclipse ejb project jpa2 library above weblogic system library.JPG

Log

  • 20091201: Start investigation
  • 20091202: Scope of this issue has been reduced to the application managed EAR level - @PersistenceContext injection of a 2.0 EM is not supported for EE servers that do not support JPA 2.0 out of the box.
    • The example used for EAR testing uses a container-managed EM via the following injected bean - this will be modified
@Local @Stateless
public class ApplicationService implements ApplicationServiceLocal {
	@PersistenceContext(unitName="example", type=PersistenceContextType.TRANSACTION)	
	private EntityManager entityManager;
  • 20100112: returning to this issue after a hold on 20091218

Meeting Minutes

20100115:

  • Application Managed
    • JPA 2.0 EM is ok with alternative #3 (<prefer-application-packages>) workaround.
  • Container Managed
    • Need to debug server $Proxy code and verify that we get proxies for all EntityManagerFactory, EntityManager, Query and EntityManagerTransaction?
      • This will aide us in determining where the server group can return us a proper error message for mixed JPA 1.0 and 2.0 configurations.

Resources

Links to this Wiki

Marcus Eisele

TODO

Back to the top