Service account throwing SQLiteException on NServiceBus startup
I'm getting the following exception when I try to start nservicebus.host.exe with service account credentials:
Database was not configured through Database method.
System.Data.SQLite.SQLiteException: Unable to open the database file
at System.Data.SQLite.SQLite3.Open(String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool)
at System.Data.SQLite.SQLiteConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection() in :line 0
at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Pr开发者_如何转开发epare() in :line 0
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) in :line 0
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) in :line 0
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) in :line 0
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in D:\dev\fluent-nhibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in D:\dev\fluent-nhibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 100
at NServiceBus.SagaPersisters.NHibernate.Config.Internal.SessionFactoryBuilder.Build(IDictionary^2 nhibernateProperties, Boolean updateSchema) in c:\Dev\DotNet\NServiceBus\src\impl\SagaPersisters\NHibernateSagaPersister\NServiceBus.SagaPersisters.NHibernate.Config\Internal\SessionFactoryBuilder.cs:line 48
--- End of inner exception stack trace ---
at NServiceBus.SagaPersisters.NHibernate.Config.Internal.SessionFactoryBuilder.Build(IDictionary^2 nhibernateProperties, Boolean updateSchema) in c:\Dev\DotNet\NServiceBus\src\impl\SagaPersisters\NHibernateSagaPersister\NServiceBus.SagaPersisters.NHibernate.Config\Internal\SessionFactoryBuilder.cs:line 55
at NServiceBus.ConfigureNHibernateSagaPersister.NHibernateSagaPersister(Configure config, IDictionary^2 nhibernateProperties, Boolean autoUpdateSchema) in c:\Dev\DotNet\NServiceBus\src\impl\SagaPersisters\NHibernateSagaPersister\NServiceBus.SagaPersisters.NHibernate.Config\ConfigureNHibernateSagaPersister.cs:line 80
at Ibfx.BackOffice.Services.NewAccounts.NewAccountsEndpoint.Init() in C:\Dev\TFS\Omega\Src\Svcs\NewAccounts\Src\Service\NewAccountsEndpoint.cs:line 67
at NServiceBus.Host.Internal.GenericHost.Start() in c:\Dev\DotNet\NServiceBus\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 56
Everything works fine if I run the host using my own account, but if I run the host as a service with domain credentials or use those same credentials with the RunAs command I get the above exception. What are the permissions I need to configure so the service will work?
Here's my config:
var configure = NServiceBus.Configure.With()
.Log4Net<Log4NetLoggerAdapter>(a => { })
.UnityBuilder(container)
.XmlSerializer()
.RijndaelEncryptionService()
.MsmqTransport()
.IsTransactional(false)
.PurgeOnStartup(false)
.MsmqSubscriptionStorage();
configure.Configurer.ConfigureComponent<MsmqSubscriptionStorage>(
ComponentCallModelEnum.None).ConfigureProperty(p => p.DontUseExternalTransaction
, true
);
IBus bus = configure.UnicastBus()
.ImpersonateSender(true)
.LoadMessageHandlers()
.Sagas()
.NHibernateSagaPersister()
.CreateBus()
.Start();
And I have a NServiceBus.Host.exe.config file with the following:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration>
What happens when you temporarily give EVERYONE and ANONYMOUS LOGON Full Control over the directory specified? If that solves the exception, it's definitely a security issue. Are you using |DataDirectory| in your connection string? Are you sure the process is actually looking at the directory that you think it's looking at?
Following that, I would try using the SQLite in memory connection string settings to see if it's able to at least create a database and use it:
":memory:;Version=3;New=True;Pooling=True;Max Pool Size=1;"
The above string uses in-memory SQLite but keeps a single connection open so that the tables and data continue to exist until the process exits.
Another strategy that I would use is to change the saga persister to another SQL flavor, such as MS SQL to see if that solves it.
精彩评论