AnsweredAssumed Answered

Share ajax to REST workflow API

Question asked by matjazmuhic on Apr 15, 2011
Latest reply on Apr 15, 2011 by michaelc
I have share client side javascript and I bound onClick event on my element in my webscript (get.html).
In onClick function I do this:


onClick: function MyTasks_onClick(e)
{
                        Alfresco.util.Ajax.request(
                        {
                                method: "POST",
                                url: "http://localhost:8080/share/proxy/alfresco/api/workflow/task/end/jbpm$58/approve",
                                successCallback: { fn: this.onSuccess, scope: this },
                                failureMessage: "",
                                execScripts: true
                        });
}


onSuccess: function MyTasks_onSuccess()
{
           alert("Success");
}


But I get error from server saying:
{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "03150012 Wrapped Exception (with status template): 03150024 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js': 03150023 Failed to signal transition approve from workflow task jbpm$58.", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 03150012 Wrapped Exception (with status template): 03150024 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js': 03150023 Failed to signal transition approve from workflow task jbpm$58.",
 
  "callstack" :
  [
      ""      ,"java.lang.IndexOutOfBoundsException: Index: 0, Size: 0"
      ,"java.util.ArrayList.RangeCheck(ArrayList.java:547)"
      ,"java.util.ArrayList.get(ArrayList.java:322)"
      ,"org.hibernate.collection.PersistentList.get(PersistentList.java:271)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)"
      ,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)"
      ,"java.lang.reflect.Method.invoke(Method.java:597)"
      ,"bsh.Reflect.invokeOnMethod(Unknown Source)"
      ,"bsh.Reflect.invokeObjectMethod(Unknown Source)"
      ,"bsh.Name.invokeMethod(Unknown Source)"
      ,"bsh.BSHMethodInvocation.eval(Unknown Source)"
      ,"bsh.BSHPrimarySuffix.doSuffix(Unknown Source)"
      ,"bsh.BSHPrimaryExpression.eval(Unknown Source)"
      ,"bsh.BSHPrimaryExpression.eval(Unknown Source)"
      ,"bsh.BSHBinaryExpression.eval(Unknown Source)"
      ,"bsh.BSHIfStatement.evaluateCondition(Unknown Source)"
      ,"bsh.BSHIfStatement.eval(Unknown Source)"
      ,"bsh.Interpreter.eval(Unknown Source)"
      ,"bsh.Interpreter.eval(Unknown Source)"
      ,"bsh.Interpreter.eval(Unknown Source)"
      ,"org.jbpm.graph.action.Script.eval(Script.java:130)"
      ,"org.jbpm.graph.action.Script.eval(Script.java:73)"
      ,"org.jbpm.graph.action.Script.execute(Script.java:62)"
      ,"org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:284)"
      ,"org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:241)"
      ,"org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:213)"
      ,"org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:196)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)"
      ,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)"
      ,"java.lang.reflect.Method.invoke(Method.java:597)"
      ,"org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)"
      ,"org.jbpm.taskmgmt.def.Task$$EnhancerByCGLIB$$61deb8ff.fireEvent(<generated>)"
      ,"org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:466)"
      ,"org.alfresco.repo.workflow.jbpm.WorkflowTaskInstance.end(WorkflowTaskInstance.java:135)"
      ,"org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:436)"
      ,"org.alfresco.repo.workflow.jbpm.JBPMEngine$26.doInJbpm(JBPMEngine.java:1815)"
      ,"org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)"
      ,"org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)"
      ,"org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)"
      ,"org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)"
      ,"org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1780)"
      ,"org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServiceImpl.java:648)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)"
      ,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)"
      ,"java.lang.reflect.Method.invoke(Method.java:597)"
      ,"org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)"
      ,"org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)"
      ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)"
      ,"org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)"
      ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
      ,"org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)"
      ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
      ,"org.alfresco.repo.audit.AuditMethodInterceptor.proceedWithAudit(AuditMethodInterceptor.java:217)"
      ,"org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:184)"
      ,"org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:137)"
      ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
      ,"org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)"
      ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
      ,"org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)"
      ,"$Proxy71.endTask(Unknown Source)"
      ,"org.alfresco.repo.workflow.jscript.JscriptWorkflowTask.endTask(JscriptWorkflowTask.java:318)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"
      ,"sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)"
      ,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)"
      ,"java.lang.reflect.Method.invoke(Method.java:597)"
      ,"org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)"
      ,"org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)"
      ,"org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)"
      ,"org.mozilla.javascript.gen.c47._c1(file:\/opt\/Alfresco\/3.4.c2\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js:46)"
      ,"org.mozilla.javascript.gen.c47.call(file:\/opt\/Alfresco\/3.4.c2\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js)"
      ,"org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)"
      ,"org.mozilla.javascript.gen.c47._c0(file:\/opt\/Alfresco\/3.4.c2\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js:49)"
      ,"org.mozilla.javascript.gen.c47.call(file:\/opt\/Alfresco\/3.4.c2\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js)"
      ,"org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)"
      ,"org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)"
      ,"org.mozilla.javascript.gen.c47.call(file:\/opt\/Alfresco\/3.4.c2\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js)"
      ,"org.mozilla.javascript.gen.c47.exec(file:\/opt\/Alfresco\/3.4.c2\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js)"
      ,"org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:472)"
      ,"org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:190)"
      ,"org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282)"
      ,"org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)"
      ,"org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:981)"
      ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:383)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:381)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:436)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:466)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:304)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:333)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:189)"
      ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)"
      ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:717)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)"
      ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)"
      ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)"
      ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)"
      ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)"
      ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)"
      ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)"
      ,"org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)"
      ,"org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)"
      ,"org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)"
      ,"java.lang.Thread.run(Thread.java:619)"
      ,"org.jbpm.graph.def.DelegationException: script evaluation exception"
      ,"org.jbpm.graph.action.Script.eval(Script.java:139)"
      ,"org.alfresco.service.cmr.workflow.WorkflowException: 03150023 Failed to signal transition approve from workflow task jbpm$58."
      ,"org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1831)"
      ,"org.alfresco.scripts.ScriptException: 03150024 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js': 03150023 Failed to signal transition approve from workflow task jbpm$58."
      ,"org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:194)"
      ,"org.springframework.extensions.webscripts.WebScriptException: 03150012 Wrapped Exception (with status template): 03150024 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/org\/alfresco\/repository\/workflow\/end-task.post.js': 03150023 Failed to signal transition approve from workflow task jbpm$58."
      ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:758)"

  ],
 
  "server" : "Community v3.4.0 (c 3335) schema 4,113",
  "time" : "15-Apr-2011 11:35:11"
}

So basically it says "Failed to signal transition approve from workflow task jbpm$58." Task DOES exist and it has two transitions: approve and reject.
I have no clue what's wrong here.

Help?

Outcomes