title: RavenDB deployment issue
body: <p>I have an ASP.Net MVC 3 app that I've developed which uses RavenDB Embedded as an integrated backing store for data, I used <a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=787">this</a> tutorial as a basis for getting started creating an MVC app with RavenDB Embedded.  I've been able to run it fine on my development PC, but when it came time to deploy it on our Windows Server 2003 web server running IIS6 it threw the following error:</p>
  
  <blockquote>
    <p>Cannot access file, the file is locked or in use  Description: An
    unhandled exception occurred during the execution of the current web
    request. Please review the stack trace for more information about the
    error and where it originated in the code. </p>
    
    <p>Exception Details:
    Microsoft.Isam.Esent.Interop.EsentFileAccessDeniedException: Cannot
    access file, the file is locked or in use</p>
    
    <p>Source Error: </p>
    
    <p>An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.</p>
    
    <p>Stack Trace: </p>
    
    <p>[EsentFileAccessDeniedException: Cannot access file, the file is
    locked or in use]    Microsoft.Isam.Esent.Interop.Api.Check(Int32 err)
    in
    C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Api.cs:2736
    Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator
    uuidGenerator) in
    c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:207</p>
    
    <p>[InvalidOperationException: Could not open transactional storage:
    C:\inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]<br>
    Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator
    uuidGenerator) in
    c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:222
    Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration
    configuration) in
    c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:185<br>
    Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in
    c:\Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddableDocumentStore.cs:143
    Raven.Client.Document.DocumentStore.Initialize() in
    c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentStore.cs:496
    MyApp.CompositionRoot.CreateControllerFactory() in
    ...\MyApp\CompositionRoot.cs:36    MyApp.CompositionRoot..ctor() in
    ..\MyApp\CompositionRoot.cs:17<br>
    MyApp.MvcApplication.Application_Start() in ...MyApp\Global.asax.cs:38</p>
    
    <p>[HttpException (0x80004005): Could not open transactional storage:
    C:\inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]<br>
    System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
    context, HttpApplication app) +3985477<br>
    System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
    appContext, HttpContext context, MethodInfo[] handlers) +191<br>
    System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
    MethodInfo[] handlers, IntPtr appContext, HttpContext context) +325<br>
    System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
    appContext, HttpContext context) +407<br>
    System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
    appContext) +375</p>
    
    <p>[HttpException (0x80004005): Could not open transactional storage:
    C:\inetpub\wwwroot\MyApp\App_Data\Database\RavenDB\Data]<br>
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
    +141    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
    wr, HttpContext context) +4782309</p>
  </blockquote>
  
  <p>The source of the error in the referenced CompositionRoot.cs class is when the initialization of the Embeddable Document Store.</p>
  
  <pre><code>private static IControllerFactory CreateControllerFactory()
  {
      var cacheRepository = new EmbeddableDocumentStore();
      cacheRepository.ConnectionStringName = "RavenDB";
  
      #if DEBUG
          cacheRepository.UseEmbeddedHttpServer = true;
      #endif
  
      Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8080);
      cacheRepository.Initialize(); //Source of Error
      var controllerFactory = new TDRControllerFactory(cacheRepository);
      return controllerFactory;
  }
  </code></pre>
  
  <p>Why is this only happening on the web server and not on my development PC?  I'm not sure what the exact cause might be.  Any help is appreciated.</p>