feliperochadev / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

OracleErrorLog exception with signaling error only #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run Oracle.sql on the Oracle Database to get the table/package/etc
created (i run this under the same user that will log later too -
everything was created successfully)
2. Configure your web to use elmah with OracleErrorLog
3. try to signal an error in a page
Elmah.ErrorSignal.FromCurrentContext().Raise(New
ApplicationException("Raise exception for error signal."), HttpContext.Current)

What is the expected output? What do you see instead?
If try to signal an error with the code above it won't get logged in the
oracle database. So i debugged the project.
An Exception occures in OracleErrorLog 's Log method at the
command.ExecuteNonQuery(); statement. This is the exception message:

ORA-01400: cannot insert NULL into ("VDI"."ELMAH$ERROR"."SOURCE")
ORA-06512: at "VDI.PKG_ELMAH$ERROR", line 88
ORA-06512: at line 1

This is the Stacktrace:

   bei System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle
errorHandle, Int32 rc)
   bei System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle
statementHandle, CommandBehavior behavior, Boolean needRowid,
OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
   bei
System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean
needRowid, OciRowidDescriptor& rowidDescriptor)
   bei System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
   bei Elmah.OracleErrorLog.Log(Error error) in C:\Program
Files\Elmah-Svn\src\Elmah\OracleErrorLog.cs:Zeile 193.
   bei Elmah.ErrorLogModule.LogException(Exception e, HttpContext context)
in C:\Program Files\Elmah-Svn\src\Elmah\ErrorLogModule.cs:Zeile 124.

What version of the product are you using? On what operating system?
I currently checked out via SVN - revision 378. I'm using Windows Vista.

Please provide any additional information below.
Exceptions that aren't signaled - those that are bubbled up the runtime a
logged correctly.

Original issue reported on code.google.com by to.ko...@gmail.com on 4 Sep 2008 at 4:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Forget about the previous comment about the brackets.

The Code variable _source is null so the Source property returns an empty string
(""). So the value for the Parameter for the stored procedure is the empty 
string.

When i try to run the stored procedure in oracle sql developer and insert an 
empty
string for the source coulmn it does NOT work, too.

It seems that oracle tries to convert the empty string to a NULL.

You can reproduce this error even with an insert statement:

INSERT INTO "VDI"."ELMAH$ERROR" 
(ERRORID, APPLICATION, HOST, TYPE, source, MESSAGE, USERNAME, STATUSCODE, 
TIMEUTC,
SEQUENCENUMBER, ALLXML) 
VALUES 
('13', '12', '12', '12', '', 's', '12', '12', TO_DATE('04.09.08', 'DD.MM.RR'), 
'2',
'(CLOB) <?xml version="1.0" encoding="utf-16"?>
<error')

So how to fix this in elmah (or oracle not to convert '' to NULL)?

Original comment by to.ko...@gmail.com on 5 Sep 2008 at 9:24

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
for a workaround i thought:

maybe if i set the applicationName in web.config:

<errorLog type="Elmah.OracleErrorLog, Elmah" connectionStringName="myDB"
applicationName="myApplicationName" />

but this isn't used for the source column (not for signaling errors (and not for
bubble up exception errors to the runtime) :(). 
the applicationName is only for the application column

Original comment by to.ko...@gmail.com on 5 Sep 2008 at 9:59

GoogleCodeExporter commented 9 years ago
This will do the trick:
please add:
            if (error.Source.Length == 0)
            {
                error.Source = "none";
            }

see below:

        public override string Log(Error error)
        {
            if (error == null)
                throw new ArgumentNullException("error");

            string errorXml = error.ToXmlString();
            Guid id = Guid.NewGuid();

            if (error.Source.Length == 0)
            {
                error.Source = "none";
            }
...

Original comment by to.ko...@gmail.com on 5 Sep 2008 at 10:20

GoogleCodeExporter commented 9 years ago
Although the fix suggested above will work, it is not ideal!
The Oracle schema was put together based on the SQL Server implementation, 
however, 
there is a big difference in the way that these 2 databases handle empty 
strings 
(""). Oracle treats "" as a NULL string, whereas SQL Server differentiates 
between 
the two.
Therefore, I have checked in a new version of Oracle.sql (Revision 379) which 
simply 
removes the NOT NULL constraint from the Source column.
You should be able to fix existing deployments by issuing the following command:

  ALTER TABLE elmah$error MODIFY (Source NULL);

Original comment by jamesdriscoll71 on 6 Sep 2008 at 10:17