I'm building a web app based on Hibernate, Spring and MDB. I'm using JTA transaction manager on WebLogic 8.1 and Oracle 9i XA data source. WebLogic "Supports Local Transactions" is set to true to enable Hibernate lazy loading.
All is fine until I hit a page that renders data that is lazy-loaded by Hibernate. The page itself is loaded fine, however when I try to go to any other page that loads data from database I'm getting the exception below.
I'm not transaction stuff expert but I suspect that the issue is related to lazy loading and the fact that this operation doesn't occurs within a global transaction.
I put also the Hibernate config from Spring's applicationContext.xml.
Please help!!!
/Slawek
-- exception --
org.springframework.jdbc.UncategorizedSQLException: (Hibernate operation): encountered SQLException [Unexpected exception while enlisting XAConnection java.sql.SQLException: XA error: XAER_PROTO : Routine was invoked in an inproper context start() failed on resource 'xa_scott_at_zachcial': XAER_PROTO : Routine was invoked in an inproper context
javax.transaction.xa.XAException
at oracle.jdbc.xa.OracleXAResource.disallowLocalTxnMode(OracleXAResource.java:1045)
at oracle.jdbc.xa.client.OracleXAResource.start(OracleXAResource.java:153)
at weblogic.jdbc.wrapper.VendorXAResource.start(VendorXAResource.java:50)
at weblogic.jdbc.jta.DataSource.start(DataSource.java:629)
at weblogic.transaction.internal.XAServerResourceInfo.start(XAServerResourceInfo.java:1103)
at weblogic.transaction.internal.XAServerResourceInfo.xaStart(XAServerResourceInfo.java:1035)
at weblogic.transaction.internal.XAServerResourceInfo.enlist(XAServerResourceInfo.java:213)
at weblogic.transaction.internal.ServerTransactionImpl.enlistResource(ServerTransactionImpl.java:461)
at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1383)
at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1325)
at weblogic.jdbc.jta.DataSource.getConnection(DataSource.java:396)
at weblogic.jdbc.jta.DataSource.connect(DataSource.java:354)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:305)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:75)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:424)
at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:149)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:95)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:86)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1125)
at org.hibernate.loader.Loader.doQuery(Loader.java:369)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.doList(Loader.java:1557)
at org.hibernate.loader.Loader.list(Loader.java:1540)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:812)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:803)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:795)
at p3.user.hibernate.HUserDAO.getAllUsers(HUserDAO.java:47)
at p3.user.UserManagerImpl.findAllUsers(UserManagerImpl.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy14.findAllUsers(Unknown Source)
at p3.web.LoginFormAction.execute(LoginFormAction.java:25)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:105)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at com.hp.bco.pl.wpa.action.WPARequestProcessor.process(WPARequestProcessor.java:188)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.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$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at p3.web.AuthenticationFilter.doFilter(AuthenticationFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at com.hp.bco.pl.wpa.filter.transactionlogging.TransactionLoggingFilter.doFilter(TransactionLoggingFilter.java:67)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6458)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
-- config --
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/myDS" />
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager"/>
<bean id="jtaTransactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="javax.transaction.TransactionManager" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<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.Oracle9Dialect</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>-->
<prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</prop>
</props>
</property>
<property name="jtaTransactionManager" ref="jtaTransactionManager" />
<property name="dataSource" ref="dataSource" />
</bean>
|