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.  [ 3 posts ] 
Author Message
 Post subject: Oracle NullReferenceException and NHibernate 1.0.4
PostPosted: Wed May 21, 2008 11:14 am 
Newbie

Joined: Tue Oct 24, 2006 12:44 pm
Posts: 8
Hibernate version: 1.0.4
Name and version of the database you are using: Oracle 10g 10.2.0.3 Patchset 6

Hi at all,

this is an issue for the developer of NHibernate. I've got a problem with a NullReferenceException in the Oracle Client driver but I can not reproduce the exception on time.

I add the (modified) chat with the Oracle support to this post. So, my question is: Is it a bug in NHibernate or Oracle or in my software? How can I debug this exception?

Thanks for your fast answers.
neo

Windows 2003 Server Enterprise English 32-Bit SP 2
Microsoft Data Access Components Version 2.0.0.0
ODP.Net 10.2.0.3.3
ConnectionString: Enlist=true;Data Source=DATABASE;User Id=USER;Password=PASSWORD;Min Pool Size=30; Max Pool Size= 250; Pooling=true;

Dear Sir or Madam,

I’m Using the ODP.Net driver and I have got several problems with NullReferenceExceptions from the OracleDataClient driver.

exception type: System.NullReferenceException
StackTrace (modified):
System.NullReferenceException: Object reference not set to an instance of an object.
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
inherited error (modified):
Oracle.DataAccess.Client.OracleException ORA-01036: Variablenname/-nummer ungültig
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode,
OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,
OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()

exception type: System.NullReferenceException
StackTrace (modified):
System.NullReferenceException: Object reference not set to an instance of an object.
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
inherited error (modified):
Oracle.DataAccess.Client.OracleException ORA-01036: Variablenname/-nummer ungültig
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn,
IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn,
String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()

I can not(!) reproduce the exception, but the NullReferenceException is critical, because the software does not work correctly after the error occures.

Logging has been enabled by setting the following registry key:
HKLM\SOFTWARE\ORACLE\ODP.NET\2.102.3.3
TraceLevel = 15
TraceOption = 1

The following arrangements have been done:

1. Try to reproduce the error with very very high load.
2. Changing the ConnectionString to ensure that the "erroneous" database connection will be destroyed within five minutes. So, the inherited errors shall be reduced to the minimum.

exception type: System.NullReferenceException
StackTrace (modified):
System.NullReferenceException: Object reference not set to an instance of an object.
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
inherited error (modified):
Oracle.DataAccess.Client.OracleException ORA-01036: Variablenname/-nummer ungültig
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn,
IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,
OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery,
Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()

*** ISSUE UPDATE BY ORACLE ***

Error: ORA 1036
Text: illegal variable <name/num>
-------------------------------------------------------------------------------
Cause: Unable to find bind context on user side.
Action: Make sure that the variable being bound is in the SQL statement.

So it sounds like you have a possible memory corruption; i.e., something is corrupting the memory associated with the SQL statement so that it doesn't work properly when it is executed. Obviously as the code works fine most of the time, this suggests there isn't a simple programming error in the application code where ExecuteNonQuery() is called. However this could be worth checking if the code around this function call is non-trivial, for example if you have a number of conditional binds working in a generic sense, rather than the simple case where the query and the number of binds are known at compile time and you have a simple bind - bind - bind - execute sequence.

I checked the knowledgebase for known bugs involving intermittent ORA-1036 errors, but didn't find anything.

Kind regards

*** ISSUE UPDATE ***

thanks alot for your fast reply. But I have to tell you that it is not possible to debug the software, because no debugger has been installed on the server. And I don't think that would help anything, because the NullReferenceException has been thrown in the Oracle.DataAccess.Client namespace.

In my opinion, you are completely right that it isn't a simple programming error in the application code. I think the three NullReferenceExceptions coming from Oracle.DataAccess driver are the reason for that ORA-01036 error (inherited errors).

So, the most important question is: Why are that NullReferenceExceptions thrown? How can I debug or log some information for that Oracle source code?

Kind regards,

*** ISSUE UPDATE BY ORACLE ***

Well a NullReference is thrown because Oracle has found a null reference that shouldn't be there. I can't tell you why this happens; I would need to see some code that reproduces the problem, although I guess once you've cut it down to 40-50 lines of code it'll be obvious. However at this point it'll be clear (a) why the code is wrong or (b) that the code is definitely correct and there's a bug in ODP.Net.

It's not impossible to debug without a debugger, for example you can write to a log file anything relevant to the error; this can help narrow down the circumstances in which the problem can occur. As the application doesn't work at all after the error this is helpful, because it means that whatever caused the problem is likely to benear the end of the log.

I'm not aware of any feature within ODP.Net that will tell you why there's a Null reference.

*** ISSUE UPDATE ***

Hi,

Ok, I think, we talk about a bug in the ODP.Net driver, because a NullReferenceException is not a business exception. So, I will try to describe my code a little bit. The first thing I have to mention is that I use NHibernate 1.0.4.0 (http://www.hibernate.org/343.html, a Object Relational Mapper) to access the database. So, I do not use the OracleData driver directly.

I send you the complete stacktrace of the first NullReferenceException of this service request.

As you can see, the NullReferenceException has been thrown while inserting a new database entry. And I can ensure that I do not try to save "null data".

2008-04-29 20:32:43,877 [107] ERROR NHibernate.Impl.SessionImpl - could not synchronize database state with session
NHibernate.ADOException: could not insert: [PoJo#181158797]
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull,
SqlString sql, Object obj, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql,
Object obj, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields,
Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledInsertion.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
at NHibernate.Impl.SessionImpl.Flush()

King regards,

*** ISSUE UPDATE BY ORACLE ***

Is it possible that this could be a bug in nHibernate, as this layer will be responsible for supplying binds to the ODP.Net driver? To investigate the NullPointerException as an ODP.Net bug we will need a minimal reproduceable testcase that uses ODP.Net directly, with out an intermediate nHibernate layer.

*** ISSUE UPDATE ***

Sorry, but I definitively can not(!) reproduce the error. The error occurs sporadically. But the error still can occur and I definitively need a solution for this. What do you recommend? As an Oracle customer I expect that you can give me scenarios or reasons why NullReferenceExceptions can occur in ODP.NET at the location given by the stacktrace.

Kind regards,

*** ISSUE UPDATE ***

Just another update: Can you provide a debug version of the ODP.Net assembly. So, I can provide a linenumber
of the error!

Thanks,

*** ISSUE UPDATE BY ORACLE ***

We don't give out debug versions of our software. Usual debugging approach is via a reproduceable testcase, then Development can run this through a debugger and step through the code to find and fix the bug, once this has been proven to be an ODP.Net bug.

ODP.Net throws a NullReferenceException when it encounters a Null reference where a non-Null reference is required. Providing you with a list of example scenarios in which this can occur is not a service provided by Oracle Support (you would need to engage Oracle Consultancy for this), but this would seem to be a waste of time as there is very little chance any of them will (a) be an ODP.Net bug or (b) point to the cause of the problem in your application.

I have the following recommendations:
- log this issue with the nHibernate authors (in addition to this SR). While this may not be an nHibernate bug, they may be able to help you debug this issue and provide further details of why the problem occurs.
- add code to the application to write to a log file anything that may be relevant to the bug, so that what was happening just before the bug occurred can be determined with some precision. This can be useful in determining the exact cause of the problem so that a testcase can be constructed.
- issue as SYSTEM or SYS the database command alter system set events='1036 trace name errorstack level 12'; and upload the trace files generated by this after the error occurs, then we should be able to see the associated DML
- test with ODAC 11.1.0.6 in a separate home using ODP.NET 11.1.0.6.20, which you can download from http://www.oracle.com/technology/tech/w ... index.html

> we talk about a bug in the ODP.Net driver, because a NullReferenceException is not a business exception

NullReferenceException not being a business exception (by which I assume you mean your application doesn't throw NullReferenceExceptions) doesn't make this an ODP.Net bug. All it means is that ODP.Net has encountered a Null reference (references are similar to pointers in C, and references in C++) where there shouldn't be one. This usually means there is a programming error in the calling application, which in this case is nHibernate, although it could be an application bug causing nHibernate to misbehave.

*** ISSUE UPDATE ***

Thanks for your reply,

OK, I will contact the NHibernate developer team. So, I will contact you within the next week, because we must discuss the installation of the OPD.Net 11.

Thanks for your patience

Best Regards,


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 3:04 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's hard to say who is to blame here. However, here are a few arguments for this being Oracle's bug:

- NullReferenceException is certainly an exception that shouldn't happen because of user error or invalid inputs. The inputs should have been checked before being used.

- NHibernate works successfully with other ADO.NET data providers. Since you are using Oracle, you could try using MS' Oracle data provider.


Top
 Profile  
 
 Post subject: Your advise?
PostPosted: Fri May 23, 2008 9:00 am 
Newbie

Joined: Tue Oct 24, 2006 12:44 pm
Posts: 8
Hi sergey,

thank you so much for your answer. I will send your answer to Oracle and then we will see. I'm really frustrated about this error, because there is no way to reproduce it. Sometimes, I start my application and the exception occurs within hours. Next time, I must wait for weeks. And it is not always the same methd or so .. I only know that there is a NullReferenceException and Oracle tries to tell me that this is not a bug. By the way, I know that that method in the OPD.Net API throws InvalidOpererationExceptions.

What would you do in my situation? I think, the update of the OPD.Net driver wouldn't be bad. Shall I update NHibernate to the latest version? But as you already said: The code works fine. That Insert method has been called thousend times and more and it worked. You know what I mean?

A change to the MS Oracle Driver is not possible because we do need support of milliseconds for DATETIME.

Hope for answer
neo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.