-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Prevalence problem
PostPosted: Tue Nov 29, 2005 7:00 pm 
Using Prevalnece cache from NHibernate 1.0.1.0 contribution module I get the following error:

Code:
Line 75:             ICriteria c = session.CreateCriteria(typeof(Module));
Line 76:             
Line 77:             IList l = c.List();


Source File: D:\inetpub\wwwroot\DT\Managers\ModuleManager.cs    Line: 77

Stack Trace:


[IOException: The file "D:\inetpub\wwwroot\DTWeb\cache\00000000000000000002.commandlog" already exists.]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +264
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +877
   NHibernate.Caches.Prevalence.CacheSystem.Add(Object key, Object value) +0
   NHibernate.Caches.Prevalence.PrevalenceCache.Put(Object key, Object value) +225
   NHibernate.Cache.ReadOnlyCache.Put(Object key, Object value, Int64 timestamp, Object version, IComparer versionComparator) +325
   NHibernate.Impl.SessionImpl.InitializeEntity(Object obj) +665
   NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList hydratedObjects, Object resultSetId, ISessionImplementor session) +222
   NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies) +719
   NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies) +75
   NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes) +274
   NHibernate.Loader.CriteriaLoader.List(ISessionImplementor session) +632
   NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria) +378

[ADOException: Unable to perform find]
   NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria) +419
   NHibernate.Impl.CriteriaImpl.List() +12
   DTL.Managers.ModuleManager.List() in D:\inetpub\wwwroot\DT\Managers\ModuleManager.cs:77
   DevTeamWeb.ctlModule.Bind() in D:\inetpub\wwwroot\DTWeb\ctlModule.ascx.cs:44
   DevTeamWeb.ctlModule.Page_Load(Object sender, EventArgs e) in D:\inetpub\wwwroot\DTWeb\ctlModule.ascx.cs:40
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Control.LoadRecursive() +98
   System.Web.UI.Page.ProcessRequestMain() +750


What can be wrong here?


Top
  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 7:31 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Could you post some code (and config and mapping) that produces this error?


Top
 Profile  
 
 Post subject: Re: Problem
PostPosted: Wed Nov 30, 2005 4:46 am 
This problem comes up everywhere where object loads it's bags. All bags have lazy="true" in their definition.


Top
  
 
 Post subject: Re: Problem
PostPosted: Wed Nov 30, 2005 5:07 am 
Well, I found something more. I tried to refresh the page when error occurs. At first cache tries to create file 00000000000000000001.commandlog. If this file exists then exception is thrown. Now, after refresh, cache tries to create file 00000000000000000002.commandlog. If this file exists then exception is thrown. If it doesn't exist then there is no exception and everything works file. On next request, the same problem occurs. Now exceptions are thrown until 00000000000000000002.commandlog. 00000000000000000003.commandlog is created correctly.

But sometimes these errors doesn't occure. I'm not sure what's the problem. I just mention here that my ASP.NET application class is inherited from base class that manages with NHibernate. The library where base classis located contains also all other business classes. My ASP.NET app just uses this library and knows nothing about NHibernate etc. Configuration is hold in my ASP.NET app's web.config and NHibernate has no problems when reading from this config file.


Top
  
 
 Post subject: Fix for prevalance problem
PostPosted: Mon Jan 02, 2006 3:52 pm 
Newbie

Joined: Sat Jul 02, 2005 12:42 pm
Posts: 11
Location: Manchester, UK
I came across the same problem when trying to use the prevalence cache.

If you don't specify the prevalenceBase config setting the cache folders are created under the \bin folder.

However, using the "prevalenceBase" setting to change the cache folder to something else (eg. C:\temp) causes the problem as the separate subfolders for each cache region are not being set / created / used (so the filenames then collide).

To fix it I made the following change to PrevalenceCache.cs:

Code:
private void Configure( IDictionary properties )
{
   string dataDir = Path.Combine( Environment.CurrentDirectory, _region );
   if( properties != null )
   {
      if( properties["prevalenceBase"] != null )
      {
         string prevalenceBase = properties["prevalenceBase"].ToString();
         if( Path.IsPathRooted( prevalenceBase ) )
         {
            dataDir = Path.Combine( prevalenceBase, _region );
         }
         else
         {
            dataDir = Path.Combine( Environment.CurrentDirectory, prevalenceBase );
            dataDir = Path.Combine( dataDir, _region );
         }
      }
   }
   if( Directory.Exists( dataDir ) == false )
   {
      if( log.IsDebugEnabled )
      {
         log.Debug( String.Format( "Data directory {0} doesn't exist: creating it.", dataDir ) );
      }
      Directory.CreateDirectory( dataDir );
   }
   if( log.IsDebugEnabled )
   {
      log.Debug( String.Format( "configuring cache in {0}.", dataDir ) );
   }
   _engine = PrevalenceActivator.CreateTransparentEngine( typeof( CacheSystem ), dataDir );
   _system = _engine.PrevalentSystem as CacheSystem;
}


(Previously the _region was not being added to the dataDir if the prevalenceBase property was set)

This seems to have solved the problem.[/code]

_________________
- Simon

http://www.intesoft.net/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.