2 Replies Latest reply on Feb 19, 2008 11:23 PM by Neil C

    Persistence Context Configuration On WebLogic 9.2

    Neil C Novice

      I am deploying a Seam-JPA application on WebLogic 9.2.  Here is my persistence unit:



      <persistence-unit name="myWebapp" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>myDS</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
               <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
               <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
            </properties>
      </persistence-unit>



      Here is the relevant portion of my components.xml:



      <persistence:entity-manager-factory name="emf" persistence-unit-name="myWebapp" />
      <persistence:managed-persistence-context name="em" auto-create="true" entity-manager-factory="#{emf}" />
      <transaction:entity-transaction entity-manager="#{em}"/>



      When I deploy my application, I get the following:



      java.lang.IllegalStateException: A JTA EntityManager cannot use getTransaction()
           at org.hibernate.ejb.AbstractEntityManagerImpl.getTransaction(AbstractEntityManagerImpl.java:317)
           at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getTransaction(FullTextEntityManagerImpl.java:166)
           at org.jboss.seam.persistence.EntityManagerProxy.getTransaction(EntityManagerProxy.java:110)
           at org.jboss.seam.transaction.EntityTransaction.getDelegate(EntityTransaction.java:61)
           at org.jboss.seam.transaction.EntityTransaction.begin(EntityTransaction.java:81)
           at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:566)
           at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:307)
           at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:142)
           at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:223)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      19 Feb 2008 16:27:40,491: DEBUG org.hibernate.jdbc.JDBCContext - TransactionFactory reported no active transaction; Synchronization not registered
      19 Feb 2008 16:27:40,491: DEBUG org.hibernate.impl.SessionImpl - setting flush mode to: AUTO
      



      I definitely have something wrong with my configuration.  Any insight on what I need to change is appreciated.


      Thanks.

        • 1. Re: Persistence Context Configuration On WebLogic 9.2
          Jay Balunas Novice

          Hello,


          When you use


          <transaction:entity-transaction entity-manager="#{em}"/>



          Seam will attempt to use JPA transactions, but your persistence.xml states JTA transactions.  Try putting RESOURCE_LOCAL in for the persistence.xml to actually use JPA.


          Take a look at the JPA examples for examples of using JPA transactions or check the docs. 


          If you got configuration from an existing example please let me know which one.


          Thanks,
          Jay

          • 2. Re: Persistence Context Configuration On WebLogic 9.2
            Neil C Novice

            Thanks, Jay.  Everything is working now.  I was relying primarily on two sources: the WebLogic JPA example that came with 2.0.0 GA and Michael Yuan's book. 


            Here is the persistence.xml from the example:



            <?xml version="1.0" encoding="UTF-8"?>
            <persistence>
               <persistence-unit name="bookingDatabase" transaction-type="JTA">
                  <provider>org.hibernate.ejb.HibernatePersistence</provider>
                  <jta-data-source>examples-dataSource-demoPool</jta-data-source>
                  <properties>
                      <property name="hibernate.dialect" 
                                value="org.hibernate.dialect.PointbaseDialect"/>
                     <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                     <property name="hibernate.show_sql" value="true"/>
                     <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                     <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
                     <!-- alternative
                     <property name="jboss.entity.manager.factory.jndi.name" 
                          value="java:/jpaBookingEntityManagerFactory"/>
                     -->
                  </properties>
               </persistence-unit>
            </persistence>



            Now time for me to do some research as to what RESOURCE LOCAL actually means.


            Thanks.