Sunday, February 5, 2012

Error in Workflow ORA-04061: existing state of has been invalidated

Working with workflows can be tough when you get errors that are really difficult to debug. As I was recently working on one of the custom workflow, I encountered the below error

"Error in Workflow /203462 ORA-04061: existing state of has been invalidated"

First thing I did was to check if the Package that has been called through workflow was in valid state and to my surprise it was. After a lot of research I came to know that this is a bug in Workflow.

If you are designing/modifying a workflow process, the workflow works fine for certain instances and you modify the Package and recompile it. And now you run the workflow process you get the above error. Recompilation of package spec/body called through workflow is the main reason you will end up with this error.
This happens as workflow fails to look at the new status of the package after compilation and it continues to look at the old SGA data.

1. One simple way to get away with this error without involving DBA/Sysadmin team is to rename the package that is being called through the workflow and accordingly modify the workflow to call the new package. And repeat this every time you need to recompile the Package.

2. This solution works if you don't have option of bounce

         DROP INVALID PACKAGE(Package for which your getting the error)


3. Another trick that might work out is to cancel all the Active/Error instances of this Workflow by using the System Administrator>Workflow : Administrator Workflow>Status Monitor.
4. Depending upon your access to the Instance(Workflow Manager) you need to restart the Notification mailer and Service components. If this doesn't work out then you go for 4.
5. Get your DBA/Sysadmin to bounce the instance.