I saw this exception in Spring 1.0.2+NHibernate 1.2 and it's still exist in Spring 1.2+NHibernate 2.0.
When using IIS, Spring (WebServiceExporter), NHibernate and Oracle sometimes I catch this Exception in my project: (with stack trace of inner exceptions)
Part of server config. It uses .Net Remoting, but it doesn't matter, Exception is still here:Code:CannotCreateTransactionException: Could not open Hibernate Session for transaction at Spring.Data.NHibernate.HibernateTransactionManager.DoBegin(Object transaction, ITransactionDefinition definition) at Spring.Transaction.Support.AbstractPlatformTransactionManager.GetTransaction(ITransactionDefinition definition) at Spring.Transaction.Interceptor.TransactionAspectSupport.CreateTransactionIfNecessary(ITransactionAttribute sourceAttr, String joinpointIdentification) at Spring.Transaction.Interceptor.TransactionAspectSupport.CreateTransactionIfNecessary(MethodInfo method, Type targetType) at Spring.Transaction.Interceptor.TransactionInterceptor.Invoke(IMethodInvocation invocation) at Spring.Aop.Framework.AbstractMethodInvocation.Proceed() at Usp.Mls.Services.Facade.Aop.WebServiceMethodInterceptor.Invoke(IMethodInvocation invocation) at Spring.Aop.Framework.AbstractMethodInvocation.Proceed() at Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.Invoke(IMethodInvocation invocation) TransactionException: Begin failed with SQL exception at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel) at NHibernate.Impl.SessionImpl.BeginTransaction(IsolationLevel isolationLevel) at Spring.Data.NHibernate.HibernateTransactionManager.DoBegin(Object transaction, ITransactionDefinition definition) OracleException: ORA-01453: SET TRANSACTION must be first statement of transaction. at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc) at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals) at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor) at System.Data.OracleClient.OracleCommand.ExecuteNonQuery() at System.Data.OracleClient.OracleTransaction..ctor(OracleConnection connection, IsolationLevel isolationLevel) at System.Data.OracleClient.OracleInternalConnection.BeginOracleTransaction(IsolationLevel il) at System.Data.OracleClient.OracleInternalConnection.BeginTransaction(IsolationLevel il) at System.Data.OracleClient.OracleConnection.BeginDbTransaction(IsolationLevel isolationLevel) at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransaction(IsolationLevel isolationLevel) at NHibernate.Transaction.AdoTransaction.Begin(IsolationLevel isolationLevel) Server stack trace: at Usp.Mls.Services.Facade.Aop.ExceptionHandlerAdvice.AfterThrowing(MethodInfo method, Object[] args, Object target, Exception e) at Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.InvokeHandlerMethod(IMethodInvocation invocation, Exception triggeringException, MethodInfo handlerMethod) at Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.LookupAndInvokeAnyHandler(Exception ex, IMethodInvocation invocation) at Spring.Aop.Framework.Adapter.ThrowsAdviceInterceptor.Invoke(IMethodInvocation invocation) at Spring.Aop.Framework.AbstractMethodInvocation.Proceed() at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Invoke(Object proxy, Object target, Type targetType, MethodInfo targetMethod, MethodInfo proxyMethod, Object[] args, IList interceptors) at CompositionAopProxy_e6d74c44d2194451924342247a8a0ca1.ReadPlaceLicences(Int64 id, RemoteCallContextDTO callContext) at SaoRemoteObjectProxy_60e527da1dfc45688e5991b35952ebf1.ReadPlaceLicences(Int64 id, RemoteCallContextDTO callContext) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext) Exception rethrown at [0]: at Usp.Mls.Presentation.Aop.WebServiceMethodInterceptor.Invoke(IMethodInvocation invocation) at Spring.Aop.Framework.AbstractMethodInvocation.Proceed() at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Invoke(Object proxy, Object target, Type targetType, MethodInfo targetMethod, MethodInfo proxyMethod, Object[] args, IList interceptors) at CompositionAopProxy_b190003f8e3440c7811f723a10a80401.ReadPlaceLicences(Int64 id, RemoteCallContextDTO callContext) at Usp.Mls.Presentation.MainModule.Controls.AdministrativeObjectViews.PlaceView.PlaceLicenceViewControl.PlaceLicenceViewControl.UpdateControl(Int64 placeId) at ...some client code
I can't reproduce this exception, but I see it very often, especially when debugging a lot. Where is my problem? Am I doing something wrong, or it's Spring.Net/NHibernate error?Code:<object id="TxProxyTemplate" type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data" abstract="true"> <property name="PlatformTransactionManager"> <ref object="TransactionManager" /> </property> <property name="TransactionAttributes"> <name-values> <add key="*" value="PROPAGATION_REQUIRED" /> </name-values> </property> <property name="PreInterceptors"> <list> <ref local="ExceptionHandlerAdvice"/> <!-- no db/service usage here --> <ref local="WebServiceMethodInterceptor"/> <!-- no db/service usage here --> </list> </property> </object> <object id="PlaceServiceExporter" lazy-init="false" type="Spring.Remoting.SaoExporter, Spring.Services"> <property name="TargetName" value="PlaceServiceProxy"/> <property name="ServiceName" value="PlaceService.rem" /> <property name="Infinite" value="true" /> </object> <object id="PlaceServiceProxy" parent="TxProxyTemplate"> <property name="Target"> <object type="Usp.Mls.Services.Facade.PlaceService, Usp.Mls.Services"> <property name="PlaceDescriptionDao" ref="PlaceDescriptionDao" /> ... </object> </property> </object> <object singleton="true" id="SessionFactory" type="Usp.Mls.DataAccess.DelegatingLocalSessionFactoryObject, Usp.Mls.DataAccess"> <!-- same problem with LocalSessionFactoryObject --> <property name="MappingAssemblies"> <list> <value>Usp.Mls.DataAccess</value> </list> </property> <property name="DbProvider" ref="MainDbProvider" /> <property name="HibernateProperties"> <dictionary> <entry key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider" /> <entry key="dialect" value="NHibernate.Dialect.Oracle9Dialect" /> <entry key="connection.driver_class" value="NHibernate.Driver.OracleClientDriver" /> <entry key="connection.isolation" value="ReadCommitted" /> <entry key="hibernate.show_sql" value="true" /> </dictionary> </property> </object> <object id="MainDbProvider" type="Usp.Mls.Services.DBProviders.CustomDBProvider, Usp.Mls.Services"> <constructor-arg value="System.Data.OracleClient"/> <constructor-arg value="Data Source=DSource;Persist Security Info=True;User ID=TEST_USER;Password=TEST_PASSWORD"/> <constructor-arg value="DB Name"/> </object>
Sometimes only restart of web service(ie:Web.Config change) helps to temporary fix the problem when it appear too often. It looks like there is a problem with connections pool.


Reply With Quote