WebObjects: "EOEditingContext: Access With No Lock" in a DirectAction Method Errors

Using an EOEditingContext in a direct action method to fetch objects results in errors.
Symptom:

Using an EOEditingContext in a direct action method to fetch objects results in the following errors:

*** EOEditingContext: access with no lock: recordForGID()!
*** EOEditingContext: access with no lock: recordObject()!

Firing faults also causes the EOEditingContext to complain:

*** EOEditingContext: access with no lock: globalIDForObject()!


Solution

Call lock() and unlock() on the EC inside the direct action method, as in:

 public WOActionResults testAction() {
ec.lock(); // Assume EC exists
.
// do fetch/processing with EC.
.
ec.unlock();
    }

Published Date: Feb 18, 2012