Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Workflow is in stale state (AEM6.0)

Avatar

Level 4

Hi,

We have created a workflow using workflow api but when we start the workflow is goes to "stale" state and never completes due to the exception.

19.11.2015 05:25:53.435 *ERROR* [JobHandler: /etc/workflow/instances/2015-11-19/model_88574152007587:/content/dam/legg-mason/documents] 

Caused by: java.lang.IllegalStateException: This session has been closed
    at com.google.common.base.Preconditions.checkState(Preconditions.java:150)
    at org.apache.jackrabbit.oak.core.ContentSessionImpl.checkLive(ContentSessionImpl.java:85)
    at org.apache.jackrabbit.oak.core.MutableRoot.checkLive(MutableRoot.java:172)
    at org.apache.jackrabbit.oak.core.MutableRoot.hasPendingChanges(MutableRoot.java:295)
    at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.hasPendingChanges(SessionDelegate.java:533)
    at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.refresh(SessionDelegate.java:562)
    at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:299)
    at org.apache.jackrabbit.oak.jcr.session.SessionImpl.perform(SessionImpl.java:127)
    at org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItemOrNull(SessionImpl.java:228)
    at org.apache.jackrabbit.oak.jcr.session.SessionImpl.getItem(SessionImpl.java:357)
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.sling.jcr.base.SessionProxyHandler$SessionProxyInvocationHandler.invoke(SessionProxyHandler.java:113)
    at com.sun.proxy.$Proxy0.getItem(Unknown Source)
    at com.adobe.granite.workflow.core.jcr.WorkflowManager.getWorkflowNode(WorkflowManager.java:815)
    at com.adobe.granite.workflow.core.jcr.WorkflowManager.getWorkflowInstance(WorkflowManager.java:112)
    at com.adobe.granite.workflow.core.WorkflowSessionImpl.getWorkflow(WorkflowSessionImpl.java:704)
    at com.leggmason.gd.webservices.document.workflow.GMDLFullIndexProcess.execute(GMDLFullIndexProcess.java:88)
    at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:212)
    ... 5 common frames omitted

I want to terminate the workflow when the above exception occurs. Please also let me know why the above exception comes as I have not closed any session.

 

Thanks 

sumit

1 Accepted Solution

Avatar

Correct answer by
Level 10

There seems to be a closure of session is happening in one of the step and you are trying to perform after that. So Workflow is kind of going to a stale state without able to complete.

Can you share your piece of code so that we can see if anything wrong there!

View solution in original post

4 Replies

Avatar

Level 10

In your workflow - are you making use of custom workflow steps?  If you are using a custom workflow step - what is the custom workflow step doing?

 Need more information about your workflow model to try and figure out what is happening. 

Avatar

Correct answer by
Level 10

There seems to be a closure of session is happening in one of the step and you are trying to perform after that. So Workflow is kind of going to a stale state without able to complete.

Can you share your piece of code so that we can see if anything wrong there!

Avatar

Level 4

Thank you for the response.

We are using the jcr session to get the search result in the query and we are not closing the session but I am still not sure why the illegalstateException occurs.

When the exception occurs the code goes to catch block and runs the workflow for another 10 more times which leads to increase the log file size.

Please let me know if there is any configuration where workflow count is given.

Please also help me to resolve the issue .

Thanks alot

Avatar

Level 4

We are not using any custom workflow. We are reading all the nodes under /content/dam/myproject and index them in Solr .While indexing if any exception occurs it goes to catch block and the workflow status is stale wherein the workflow runs for another 10 times resulting into increasing the log file size to more than 100GB and crashes the instance,

Please help me if there is any other way to stop the workflow when it goes to stale state.

Thanks alot for all the help