7 Replies Latest reply: Jul 4, 2011 12:26 PM by 872988 RSS

    new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1

    872988
      Hi,

      We want to deploy a new app .ear to a WLS 10.3.1 instance with JPA 2.0 provider=eclispeLink (so that it can use the new javax.persistence.metamodel package API). We want to do this in a way that assures that the new app .ear deployment in no way impacts any other app .ear deployment using JPA 1.0 on that same WLS 10.3.1 instance.

      We have basically covered all the steps documented under "alternative 3" on the EclipseLink wiki page addressing this issue (see [http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#20110115:_JPA_2.0_using_EclipseLink_on_WebLogic_10.3.4.0|http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#20110115:_JPA_2.0_using_EclipseLink_on_WebLogic_10.3.4.0] )

      Because we could not get past the verison=2.0 XSD validation issue on deployment, our app's persistence.xml uses the version=1.0 header and comments out all the tags (i.e. <SHARED-CACHE-MODE/>) only available in the 2.0 XSD.

      <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">



      Our provider tag looks like this

      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

      and our properties tag looks like this:

      <properties>
                     <property name="*eclipselink.target-server"* value="*WebLogic_10*"/>
                     <property name="*eclipselink.logging.level.sql*" value="*FINER*"/>
                     <property name="*eclipselink.cache.shared.default*" value="*false*"/>
                     <property name="*eclipselink.logging.logger*" value="*DefaultLogger*"/>
           </properties>

      Following other recommended steps, our .ear root has an APP-INF/ structure that looks like this

      ./APP-INF/lib/eclipselink.jar
      ./APP-INF/lib/javax.persistence_2.0.3.v201010191057.jar

      Our .earRoot/META-INF/weblogic-application.xml file includes

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

      Our .earRoot/META-INF/MANIFEST.MF file looks like this

      Manifest-Version: 1.0
      Class-Path: javax.persistence_2.0.3.v201010191057.jar eclipselink.jar

      Our .earRoot/.warRoot/WEB-INF/weblogic.xml looks includes

      <wls:container-descriptor>
      <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
      </wls:container-descriptor>


      Believing that we have covered all the recommened steps documented under "alternative 3" at the above cited EclipseLink wiki, we deploy this new app .ear to the WLS 10.3.1 instance and encounter the following Exception:


      +weblogic.deployment.EnvironmentException: Error processing persitence unit ReleaseBObjectModel of module /IConWorkspace: Error instantiating the Persistence Provider class org.eclipse.persistence.jpa.PersistenceProvider of the PersistenceUnit ReleaseBObjectModel: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider+
      at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:322)
      at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:123)
      at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:331)
      at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptors(AbstractPersistenceUnitRegistry.java:111)
      at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:58)
      Truncated. see log file for complete stacktrace

      Any ideas on what we need to do to overcome this CCE? Is our deployment both sound and complete wrt to our providing the necessary .earRoot/APP-INF/lib/ JPA 2.0 standard interface and eclipseLink implementation .jars?

      We are a bit stuck.

      We understand all the issues wrt WLS 10.3.1 being a particularly challenging JEE 5 platform on which to coerce JEE 6 capability (like JPA 2.0) ... we realize that this effoprt would be easier on WLS 10.3.4.

      However, at this time, WLS 10.3.1 is the only platform on which we are allowed to attempt to deploy this application.

      Thanks,
      Ben.Cotton@csg.com
        • 1. Re: new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
          René van Wijk
          From the your comments I assume you have the following directory structure:
          EAR
              APP-INF/lib
                  eclipselink.jar
                  javax.persistence_2.0.3.v201010191057.jar
                  ...
              META-INF
                  application.xml
                  weblogic-application.xml
              Model.jar
              Userinterface.war
          To filter the classloading for some preferred packages you can use.
          <prefer-application-packages>
               <package-name>javax.persistence.*</package-name>
                  <package-name>org.eclipse.persistence.*</package-name>
          </prefer-application-packages>
          Note that in your comments there are some * (<wls:package-name>javax.persistence.*</wls:package-name>).
          As long as you do not have any classes that need preference in the WEB-INF/lib directory can can leave out: <prefer-web-inf-classes>true</prefer-web-inf-classes>

          A similar issue, but than related to Hibernate is discussed here: http://middlewaremagic.com/weblogic/?p=5861
          Some general comments on classloading can be found here: http://middlewaremagic.com/weblogic/?p=6725
          • 2. Re: new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
            872988
            Hi Rene,

            Thank you for your response.

            Yes, the structure of our .ear is exactly as the tree you pictured.

            Sorry about the multiple '*' characters that appeared in the post. These '*' characters do not appear in our weblogic-application.xml file, which looks exactly like this:

            <wls:weblogic-application xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-application"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/javaee_5.xsd
            http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd">
            <!-- server-version: 10.3.1 -->
            <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>
            </wls:weblogic-application>

            Also, thank you for the links you provided ... we tried some of the ideas mentioned there (i.e. providing explicit <wls:classloader-structure/> entries in weblogic-application.xml).

            Ultimately, however, we still get the following CCE when we deploy our app .ear to WLS 10.3.1 (with JPA 2.0 provider=EclipseLink):

            weblogic.deployment.EnvironmentException: Error processing persitence unit ReleaseBObjectModel of module /IConWorkspace: Error instantiating the Persistence Provider class org.eclipse.persistence.jpa.PersistenceProvider of the PersistenceUnit ReleaseBObjectModel: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
            at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:322)
            at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:123)
            at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:331)
            at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptors(AbstractPersistenceUnitRegistry.java:111)
            at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:58)
            Truncated. see log file for complete stacktrace

            Thanks,
            Ben
            • 3. Re: new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
              René van Wijk
              There are some notes on running JPA 2.0 on WebLogic here: http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic, which you already mentioned.

              Find the entry WEBLOGIC_CLASSPATH in the commonEnv file (located in the ${WL_HOME}/common/bin directory} and add your jars at the front, for example,
              set WEBLOGIC_CLASSPATH=%YOUR_LOCATION%\javax.persistence_2.0.3.v201010191057.jar;%YOUR_LOCATION%\eclipselink.jar;%JAVA_HOME%\lib\tools.jar;%BEA_HOME%\utils...
              Note that this is for a Windows machine. I have not tested this set-up so I hope it helps.
              • 4. Re: new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
                859018
                Ben,
                Unfortunately, prior to WebLogic 10.3.4 you only have application managed persistence available for JPA 2.0. My page below details what can be done for older versions of WebLogic.

                http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#Oracle_WebLogic_Server_10.3.1.0
                http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic

                The issue with injection/instrumentation/proxying of a container managed JPA 2.0 @PersistenceContext is that the DI code in WebLogic needs to be aware of the JPA 2.0 EM and EMF (the 10.3.1 API was not forward compatible - you would need to hack the Spring based AOP injection code and the referenced EMFProxyImpl areas - and partiallly upgrade in effect to 10.3.4).
                See the following patch to the 20110115 initial release for the code changes related to (XSD, weaving and injection)
                http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#DI_1.1:_Alternative_3:_Application_Level_Shared_Library_-InUse
                http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309

                Note: if you don't require the JPA 2.0 additions to the persistence schema like shared-cache-mode NONE then use the 1.0 xsd to avoid the parse error.

                thank you
                Michael O'Brien
                michael.f.obrien at eclipselink.org
                http://www.eclipselink.org
                     

                cross references
                WebLogic 10.0 + JPA 2.0 = errors
                new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
                http://www.eclipse.org/forums/index.php/m/692428/#msg_692428
                • 6. Re: new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
                  872988
                  Thanks for the response. Unfortunately, we can't change any global settings for the WLS 10.3.1 instance that we are targeting for deployment. The capability to have JPA 2.0 provider=EclipseLink must be realized via a configuration to our .ear application. We cannot impact other apps.
                  • 7. Re: new app .ear with JPA 2.0 provider=eclipseLink deployed to WLS 10.3.1
                    872988
                    Thank you Michael. As always, most informative. Thanks again.