AnsweredAssumed Answered

CIFS - start simple workflow

Question asked by borys on Dec 14, 2007
Hi all,

I'm writing custom desktop action that starts a simple workflow.
Here's my Java code:

public class WorkflowAction extends DesktopAction {

   private Log log = LogFactory.getLog(WorkflowAction.class);

   public WorkflowAction() {
      super(AttrAnyFilesFolders, PreConfirmAction);

   public DesktopResponse runAction(DesktopParams arg0)
         throws DesktopActionException {
      String ticket = arg0.getTicket();

      for (int i = 0; i <= arg0.numberOfTargetNodes() - 1; i++) {
         DesktopTarget target = arg0.getTarget(i);
         approve(target.getNode(), ticket);

      return new DesktopResponse(StsSuccess,
            "Approve action at " + new Date());

   private void approve(NodeRef ref, String ticket) {
      String host = getWebappURL();
      String command = "command/workflow/approve/workspace/SpacesStore/";
      String URL = host + command + ref.getId() + "?ticket=" + ticket;
      try {"HTTP " + URL);
         HttpClient client = new HttpClient();
         HttpMethod get = new GetMethod(URL);
      } catch (Exception e) {

Whem I'm logged in (through web client) it works but if I'm not it throws this exception:

13:19:39,718 DEBUG [] Processing URL: /alfresco/command/workflow/approve/workspace/SpacesStore/f405768f-aa26-11dc-a39c-2b6d627d7ce9?ticket=TICKET_166ace453e337886079d92dafbb586e9499e99f7
13:19:39,750 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/alfresco].[commandServlet]] Servlet.service() for servlet commandServlet threw exception
java.lang.IllegalStateException: Cannot create a session after the response has been committed
   at org.apache.catalina.connector.Request.doGetSession(
   at org.apache.catalina.connector.Request.getSession(
   at org.apache.catalina.connector.RequestFacade.getSession(
   at org.apache.catalina.connector.RequestFacade.getSession(
   at javax.servlet.http.HttpServlet.service(
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(
   at org.apache.catalina.core.StandardWrapperValve.invoke(
   at org.apache.catalina.core.StandardContextValve.invoke(
   at org.apache.catalina.core.StandardHostValve.invoke(
   at org.apache.catalina.valves.ErrorReportValve.invoke(
   at org.apache.catalina.core.StandardEngineValve.invoke(
   at org.apache.catalina.connector.CoyoteAdapter.service(
   at org.apache.coyote.http11.Http11Processor.process(
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
   at org.apache.tomcat.util.threads.ThreadPool$

But after I've received this exception it works. I mean - i try start workflow -> receive exception -> try again -> it works ;)
Any ideas ?