AnsweredAssumed Answered

Error execute document-workflows.get.js

Question asked by user21 on Feb 27, 2012
Hello, after upgrading my alfresco from 3.4.c to 4.0.c, i get this error, when open document in Repository:
    Exception: org.mozilla.javascript.JavaScriptException - [object Error] (file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js#903)
    org.mozilla.javascript.gen.c41._c22(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js:903)
    org.mozilla.javascript.gen.c41.call(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js)
    org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
    org.mozilla.javascript.gen.c41._c40(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js:1515)
    org.mozilla.javascript.gen.c41.call(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js)
    org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
    org.mozilla.javascript.gen.c41._c41(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js:1528)
    org.mozilla.javascript.gen.c41.call(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js)
    org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
    org.mozilla.javascript.gen.c41._c0(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js:1532)
    org.mozilla.javascript.gen.c41.call(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js)
    org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
    org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
    org.mozilla.javascript.gen.c41.call(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js)
    org.mozilla.javascript.gen.c41.exec(file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js)
    org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:318)
    org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:192)
    org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1194)
    org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
    org.springframework.extensions.webscripts.PresentationContainer.executeScript(PresentationContainer.java:70)
    org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:239)
    org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)
    org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
    org.springframework.extensions.webscripts.WebScriptProcessor.executeBody(WebScriptProcessor.java:311)
    org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
    org.springframework.extensions.surf.render.RenderService.process(RenderService.java:600)
    org.springframework.extensions.surf.render.RenderService.renderSubComponent(RenderService.java:506)
    org.springframework.extensions.surf.render.RenderService.renderChromeInclude(RenderService.java:1296)
    org.springframework.extensions.webscripts.ChromeIncludeFreeMarkerDirective.execute(ChromeIncludeFreeMarkerDirective.java:81)
    freemarker.core.Environment.visit(Environment.java:274)
    freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.IfBlock.accept(IfBlock.java:82)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.Environment.process(Environment.java:199)
    org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
    org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:455)
    org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
    org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:204)
    org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:95)
    org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
    org.springframework.extensions.surf.render.bean.ChromeRenderer.render(ChromeRenderer.java:86)
    org.springframework.extensions.surf.render.RenderService.processComponent(RenderService.java:433)
    org.springframework.extensions.surf.render.bean.ComponentRenderer.body(ComponentRenderer.java:94)
    org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
    org.springframework.extensions.surf.render.RenderService.renderComponent(RenderService.java:962)
    org.springframework.extensions.surf.render.RenderService.renderRegionComponents(RenderService.java:901)
    org.springframework.extensions.surf.render.RenderService.renderChromeInclude(RenderService.java:1275)
    org.springframework.extensions.webscripts.ChromeIncludeFreeMarkerDirective.execute(ChromeIncludeFreeMarkerDirective.java:81)
    freemarker.core.Environment.visit(Environment.java:274)
    freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.Environment.process(Environment.java:199)
    org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
    org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:455)
    org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
    org.springframework.extensions.surf.render.RenderService.processRenderable(RenderService.java:204)
    org.springframework.extensions.surf.render.bean.ChromeRenderer.body(ChromeRenderer.java:95)
    org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
    org.springframework.extensions.surf.render.bean.ChromeRenderer.render(ChromeRenderer.java:86)
    org.springframework.extensions.surf.render.bean.RegionRenderer.body(RegionRenderer.java:99)
    org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
    org.springframework.extensions.surf.render.RenderService.renderRegion(RenderService.java:852)
    org.springframework.extensions.surf.extensibility.impl.RegionDirectiveData.render(RegionDirectiveData.java:90)
    org.springframework.extensions.surf.extensibility.impl.ExtensibilityModelImpl.merge(ExtensibilityModelImpl.java:319)
    org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirective.merge(AbstractExtensibilityDirective.java:177)
    org.springframework.extensions.surf.extensibility.impl.AbstractExtensibilityDirective.execute(AbstractExtensibilityDirective.java:145)
    freemarker.core.Environment.visit(Environment.java:274)
    freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.Environment.visit(Environment.java:406)
    freemarker.core.BodyInstruction.accept(BodyInstruction.java:93)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.Macro$Context.runMacro(Macro.java:172)
    freemarker.core.Environment.visit(Environment.java:614)
    freemarker.core.UnifiedCall.accept(UnifiedCall.java:106)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.MixedContent.accept(MixedContent.java:92)
    freemarker.core.Environment.visit(Environment.java:221)
    freemarker.core.Environment.process(Environment.java:199)
    org.springframework.extensions.webscripts.processor.FTLTemplateProcessor.process(FTLTemplateProcessor.java:171)
    org.springframework.extensions.webscripts.WebTemplateProcessor.executeBody(WebTemplateProcessor.java:455)
    org.springframework.extensions.surf.render.AbstractProcessor.execute(AbstractProcessor.java:57)
    org.springframework.extensions.surf.render.RenderService.processTemplate(RenderService.java:722)
    org.springframework.extensions.surf.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:123)
    org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
    org.springframework.extensions.surf.render.bean.PageRenderer.body(PageRenderer.java:85)
    org.springframework.extensions.surf.render.AbstractRenderer.render(AbstractRenderer.java:77)
    org.springframework.extensions.surf.render.RenderService.renderPage(RenderService.java:763)
    org.springframework.extensions.surf.mvc.PageView.dispatchPage(PageView.java:419)
    org.springframework.extensions.surf.mvc.PageView.renderView(PageView.java:314)
    org.springframework.extensions.surf.mvc.AbstractWebFrameworkView.renderMergedOutputModel(AbstractWebFrameworkView.java:316)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    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.site.servlet.MTAuthenticationFilter.doFilter(MTAuthenticationFilter.java:74)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.alfresco.web.site.servlet.SSOAuthenticationFilter.doFilter(SSOAuthenticationFilter.java:307)
    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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
    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:857)
    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:662)
    Exception: org.springframework.extensions.webscripts.WebScriptException - 01270005 Error: Could not load document workflows for workspace://SpacesStore/411d4926-059c-4f47-8291-7a9a91978539 (file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js#903)
    org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScriptImpl(JSScriptProcessor.java:328)
    Exception: org.springframework.extensions.webscripts.WebScriptException - 01270006 Failed to execute script 'classpath*:alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js': 01270005 Error: Could not load document workflows for workspace://SpacesStore/411d4926-059c-4f47-8291-7a9a91978539 (file:/usr/local/alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/document-details/document-workflows.get.js#903)
    org.springframework.extensions.webscripts.processor.JSScriptProcessor.executeScript(JSScriptProcessor.java:200)
I compared document-workflows.get.js in both versions(3.4.c and 4.0.c) it's different.


document-workflows.get.js 3.4.0c
function main()
{
   if (args.nodeRef != null)
   {
      var nodeRef = args.nodeRef;
     
      // Call the repo to get the workflows this node is part of
      var response = remote.call("/api/node/" + nodeRef.replace(":/", "") + "/workflow-instances");
     
      // Create javascript objects from the server response
      var workflows = [];
     
      if (response.status == 200)
      {
         var result = eval('(' + response + ')');
        
         workflows = result.data;
      }
     
      // Prepare the model for the template
      model.nodeRef = nodeRef;
      model.workflows = workflows;
   }
}

main();


document-workflows.get.js 4.0.c
<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">

function getDocumentWorkflows(nodeRef)
{
   var result = remote.call("/api/node/" + nodeRef.replace(":/", "") + "/workflow-instances");
   if (result.status != 200)
   {
      AlfrescoUtil.error(result.status, 'Could not load document workflows for ' + nodeRef);
   }
   return eval('(' + result + ')').data;
}

function main()
{
   AlfrescoUtil.param('nodeRef');
   AlfrescoUtil.param('site', null);
   var documentDetails = AlfrescoUtil.getNodeDetails(model.nodeRef, model.site);
   if (documentDetails)
   {
      model.destination = documentDetails.item.parent.nodeRef
      model.workflows = getDocumentWorkflows(model.nodeRef);
   }
}

main();

What can i do, to resolve this problem?

Outcomes