Announcement Announcement Module
Collapse
No announcement yet.
Hibernate and JTA on WebLogic - doesn't work ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate and JTA on WebLogic - doesn't work ?

    Hi,

    I'm evaluating Spring/Hibernate combo. My "vertical slice" app is a mini message board with a classic layered architecture: presentation - Struts, biz layer - Spring-managed beans, data access - Hibernate.

    All worked fine with HibernateTransactionManager and non-JNDI data source. But when I switched to JtaTransactionManager and JNDI-bound data source I'm getting the exception below.

    From the trace below you can see that a transactional object MessageBoardImpl calls another tx object - ACLEntryManagerImpl, that in turns calls HACLEntryDAO.

    I include also my applicationContext.xml file.

    I'm using JDK 1.4.2, WebLogic 8.1.3 on Win XP. I found that other folks had the same problem but in different conditions. It seems like it's specific to WebLogic. Unfortunately, I didn't find any answer for that.

    Can anyone please tell me what's wrong with what I'm doing? I know that String/Hibernate and JTA work fine and I'm sure that it's sth wrong with my code.

    Thanks,
    /Slawek

    --- Exception stack trace ---
    Error occured:

    org.springframework.jdbc.UncategorizedSQLException : (Hibernate operation): encountered SQLException [The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.]; nested exception is java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
    java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
    at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledB ack(JTSConnection.java:155)
    at weblogic.jdbc.wrapper.JTSConnection.checkConnectio n(JTSConnection.java:164)
    at weblogic.jdbc.wrapper.Connection.prepareStatement( Connection.java:347)
    at weblogic.jdbc.wrapper.JTSConnection.prepareStateme nt(JTSConnection.java:479)
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStat ement(AbstractBatcher.java:379)
    at org.hibernate.jdbc.AbstractBatcher.getPreparedStat ement(AbstractBatcher.java:320)
    at org.hibernate.jdbc.AbstractBatcher.prepareQuerySta tement(AbstractBatcher.java:86)
    at org.hibernate.loader.Loader.prepareQueryStatement( Loader.java:1096)
    at org.hibernate.loader.Loader.doQuery(Loader.java:36 7)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Loader.java:208)
    at org.hibernate.loader.Loader.doList(Loader.java:152 2)
    at org.hibernate.loader.Loader.list(Loader.java:1505)
    at org.hibernate.hql.classic.QueryTranslatorImpl.list (QueryTranslatorImpl.java:883)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:791)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:7 4)
    at org.springframework.orm.hibernate3.HibernateTempla te$34.doInHibernate(HibernateTemplate.java:849)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:310)
    at org.springframework.orm.hibernate3.HibernateTempla te.findByNamedQueryAndValueBean(HibernateTemplate. java:844)
    at p3.acl.hibernate.HACLEntryDAO.getEntriesForAccesso r(HACLEntryDAO.java:26)
    at p3.acl.ACLEntryManagerImpl.findResourceIDs(ACLEntr yManagerImpl.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:310)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:155)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :122)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:57)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy13.findResourceIDs(Unknown Source)
    at p3.mb.MessageBoardImpl.findTopicsForAccount(Messag eBoardImpl.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:310)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:155)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :122)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:57)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174)
    at $Proxy14.findTopicsForAccount(Unknown Source)
    at p3.web.TopicListAction.execute(TopicListAction.jav a:59)
    at org.springframework.web.struts.DelegatingActionPro xy.execute(DelegatingActionProxy.java:105)
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:484)
    at com.hp.bco.pl.wpa.action.WPARequestProcessor.proce ss(WPARequestProcessor.java:188)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doGet(Actio nServlet.java:507)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletI nvocationAction.run(ServletStubImpl.java:996)
    at weblogic.servlet.internal.ServletStubImpl.invokeSe rvlet(ServletStubImpl.java:419)
    at weblogic.servlet.internal.TailFilter.doFilter(Tail Filter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at p3.web.AuthenticationFilter.doFilter(Authenticatio nFilter.java:36)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at com.hp.bco.pl.wpa.filter.transactionlogging.Transa ctionLoggingFilter.doFilter(TransactionLoggingFilt er.java:67)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at org.springframework.orm.hibernate3.support.OpenSes sionInViewFilter.doFilterInternal(OpenSessionInVie wFilter.java:172)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at weblogic.servlet.internal.FilterChainImpl.doFilter (FilterChainImpl.java:27)
    at weblogic.servlet.internal.WebAppServletContext$Ser vletInvocationAction.run(WebAppServletContext.java :6458)
    at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.inv okeServlet(WebAppServletContext.java:3661)
    at weblogic.servlet.internal.ServletRequestImpl.execu te(ServletRequestImpl.java:2630)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)

    --- applicationContext.xml ---
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans default-lazy-init="true">

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName"><value>jdbc/B2BTechStudyDS</value></property>
    </bean>

    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTran sactionManager"/>

    <!--
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>classpath:jdbc.properties</value>
    </list>
    </property>
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"><value>oracle.jdbc.OracleDr iver</value></property>
    <property name="url"><value>${jdbc.url}</value></property>
    <property name="username"><value>${jdbc.username}</value></property>
    <property name="password"><value>${jdbc.password}</value></property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
    -->

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="mappingResources">
    <list>
    <value>p3/account/hibernate/Account.hbm.xml</value>
    <value>p3/user/hibernate/User.hbm.xml</value>
    <value>p3/acl/hibernate/ACLEntry.hbm.xml</value>
    <value>p3/mb/hibernate/MessageBoard.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.Orac le9Dialect</prop>
    <!-- This property is required as WLS uses ANTLR and H3 also - there is some classloading issue with that -->
    <prop key="hibernate.query.factory_class">org.hibernate. hql.classic.ClassicQueryTranslatorFactory</prop>
    <!--<prop key="hibernate.show_sql">true</prop>-->
    </props>
    </property>
    <property name="dataSource"><ref bean="dataSource"/></property>
    </bean>

    <bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName"><value>jms/MyConnectionFactory</value></property>
    </bean>

    <bean id="messagePostedQueue" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName"><value>jms/MessagePostNotificationQueue</value></property>
    </bean>

    <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"
    abstract="true">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="create*">PROPAGATION_REQUIRED</prop>
    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
    </props>
    </property>
    </bean>

    <bean id="accountDAO" class="p3.account.hibernate.HAccountDAO">
    <property name="sessionFactory"><ref local="sessionFactory" /></property>
    </bean>

    <bean id="userDAO" class="p3.user.hibernate.HUserDAO">
    <property name="sessionFactory"><ref local="sessionFactory" /></property>
    </bean>

    <bean id="aclEntryDAO" class="p3.acl.hibernate.HACLEntryDAO">
    <property name="sessionFactory"><ref local="sessionFactory" /></property>
    </bean>

    <bean id="messageBoardDAO" class="p3.mb.hibernate.HMessageBoardDAO">
    <property name="sessionFactory"><ref local="sessionFactory" /></property>
    </bean>

    <bean id="accountManagerTarget" class="p3.account.AccountManagerImpl">
    <property name="accountDAO"><ref bean="accountDAO" /></property>
    </bean>

    <bean id="accountManager" parent="baseTransactionProxy">
    <property name="target"><ref bean="accountManagerTarget" /></property>
    </bean>

    <bean id="userManagerTarget" class="p3.user.UserManagerImpl">
    <property name="userDAO"><ref bean="userDAO" /></property>
    </bean>

    <bean id="userManager" parent="baseTransactionProxy">
    <property name="target"><ref bean="userManagerTarget" /></property>
    </bean>

    <bean id="aclEntryManagerTarget" class="p3.acl.ACLEntryManagerImpl">
    <property name="ACLEntryDAO"><ref bean="aclEntryDAO" /></property>
    </bean>

    <bean id="aclEntryManager" parent="baseTransactionProxy">
    <property name="target"><ref bean="aclEntryManagerTarget" /></property>
    </bean>

    <bean id="messageNotifier" class="p3.mb.JMSMessageNotifierImpl">
    <property name="connectionFactory"><ref bean="jmsConnectionFactory"/></property>
    <property name="queue"><ref bean="messagePostedQueue" /></property>
    </bean>

    <bean id="messageBoardTarget" class="p3.mb.MessageBoardImpl">
    <property name="messageBoardDAO"><ref bean="messageBoardDAO" /></property>
    <property name="ACLEntryManager"><ref bean="aclEntryManager" /></property>
    <property name="notifier"><ref bean="messageNotifier" /></property>
    </bean>

    <bean id="messageBoard" parent="baseTransactionProxy">
    <property name="target"><ref bean="messageBoardTarget" /></property>
    </bean>
    </beans>
Working...
X