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: Problem in guts of NHibernate
PostPosted: Fri Jun 22, 2007 4:19 pm 
Newbie

Joined: Fri Jun 22, 2007 4:06 pm
Posts: 2
Hi,

I am using NHibernate 1.2 for connecting MS Sql Server 2005 database.
At one place in code I am calling session.Save for one of my entity object.
This works for few hours and gets records inserted into Database but after
4-5 hours of inserting it throws an error which seems to be in guts of NHibernate code. It seems that Save method of Hibernate source is calling
System.String.CopyTo in its guts and the argument "count" is being passed as less than zero.

See below error stack,
[2007-06-18 00:00:03][Error ][Navis.Common.Core.Logger]NHibernate.ADOException: could not insert: [Navis.Common.Entity.SAICHost][SQL: INSERT INTO saic_host (msg_id, msg_time, msg_type, asset_id, ocr_obj_ref, ocr_obj_ctr1, ocr_obj_ctr2, ocr_obj_chs, ocr_obj_gen1, ocr_obj_gen2, trolleyvalue, hoistvalue, message, creator, created, changer, changed, processed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)] ---> System.ArgumentOutOfRangeException: Count cannot be less than zero.
Parameter name: count
at System.String.CopyTo(Int32 sourceIndex, Char[] destination, Int32 destinationIndex, Int32 count)
at System.IO.StreamWriter.Write(String value)
at System.IO.TextWriter.SyncTextWriter.Write(String value)
at NHibernate.Impl.BatcherImpl.LogCommand(IDbCommand command)
at NHibernate.Impl.BatcherImpl.Prepare(IDbCommand cmd)
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledIdentityInsertion.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.DoSave(Object theObj, EntityKey key, IEntityPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IEntityPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
at NHibernate.Impl.SessionImpl.Save(Object obj)
at Navis.Common.Consumer.DBConsumer.DBConsumer.ProcessSAICHost(Object obj, EventArgs evargs)

The code part, which does this is,

ISession session = null;
ITransaction transaction = null;
try
{
session = DatabaseHelper.GetNewSession();
transaction = session.BeginTransaction();

SAICHost inSAICHost = obj as SAICHost;
if (inSAICHost != null)
{
session.Save(inSAICHost);
}
}
catch (Exception e)
{
if (transaction != null)
transaction.Rollback();
transaction = null;

Logger.LOGEXCEPTION(e);
}
finally
{
if (transaction != null)
transaction.Commit();
transaction = null;

if (session != null)
session.Close();
session = null;
}

The hibernate.cfg.xml has below given entries,

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<!-- an ISessionFactory instance -->
<session-factory>
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="hibernate.connection.isolation">ReadCommitted</property>
<property name="show_sql">false</property>
<property name="connection.connection_string">Server=DELLD810-1000\SQLEXPRESS;initial catalog=edgemanager;Integrated Security=SSPI</property>
</session-factory>
</hibernate-configuration>


I am struggling with this problem since last one week and any help on this will be highly appreciated.

Ajay


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 23, 2007 2:10 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
If you can reproduce this problem in a simple test case, please create a JIRA issue and attach the test case there. Thanks.

Or try putting a breakpoint in the BatcherImpl.LogCommand method and try to understand what's happening.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 26, 2007 5:08 am 
Newbie

Joined: Thu Apr 06, 2006 1:17 am
Posts: 6
Location: Copenhagen, Denmark
I am right now experiencing the exact same problem since friday. This error message occurs after some hours on my ASP.NET 2.0 website (suddenly and without any logic explanation). The Windows-services on the same box keeps running against the MySQL database without problems.

NHibernate version: 1.2.0.3002
Show_sql: true

I recall only one thing I changed that particular day in the NHibernate configuration: I changed the drive letter of the log4net logfile from c:\logfilepath\ to e:\logfilepath (a newly attached hot-swap harddisk where I moved all my data files to)

I now set my logfile back to c:, and disabled show_sql and are now waiting to see if it happens again..

I haven't changed anything else in NHibernate for months, and it has been running stable until friday.

if anyone knows more about this issue, please let me know.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 27, 2007 5:47 pm 
Newbie

Joined: Tue Nov 27, 2007 5:32 pm
Posts: 1
We began experiencing the exact same error as the original poster (System.ArgumentOutOfRangeException in NHibernate.Impl.BatcherImpl.LogCommand) when traffic on our NHibernate-based Web application started increasing. We discovered that the error only occured when using log4net's RollingFileAppender with NHibernate. Whether it is NHibernate's method of using log4net or log4net itself that is the problem I have no idea, but switching to the EventLogAppender in production solved the problem for us.


Top
 Profile  
 
 Post subject: Any Ideas if log4net was turned off
PostPosted: Tue Feb 03, 2009 9:46 pm 
Newbie

Joined: Tue Feb 03, 2009 9:32 pm
Posts: 1
hi, Zebra,

I encountered this error too.

My log4net is using RollingFileAppender but I set the level to 'OFF'.

Will RollingFileAppender with level 'OFF' cause the error also?


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.