Note that there are some explanatory texts on larger screens.

plurals
  1. PONhibernate Error: BuidSessionFactory() Deadlock / Dropping Connection
    primarykey
    data
    text
    <p>Good afternoon,</p> <p>I have been stuck on this issue for a number of days now and I don't feel my understanding of Nhibernate / SQL Server is of enough so that I might figure it out.</p> <p>The issue is that any unit test that involves making a call to:</p> <pre><code>Nhibernate.Cfg.Configuaration.BuildSessionFactory(); </code></pre> <p>Just becomes stuck in a running state, I am forced to press 'Stop' in order to get NUnit to respond. At which point an error dialogue appears with the following information:</p> <p>"No connection could be made because the target machine actively refused it"</p> <p>With the "exception text" being;</p> <pre><code> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:51293 Server stack trace: at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint) at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket() at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew) at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream) at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders&amp; responseHeaders, Stream&amp; responseStream) at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type) at NUnit.Core.TestRunner.get_Running() at NUnit.Core.ProxyTestRunner.get_Running() at NUnit.Util.TestLoader.get_Running() at NUnit.Gui.NUnitForm.get_IsTestRunning() at NUnit.Gui.NUnitForm.CancelRun() at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message&amp; m) at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m) at System.Windows.Forms.Button.WndProc(Message&amp; m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) </code></pre> <p>My NHibernate is configured like so;</p> <pre><code>&lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"&gt; &lt;session-factory&gt; &lt;property name="connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt; &lt;property name="dialect"&gt;NHibernate.Dialect.MsSql2008Dialect&lt;/property&gt; &lt;property name="connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt; &lt;property name="connection.connection_string"&gt;Server=MachineName\SQLEXPRESS;database=TestingDB;Integrated Security=true;&lt;/property&gt; &lt;property name ="proxyfactory.factory_class"&gt;NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu&lt;/property&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; </code></pre> <p>and with the TestFixtureSetup calling the following:</p> <pre><code>_configuration.Configure(); _configuration.AddAssembly(typeof(MyClass).Assembly); _sessionFactory = _configuration.BuildSessionFactory(); </code></pre> <p>The test simply hangs on the final line. To try and understand what is going wrong, I enabled log4net which gave the following output when running a test.</p> <pre><code>[TestRunnerThread] INFO NHibernate.Cfg.Environment - NHibernate 2.1.2.4000 (2.1.2.4000) [TestRunnerThread] INFO NHibernate.Cfg.Environment - hibernate-configuration section not found in application configuration file [TestRunnerThread] INFO NHibernate.Cfg.Environment - Bytecode provider name : lcg [TestRunnerThread] INFO NHibernate.Cfg.Environment - Using reflection optimizer [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.provider=NHibernate.Connection.DriverConnectionProvider [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - dialect=NHibernate.Dialect.MsSql2008Dialect [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.driver_class=NHibernate.Driver.SqlClientDriver [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - connection.connection_string=Server=MachineName\SQLEXPRESS;database=MySolution_Testing;Integrated Security=true; [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - proxyfactory.factory_class=NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - show_sql=true [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - properties: System.Collections.Generic.Dictionary`2[System.String,System.String] [TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.MenuItem.hbm.xml [TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect [TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.MenuItem -&gt; MenuItems [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -&gt; MenuItemID, type: Int32 [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Name -&gt; MenuItemName, type: String [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ControllerName -&gt; MenuItemController, type: String [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ActionName -&gt; MenuItemAction, type: String [TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.Perspective.hbm.xml [TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect [TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.UserPerspective -&gt; Perspectives [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -&gt; PerspectiveID, type: Int32 [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Name -&gt; PerspectiveName, type: String [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Description -&gt; PerspectiveDescription, type: String [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Password -&gt; PerspectivePassword, type: String [TestRunnerThread] INFO NHibernate.Cfg.Configuration - Mapping resource: MySolution.Models.Mappings.ViewGroup.hbm.xml [TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect [TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - Mapping class: MySolution.Models.ViewGroup -&gt; ViewGroups [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: ID -&gt; ViewGroupID, type: Int32 [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: Perspective -&gt; Link_PerspectiveID, type: MySolution.Models.UserPerspective [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped property: MenuItems, type: Iesi.Collections.Generic.ISet`1[[MySolution.Models.MenuItem, MySolution.Models, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](MySolution.Models.ViewGroup.MenuItems) [TestRunnerThread] INFO NHibernate.Cfg.Configuration - checking mappings queue [TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing one-to-many association mappings [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Second pass for collection: MySolution.Models.ViewGroup.MenuItems [TestRunnerThread] INFO NHibernate.Cfg.XmlHbmBinding.Binder - mapping collection: MySolution.Models.ViewGroup.MenuItems -&gt; MenuItems [TestRunnerThread] DEBUG NHibernate.Cfg.XmlHbmBinding.Binder - Mapped collection key: MenuItemID, one-to-many: MySolution.Models.MenuItem [TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing one-to-one association property references [TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing foreign key constraints [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - resolving reference to class: MySolution.Models.ViewGroup [TestRunnerThread] DEBUG NHibernate.Cfg.Configuration - resolving reference to class: MySolution.Models.UserPerspective [TestRunnerThread] INFO NHibernate.Cfg.Configuration - processing filters (second pass) [TestRunnerThread] INFO NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2008Dialect [TestRunnerThread] INFO NHibernate.Exceptions.SQLExceptionConverterFactory - Using dialect defined converter [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Generate SQL with comments: disabled [TestRunnerThread] INFO NHibernate.Connection.ConnectionProviderFactory - Initializing connection provider: NHibernate.Connection.DriverConnectionProvider [TestRunnerThread] INFO NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Transaction factory: NHibernate.Transaction.AdoNetWithDistrubtedTransactionFactory [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Optimize cache for minimal puts: False [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Connection release mode: auto [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Default batch fetch size: 1 [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - echoing all SQL to stdout [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Statistics: disabled [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Query translator: NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Query language substitutions: {} [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.NoCacheProvider, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4 [TestRunnerThread] DEBUG NHibernate.Cfg.SettingsFactory - Wrap result sets: disabled [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Batcher factory: NHibernate.AdoNet.NonBatchingBatcherFactory, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4 [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Default entity-mode: Poco [TestRunnerThread] INFO NHibernate.Cfg.SettingsFactory - Named query checking : enabled [TestRunnerThread] INFO NHibernate.Impl.SessionFactoryImpl - building session factory [TestRunnerThread] DEBUG NHibernate.Impl.SessionFactoryImpl - Session factory constructed with filter configurations : {} [TestRunnerThread] DEBUG NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {'use_reflection_optimizer'='True', 'connection.provider'='NHibernate.Connection.DriverConnectionProvider', 'dialect'='NHibernate.Dialect.MsSql2008Dialect', 'connection.driver_class'='NHibernate.Driver.SqlClientDriver', 'connection.connection_string'='Server=MachineName\SQLEXPRESS;database=MySolution_Testing;Integrated Security=true;', 'proxyfactory.factory_class'='NHibernate.ByteCode.LinFu.ProxyFactoryFactory, Nhibernate.ByteCode.LinFu', 'show_sql'='true'} [TestRunnerThread] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver [TestRunnerThread] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection </code></pre> <p>As you can see, NHibernate seems to configure it self correctly, however, the final two lines seem to suggest that when a connection is actually asked for, something errors and it is all closed off. This is not reported back to NUnit and so it just sits there waiting indefinitely for a valid connection to use. </p> <p>I have other projects that use a Fluent configuration that seem to function correctly, but these older projects use a SQL Compact database not SQL Express.</p> <p>Is anyone able to suggest a solution to this issue ?</p> <p>Thank you for your time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload