5 Replies Latest reply on Jul 13, 2011 10:09 AM by 819702

    Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn

    824749
      Hi,

      Is anyone able to deploy a JPA 2.0 (Hibernate 3.6 Final specifically) application on WL 10.3.x?

      I tried on 10.3.2 and 10.3.3 but I get following exceptions

      Caused By: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getSharedCacheMode()Ljavax/persistence/SharedCacheMode;
      at org.hibernate.ejb.util.LogHelper.logPersistenceUnitInfo(LogHelper.java:39)
      at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:516)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
      at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:352)
      at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:332)


      Or (when I set to use prefer-application-packages for javax.persistence.* and org.hibernate.*, I get the following exceptions:

      Caused By: weblogic.deployment.EnvironmentException: Error processing persistence unit TrivnetEJB of module TrivnetEJB.jar: Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit TrivnetEJB: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider
      at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:344)
      at weblogic.deployment.PersistenceUnitInfoImpl.createEntityManagerFactory(PersistenceUnitInfoImpl.java:332)
      at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:134)
      at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:336)
      at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:250)
      at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:69)
      at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:221)


      I have seen few forums that specify a workaround for this for applications that use spring.
      WebLogic 10.0 + JPA 2.0 = errors

      The above forum also specifies that till WL10.3.3, full JPA2.0 support is not available. So does it mean that Hibernate 3.6 based applications won't work at all on WL 10.3.x and have to wait till 10.3.4 is released? Or is there any other solution or patch available for this.
      This is really a high priority issue for us.

      Please suggest.
        • 1. Re: Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn
          obrienmi8
          See the recent OTN post from 20110115 detailing the latest release of Oracle WebLogic Server and some retesting of the previous issues related to JSR-317 JPA 2.0 support below.
          Re: Deploy Hibernate based EAR file on Weblogic 10.3.3?
          The latest release of Oracle WebLogic Server has been available on OTN at the following location since 20110115.
          http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html

          This release provides support for JSR-317 JPA 2.0 container managed applications using the QWG8 patch or a manual prepending classpath change.

          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 as well as the persistence.xml renaming one is now fully deprecated and not required in 10.3.4.0 for both application and container managed persistence contexts.
          As of 20110115 the 5 outstanding issues below look to be fixed by applying the http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch for QWG8 or manually prepending to the WebLogic 10.3.4.0 server 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
          A JPA 2.0 EE application using EclipseLink as the JPA2 persistence provider on WebLogic is detailed in the analysis section below
          1) JPA 2.0 XSD parsing - verified
          2) New JPA 2.0 schema elements like <shared-cache-mode>NONE</shared-cache-mode> - verified
          3) JPA 2.0 runtime API like a entityManager.getMetamodel(); call on the Servlet or Stateless session bean - verified
          4) JPA 2.0 weaving/instrumentation - this will require a more detailed lazy model and more debugging to fully verify
          5) Dependency Injection of a container managed JPA 2.0 entityManager on a EJB component like a stateless session bean - verified
          http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support
          OTN download
          http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.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 documentation/patching
          http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
          EclipseLink Wiki: JPA 2.0 using EclipseLink on WebLogic analysis (XSD, Weaving, DI of @PersistenceContext)
          http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support

          thank you
          /Michael O'Brien
          http://www.eclipselink.org
          • 2. Re: Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn
            746931
            We have a Hibernate (using Hibernate 3.5.x + JPA 1.x) app working in weblogic 10.3.2, 10.3.3 and 10.3.4 using the following:

            1. persistence.xml
            <provider>org.hibernate.ejb.HibernatePersistence</provider>

            2. META-INF/weblogic-application.xml

            <wls:prefer-application-packages>
            <wls:package-name>antlr.*</wls:package-name>
            </wls:prefer-application-packages>

            We are not able to get this app to work with Hibernate 3.6 and JPA 2.x. We followed all of the instructions in the previous post with setting up Weblogic 10.3.4 with JPA 2.0 CLASSPATH. The following errors are observed:

            a. Using the weblogic-application.xml in step 2 above, a method signature error is seen:

            javax/persistence/spi/PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode

            b. Removing antllr and adding org.hibernate.* and/or org.hibernate.ejb.* to step 2 above, the following error is seen:

            Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit nifproposals: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence

            Any ideas?
            • 3. Re: Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn
              user11219675
              This is now working for me!
              Hibernate 3.6, WL 10.3.4 Spring 3.0.5
              The key is putting the following on the 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
              • 4. Re: Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn
                Steve Button-Oracle
                This is documented here, albeit from the context of enabling JPA 2.0 with EclipseLink.

                http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#CIHDJHHI

                We've provided two ways to do this from WLS 10.3.4 onwards:

                1. Download and apply a smartupdate patch, which essentially automates that classpath alteration using a patch to pull in those libraries to the head of the classpath.

                2. Make the same changes manually through the startup scripts or environment variables.

                -steve-
                • 5. Re: Hibernate 3.6 Final (JPA 2.0) + WL 10.3.x :Unable to deploy sample appn
                  819702
                  Indeed this works.
                  This is my classpath (shown when my WL Server starts)
                  CLASSPATH=D:\tools\Oracle\Middleware\modules\javax.persistence_1.0.0.0_2-0-0.jar;D:\tools\Oracle\Middleware\modules\com.oracle.jpa2support_1.0.0.0_2-0.jar;D:\tools\Oracle\MIDDLE~1\patch_wls1035\profiles\default\sys_manifest_classpath\weblogic_patch.jar;D:\tools\Oracle\MIDDLE~1\JDK160~1\lib\tools.jar;D:\tools\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic_sp.jar;D:\tools\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.jar;D:\tools\Oracle\MIDDLE~1\modules\features\weblogic.server.modules_10.3.5.0.jar;D:\tools\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\webservices.jar;D:\tools\Oracle\MIDDLE~1\modules\ORGAPA~1.1/lib/ant-all.jar;D:\tools\Oracle\MIDDLE~1\modules\NETSFA~1.0_1/lib/ant-contrib.jar;D:\tools\Oracle\MIDDLE~1\WLSERV~1.3\common\derby\lib\derbyclient.jar;D:\tools\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\xqrl.jar

                  I manually added this to my *<server_dir>\common\bin\commEnv.cmd* (in the beginning)
                  @rem Enable JPA 2.0 functionality on WebLogic Server
                  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

                  Also, I am using Hibernate JPA2 Provider instead of the EclipseLink bundled in WebLogic. You can achieve that by including the required Hibernate/JPA2 jars in your EAR/WAR and putting this in your META-INF\weblogic-application.xml.
                  <?xml version="1.0" encoding="UTF-8"?>
                  <wls:weblogic-application xmlns:wls="http://xmlns.oracle.com/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/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.2/weblogic-application.xsd">
                  <wls:prefer-application-packages>
                       <wls:package-name>antlr.*</wls:package-name>
                  </wls:prefer-application-packages>
                  </wls:weblogic-application>