PRB: Error 8004e002 When You Call SetComplete on an MTS Component (286414)



The information in this article applies to:

  • Microsoft COM+ 1.0
  • Microsoft COM+ 1.5
  • Microsoft Transaction Server 2.0

This article was previously published under Q286414

SYMPTOMS

When a method that calls SetComplete returns, you may receive the following error message in Microsoft Visual Basic:
-2147164158 Automation error
The root transaction wanted to commit, but transaction aborted
or the following error message in Microsoft Active Server Pages (ASP):
(0x8004E002) The root transaction wanted to commit, but transaction aborted /test/abort.asp, line 5

CAUSE

Microsoft Transaction Server and COM+ check consistency between the SetAbort and SetComplete methods along the call chain. If a transaction is doomed because a non-root component called SetAbort, it is not appropriate to call SetComplete from the root.

For example, suppose that two components (component A and component B) are both set to require a transaction, and suppose that component A is called from an ASP page. Component A calls component B, which calls SetAbort. When control returns to component A, which calls SetComplete, the above-mentioned error is returned to the client. Note that the error is not raised in component A.

RESOLUTION

To resolve this problem, propagate an error back to the root component whenever component B calls SetAbort. For example:
Err.Raise vbObjectError + 1, "Component B", "Transaction Aborted"
				

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create an ActiveX dynamic-link library (DLL) in Visual Basic.
  2. Rename the project Wrong, and rename the class Root.
  3. Add the following routine to class Root:
    Public Sub Trans()
        Dim a As No2
    
        On Error GoTo handler
        
        Set a = GetObjectContext().CreateInstance("Wrong.Child")
        
        a.DoThis
        
        GetObjectContext().SetComplete
        
        Exit Sub
    handler:
        MsgBox Err.Number
        
    End Sub
    					
  4. Add another component named Child to the project, and add the following code:
    Public Sub DoThis()
        GetObjectContext().SetAbort
    End Sub
    					
  5. Set the transaction properties of both the Root component and the Child component to requires transaction.
  6. Compile the DLL, and add the DLL to COM+ or MTS.
  7. Create an ASP page, and add the following code:
    <%
    	Set o = Server.CreateObject("Wrong.Root")
    
    	o.Trans
            Set o = Nothing
    %>
    						
    You receive the above-mentioned error message.

Modification Type:MajorLast Reviewed:2/20/2002
Keywords:kbDSupport kberrmsg kbprb KB286414