Microsoft KB Archive/286414

= PRB: Error 8004e002 When You Call SetComplete on an MTS Component =

Article ID: 286414

Article Last Modified on 12/5/2007

-

APPLIES TO


 * Microsoft COM+ 1.0
 * Microsoft COM+ 1.5
 * Microsoft Transaction Services 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, &quot;Component B&quot;, &quot;Transaction Aborted&quot;



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create an ActiveX dynamic-link library (DLL) in Visual Basic. Rename the project Wrong, and rename the class Root .  Add the following routine to class Root: Public Sub Trans Dim a As No2

On Error GoTo handler Set a = GetObjectContext.CreateInstance(&quot;Wrong.Child&quot;) a.DoThis GetObjectContext.SetComplete Exit Sub handler: MsgBox Err.Number End Sub   Add another component named Child to the project, and add the following code: Public Sub DoThis GetObjectContext.SetAbort End Sub  Set the transaction properties of both the Root component and the Child component to requires transaction.</li> Compile the DLL, and add the DLL to COM+ or MTS.</li>  Create an ASP page, and add the following code: <%   Set o = Server.CreateObject(&quot;Wrong.Root&quot;)

o.Trans Set o = Nothing %> You receive the above-mentioned error message. </li></ol>

Additional query words: -2147164158 0x8004E002 8004E002

Keywords: kberrmsg kbprb KB286414

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.