cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow.cancel ends with error in docLib

zladuric
Champ on-the-rise
Champ on-the-rise
When I end a workflow through workflow.cancel() or workflow["delete"](); I can't access the documents' parrent space in Share afterwards.

I tried searching the forums, but couldn't find any similar problem.

So the details:
I upload a file to a space in document library and start an advanced workflow with a task-node.
After that, the user the workflow is assigned to ends the workflow with workflow.cancel (through a webscript).
After this, when I try to access that space (where the document is held), by ANY user in /share, I get an error like this:

Wrapped Exception (with status template): Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath store file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': Workflow instance 'jbpm$82324' does not exist 
(catalina error log bellow)

Of course, the documents from this space are not shown. My guess here is that the workflow is canceled, but the task somehow remains. And alfresco can't find the info on the now deleted workflow, so it gives some sort of error. I don't know if this is true, but this is a problem for me.

Now, my questions: is this a known bug/behaviour?

And another, even better question, that would actually help me solve the issue. Could somebody post an example of how to get the list of possible transitions for a task and then send the document down one of these?

That way I wouldn't have to cancel() the workflow.

Thanks in advance


Catalina error log:
13:46:37,467 User:test ERROR [web.scripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: Wrapped Exception (with status template): Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath storefile:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': Workflow instance 'jbpm$82328' does not exist
org.alfresco.web.scripts.WebScriptException: Wrapped Exception (with status template): Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath storefile:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': Workflow instance 'jbpm$82328' does not exist
        at org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:622)
        at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:165)
        at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:319)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:322)
        at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:229)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:368)
        at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:390)
        at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:273)
        at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262)
        at org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
        at org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.alfresco.scripts.ScriptException: Failed to execute script '/org/alfresco/slingshot/documentlibrary/doclist.get.js (in classpath storefile:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': Workflow instance 'jbpm$82328' does not exist
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:178)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:274)
        at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108)
        at org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:827)
        at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90)
        … 22 more
Caused by: org.alfresco.service.cmr.workflow.WorkflowException: Workflow instance 'jbpm$82328' does not exist
        at org.alfresco.repo.workflow.jbpm.JBPMEngine.getProcessInstance(JBPMEngine.java:802)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine$13.doInJbpm(JBPMEngine.java:767)
        at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
        at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
        at org.alfresco.repo.workflow.jbpm.JBPMEngine.getWorkflowById(JBPMEngine.java:761)
        at org.alfresco.repo.workflow.WorkflowServiceImpl.getWorkflowsForContent(WorkflowServiceImpl.java:576)
        at sun.reflect.GeneratedMethodAccessor929.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:275)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy51.getWorkflowsForContent(Unknown Source)
        at org.alfresco.repo.jscript.ScriptNode.getActiveWorkflows(ScriptNode.java:2324)
        at sun.reflect.GeneratedMethodAccessor928.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
        at org.mozilla.javascript.JavaMembers.get(JavaMembers.java:117)
        at org.mozilla.javascript.NativeJavaObject.get(NativeJavaObject.java:113)
        at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1544)
        at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1375)
        at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1364)
        at org.mozilla.javascript.gen.c14._c6(file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js:566)
        at org.mozilla.javascript.gen.c14.call(file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
        at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
        at org.mozilla.javascript.gen.c14._c0(file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js:340)
        at org.mozilla.javascript.gen.c14.call(file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.gen.c14.call(file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
        at org.mozilla.javascript.gen.c14.exec(file:/opt/pbk-svn/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:449)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:174)
        … 26 more

2 REPLIES 2

sgartner
Champ on-the-rise
Champ on-the-rise
And another, even better question, that would actually help me solve the issue. Could somebody post an example of how to get the list of possible transitions for a task and then send the document down one of these?

Zladuric,

I can't help you with the cancel workflow issue as I'm trying to figure that out myself (though for cleaning up a development environment, not how you appear to be using it).  I can help you with your last question.  However, it's unclear if you really want the transitions for a random document's task, or if you want the transitions for tasks that the user has in My Tasks.  So, I'll answer both questions.

First, here is some FTL for showing the tasks in My Tasks and the transitions for each task:

 <table cellspacing=0 cellpadding=2>
   <tr>
      <th>ID</th>
      <th>Type</th>
      <th>Name</th>
      <th>Completed</th>
      <th>Transitions</th>
   </tr>
   <tr>
     <td colspan="11"><hr/></td>
   </tr>
   <#list workflow.assignedTasks as t>
      <tr>
         <td>${t.id}</td>
         <td>${t.type}</td>
         <td>${t.name}</td>
         <td>${t.isCompleted?string("Yes", "No")}</td>
         <td>
            <#list t.transitions as transition>
                <span class="${t.id} ${transition.id}">
                  ${transition.label?html}
                </span>
                <#if transition_has_next><span class="separator">|</span></#if>
            </#list>
         </td>
      </tr>
   </#list>
</table>

But let's say you are starting with a document nodeRef.  Here is how you would find all of the workflows, tasks, and transitions connected to that document, and then how you would transition one of them (leaving for homework how you would choose which one to transition):


var theDocument = search.findNode(docNodeRef);
var tasks = [];

// get the current task IDs and push them into the tasks array
for each (wf in theDocument.activeWorkflows)
  {
    var thePaths = wf.getPaths();
    for (var pathKey in thePaths)
      {
        var theTasks = thePaths[pathKey].getTasks();
        for (var taskKey in theTasks)
          {
            tasks.push(workflow.getTaskById(theTasks[taskKey].getId()));
          }
      }
  }

// Now that we have the tasks for all workflows attached to the current document
// you can get the possible transitions this way.
var transitions = {};
for (var key in tasks)
  {
    var taskTransitions = tasks[key].getTransitions();
    for (var key1 in taskTransitions)
      {
        transitions[tasks[key].getId()] = taskTransitions[key1].getId();
      }
  }

// Now that you have the transitions you can display them for
// your user but to transition one of these you do something like
// this.

var task = workflow.getTaskById(taskId);
task.endTask(transitionId);

I hope this helps.

zladuric
Champ on-the-rise
Champ on-the-rise
Oh, thanks very very much for your effort. I found it out myself in the mean time, so it doesn't matter any more. Thanks for the help again anyway.