COM+ error handling on SetAbort 
Author Message
 COM+ error handling on SetAbort

Hi!
I've run into a peculiar problem...

This is the setup:
We have a multi-tier web application that access an Oracle db. We have several VB-components that are in COM+. The webserver run on the same machine (W2k Adv. server) as the components and access the db on a second one (Unix).

When an error occur in a transaction component (MTSTransactionMode = 2-RequiresTransaction) we call SetAbort and then tries to log the error through a common framework object that handles all our logging.
But when we try that we get a message:
You made a method call on a COM+ component that has a transaction that has already aborted or in the process of aborting.

and in some extreme cases all that bubbles to the ASP-page is: "Method '~' of object '~' failed".

It seems that after calling SetAbort the transaction-starting-component is not allowed to create any new objects at all! But then how the *&%# are we supposed to be able to log the error!!
I've even tried to call the component before SetAbort with the same result...

Crossing my fingers for help!
Rickard Nord
Sweden



Mon, 31 Oct 2005 16:53:11 GMT  
 COM+ error handling on SetAbort

I faced such problem and I had to check if I was putting all the setcompletes and setaborts properly or not. Other thing you may need to check is the transaction nesting in your classes.

--
Ashok Gupta - ashi
This posting is provided "AS IS" with no warranties, and confers no rights.

  Hi!
  I've run into a peculiar problem...

  This is the setup:
  We have a multi-tier web application that access an Oracle db. We have several VB-components that are in COM+. The webserver run on the same machine (W2k Adv. server) as the components and access the db on a second one (Unix).

  When an error occur in a transaction component (MTSTransactionMode = 2-RequiresTransaction) we call SetAbort and then tries to log the error through a common framework object that handles all our logging.
  But when we try that we get a message:
  You made a method call on a COM+ component that has a transaction that has already aborted or in the process of aborting.

  and in some extreme cases all that bubbles to the ASP-page is: "Method '~' of object '~' failed".

  It seems that after calling SetAbort the transaction-starting-component is not allowed to create any new objects at all! But then how the *&%# are we supposed to be able to log the error!!
  I've even tried to call the component before SetAbort with the same result...

  Crossing my fingers for help!
  Rickard Nord
  Sweden



Mon, 31 Oct 2005 18:43:48 GMT  
 COM+ error handling on SetAbort
You can try this one :

Create on type to store the last error occured:

Type LastErrorType
    Description As String
    HelpContext As Long
    HelpFile As String
    LastDllError As Long
    number As Long
    Source As String
End Type
Public lError As LastErrorType

Then create a subroutine to store the error occured in it which can be as
under:

Public Sub SetLastError()
        With lError
            .Description = Err.Description
            .HelpContext = Err.HelpContext
            .HelpFile = Err.HelpFile
            .LastDllError = Err.LastDllError
            .number = Err.number
            .Source = Err.Source
        End With
End Sub

Then create one more sub-routine to record the error:

Public Sub RaiseError(byval errsource as string)
        Dim lErr As Long, fNumber As Integer
        Dim sErr As String
        fNumber = FreeFile
        Open App.Path & "\Error.log" For Append As #fNumber
        Print #fNumber, Now; lError.number; lError.Description;
lError.Source; lError.LastDllError
        Close #fNumber
        getobjectcontext.SetAbort
        Err.Raise lError.number, ErrSource, lError.Description
End Sub

Now in your procedure whenever u want to do the setabort - you can use
err.raise function and trap the error.

In error trapping routine first execute setlasterror function and then
raiseerror function.


Hi!
I've run into a peculiar problem...

This is the setup:
We have a multi-tier web application that access an Oracle db. We have
several VB-components that are in COM+. The webserver run on the same
machine (W2k Adv. server) as the components and access the db on a second
one (Unix).

When an error occur in a transaction component (MTSTransactionMode =
2-RequiresTransaction) we call SetAbort and then tries to log the error
through a common framework object that handles all our logging.
But when we try that we get a message:
You made a method call on a COM+ component that has a transaction that has
already aborted or in the process of aborting.

and in some extreme cases all that bubbles to the ASP-page is: "Method '~'
of object '~' failed".

It seems that after calling SetAbort the transaction-starting-component is
not allowed to create any new objects at all! But then how the *&%# are we
supposed to be able to log the error!!
I've even tried to call the component before SetAbort with the same
result...

Crossing my fingers for help!
Rickard Nord
Sweden



Mon, 31 Oct 2005 18:58:07 GMT  
 COM+ error handling on SetAbort

It's basically what I've done, but I have taken it one step further and placed all errorhandling in its own object.
BUT I can't call that object after the SetAbort have been called in the failing component.

Like this:
    ...
    Set errobj = CreateObject("MyApp.ErrorObject")
    Set dbobj = CreateObject("MyApp.DBAccessor")
    ' here I make a DB violation that throws an error and causes my DBAccessor to say SetAbort --->
    dbobj.Update "whatever"
    ...

errh:
    lErrno = Err.Number
    sErrDesc = Err.Description
    sErrSource = Err.Source
    lErl = Erl

    On Error Resume Next
    GetObjectContext.SetAbort
    ' this fails with a "hard" error that doesn't care about "Resume Next" but rather ends the application entirely --->
    errobj.LogError lErrno, sErrDesc, lErl, sErrSource, TypeName(Me)
    On Error GoTo 0
    Err.Raise lErrno, sErrSource, sErrDesc
Exit Sub

Quote:

> You can try this one :

> Create on type to store the last error occured:

> Type LastErrorType
>     Description As String
>     HelpContext As Long
>     HelpFile As String
>     LastDllError As Long
>     number As Long
>     Source As String
> End Type
> Public lError As LastErrorType

> Then create a subroutine to store the error occured in it which can be as
> under:

> Public Sub SetLastError()
>         With lError
>             .Description = Err.Description
>             .HelpContext = Err.HelpContext
>             .HelpFile = Err.HelpFile
>             .LastDllError = Err.LastDllError
>             .number = Err.number
>             .Source = Err.Source
>         End With
> End Sub

> Then create one more sub-routine to record the error:

> Public Sub RaiseError(byval errsource as string)
>         Dim lErr As Long, fNumber As Integer
>         Dim sErr As String
>         fNumber = FreeFile
>         Open App.Path & "\Error.log" For Append As #fNumber
>         Print #fNumber, Now; lError.number; lError.Description;
> lError.Source; lError.LastDllError
>         Close #fNumber
>         getobjectcontext.SetAbort
>         Err.Raise lError.number, ErrSource, lError.Description
> End Sub

> Now in your procedure whenever u want to do the setabort - you can use
> err.raise function and trap the error.

> In error trapping routine first execute setlasterror function and then
> raiseerror function.



> Hi!
> I've run into a peculiar problem...

> This is the setup:
> We have a multi-tier web application that access an Oracle db. We have
> several VB-components that are in COM+. The webserver run on the same
> machine (W2k Adv. server) as the components and access the db on a second
> one (Unix).

> When an error occur in a transaction component (MTSTransactionMode =
> 2-RequiresTransaction) we call SetAbort and then tries to log the error
> through a common framework object that handles all our logging.
> But when we try that we get a message:
> You made a method call on a COM+ component that has a transaction that has
> already aborted or in the process of aborting.

> and in some extreme cases all that bubbles to the ASP-page is: "Method '~'
> of object '~' failed".

> It seems that after calling SetAbort the transaction-starting-component is
> not allowed to create any new objects at all! But then how the *&%# are we
> supposed to be able to log the error!!
> I've even tried to call the component before SetAbort with the same
> result...

> Crossing my fingers for help!
> Rickard Nord
> Sweden



Mon, 31 Oct 2005 19:20:30 GMT  
 COM+ error handling on SetAbort

Hi Rickard,

Is your logger class created inside the context of the current transaction, or outside of it? Your logger class should either be not configured altogether (you're not logging to the DB are you?), or should be set to Does Not Support Transactions in order to run outside of the current transaction, since transactions are usually aborting when the logger is called.

I think this should work for you. Personally, I usually log to the event log or to a file. I have have never configured my loggers for COM+ altogether, so I don't have direct experience with your scenario.

Hope this helps,

- Joe Geretz -

  Hi!
  I've run into a peculiar problem...

  This is the setup:
  We have a multi-tier web application that access an Oracle db. We have several VB-components that are in COM+. The webserver run on the same machine (W2k Adv. server) as the components and access the db on a second one (Unix).

  When an error occur in a transaction component (MTSTransactionMode = 2-RequiresTransaction) we call SetAbort and then tries to log the error through a common framework object that handles all our logging.
  But when we try that we get a message:
  You made a method call on a COM+ component that has a transaction that has already aborted or in the process of aborting.

  and in some extreme cases all that bubbles to the ASP-page is: "Method '~' of object '~' failed".

  It seems that after calling SetAbort the transaction-starting-component is not allowed to create any new objects at all! But then how the *&%# are we supposed to be able to log the error!!
  I've even tried to call the component before SetAbort with the same result...

  Crossing my fingers for help!
  Rickard Nord
  Sweden



Tue, 01 Nov 2005 00:19:13 GMT  
 COM+ error handling on SetAbort

Yes i know that this will happen. Thats why i had created a seperate procedure which is being called by the error occured procedure and it never turns back to the original procedure as error is again raised in raise error method.

I think u also need to use on error goto 0 instead of on error resume next to inform the stack that the active error handler is now the parent procedure and not the procedure in which the error has occured.


  It's basically what I've done, but I have taken it one step further and placed all errorhandling in its own object.
  BUT I can't call that object after the SetAbort have been called in the failing component.

  Like this:
      ...
      Set errobj = CreateObject("MyApp.ErrorObject")
      Set dbobj = CreateObject("MyApp.DBAccessor")
      ' here I make a DB violation that throws an error and causes my DBAccessor to say SetAbort --->
      dbobj.Update "whatever"
      ...

  errh:
      lErrno = Err.Number
      sErrDesc = Err.Description
      sErrSource = Err.Source
      lErl = Erl

      On Error Resume Next
      GetObjectContext.SetAbort
      ' this fails with a "hard" error that doesn't care about "Resume Next" but rather ends the application entirely --->
      errobj.LogError lErrno, sErrDesc, lErl, sErrSource, TypeName(Me)
      On Error GoTo 0
      Err.Raise lErrno, sErrSource, sErrDesc
  Exit Sub



Tue, 01 Nov 2005 14:39:44 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. COM+ question: SetAbort not rolling back transaction?

2. Handle COM errors in Try...Catch block?

3. Handling COM Errors in VB script

4. error handling from com

5. COM+ error handling (COMAdminCatalogCollection ErrorInfo etc)

6. Error Handling using VBScript & COM

7. Handling Errors from COM Objects

8. COM error handling

9. Strategies for Error Handling in VB/COM+

10. Error handling between COM and ASP

11. Error Handling in COM+

12. COM Object: handle or trap errors?

 

 
Powered by phpBB® Forum Software