Hi!
I'm developing an application based on Hibernate 3.3.1 and Spring 2.5 with JTA transactions provided by JTOM.
I'm getting the following exception when trying to invoke a data access operation from a Spring bean:
Code:
java.lang.reflect.UndeclaredThrowableException
at $Proxy9.invoke(Unknown Source)
at org.mc4j.console.bean.operation.OperationExecutionResultsVisualPanel$2.run(OperationExecutionResultsVisualPanel.java:126)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.reflect.InvocationTargetException
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:585)
at org.mc4j.console.connection.proxy.JMXRemotingMBeanServerProxy.invoke(JMXRemotingMBeanServerProxy.java:61)
... 3 more
Caused by: javax.management.RuntimeErrorException: Error occured in RequiredModelMBean while trying to invoke operation queryTheme
at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1092)
at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:953)
at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1341)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
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:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:972)
... 8 more
Caused by: java.lang.StackOverflowError
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.naming.internal.VersionHelper12.getContextClassLoader(VersionHelper12.java:158)
at com.sun.naming.internal.ResourceManager.getFactory(ResourceManager.java:339)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:575)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:533)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:279)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:162)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:172)
at
...
This results in a StackOverflowException caused due to a bug in Hibernate 3.3.1 (see
http://opensource.atlassian.com/proj...rowse/HHH-3481).
The exception is caused because Hibernate can't find the java:comp/UserTransaction
The Hibernate operation is called from a service layer bean that it is invoked from another Spring bean that is exposed as JMX MBean. Transactions are applied with Spring AOP to the operation defined in the service layer.
Here are the hibernate configuration properties:
Code:
<value>
hibernate.dialect=org.hibernate.dialect.Oracle9iDialect
hibernate.transaction.factory_class = org.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JOTMTransactionManagerLookup
hibernate.generate_statistics=true
hibernate.cache.use_structured_entries=true
</value>
Here are the logs I get grom Spring and Hibernate:
Code:
2008-11-06 09:51:10,625 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Using transaction object [org.springframework.transaction.jta.JtaTransactionObject@12e79d0]
2008-11-06 09:51:10,625 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Creating new transaction with name [ThemeProvisioningService.queryTheme]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2008-11-06 09:51:10,625 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Initializing transaction synchronization
2008-11-06 09:51:10,625 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Getting transaction for [ThemeProvisioningService.queryTheme]
2008-11-06 09:51:10,625 DEBUG [ThemeProvisioningServiceImp] Retrieving theme with themeID: 100
2008-11-06 09:51:10,625 DEBUG [ThemeProvisioningServiceImp] Retrieving theme with themeID: 100
2008-11-06 09:51:10,640 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Opening Hibernate Session
2008-11-06 09:51:10,640 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 12259614706
2008-11-06 09:51:10,640 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] Registering Spring transaction synchronization for new Hibernate Session
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.interceptor.TransactionInterceptor] Completing transaction for [ThemeProvisioningService.queryTheme] after exception: java.lang.StackOverflowError
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] Applying rules to determine whether transaction should rollback on java.lang.StackOverflowError
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] Winning rollback rule is: null
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.interceptor.RuleBasedTransactionAttribute] No relevant rollback rule found: applying default rules
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Triggering beforeCompletion synchronization
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Initiating transaction rollback
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.jta.JtaTransactionManager] Triggering afterCompletion synchronization
2008-11-06 09:51:11,968 DEBUG [org.springframework.transaction.support.TransactionSynchronizationManager] Clearing transaction synchronization
The fact is that the application was working perfectly with Hibernate 3.2.5 version till I updated it to 3.3.1. I need to use Hibernate 3.3.1 because I want to add second cache support based on JBossCache (which is not supported with earlier versions).
I've tried the same data access operation invocation though web services in the application and then it works perfectly. The same happens with HTTP request operations.
It is the JMX invocation wich fails although they are all effectuated though the same sevice layer (ThemeProvisioningService).
Any idea will be greatly appreciated.
Thanks in advance.