cancel
Showing results for 
Search instead for 
Did you mean: 

can not start process instance without any exceptions

wenweikun
Champ in-the-making
Champ in-the-making
Hi~I have a bean that use for starting my process instance with the process variable, I use activiti 5.12 and activiti-cdi.
the code is quite sample:

   public void startProcess(PurchaseOrder po) {
      System.out.println("————-Process begin————");
      businessProcess.setVariable("po", po);
      System.out.println("————-set process variables done————");
      businessProcess.startProcessByKey("myProcess");
      System.out.println("————-Process started————");
   }

the system out msg use for my debug.

everything is perfect using the following bpmn:

<process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask1" name="User Task"></userTask>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="usertask2"></sequenceFlow>
    <userTask id="usertask2" name="User Task"></userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
  </process>

but when i change the "usertask1" to a email task, the process instance was not deployed. the system out msg remain in —set process variables done—– but not —-Process started—— and also , there is no exceptions.

the email task is also not special :  <serviceTask id="mailtask1" name="Send email if received" activiti:type="mail">

I go on debug.


I set the email task as Asynchronous, the process instance will work, but seems the mail did not sent out successfully

and if I change the email task to a service task, it is no problem.

my engine configuration:

public ProcessEngine getProcessEngine() {
      CdiJtaProcessEngineConfiguration processEngineConfiguration = new CdiJtaProcessEngineConfiguration();
      processEngineConfiguration.setProcessEngineName("default");
      processEngineConfiguration
            .setDataSourceJndiName("java:jboss/datasources/MysqlDS");
      processEngineConfiguration
            .setTransactionManager(lookupTransactionManager());
      processEngineConfiguration.setDatabaseType("mysql");
      processEngineConfiguration.setDatabaseSchemaUpdate("true");
      processEngineConfiguration.setTransactionsExternallyManaged(true);
      processEngineConfiguration.setJobExecutorActivate(true);
      processEngineConfiguration.setMailServerPort(1025);
      processEngine = processEngineConfiguration.buildProcessEngine();
      return processEngine;
   }

Looking forward for the help~ Thank you.
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Is the logging configured correcltly? maybe the error is swallowed. Have you tried debugging the java-code, up to the point where the process is actually started?

Thank you for the reply, the logging config should be no problem since the other activiti exceptions show out correctly. I have debug the java code, I set the break point at businessProcess.startProcessByKey("poManagementProcess"); and System.out.println("————-Process started————"); I press F5 all the way down, but it seems no problem for me.(I have no knowledge at Activiti source code Smiley Sad )
now my solution is create a service task  and use java mail for my mail sending task. It works fine now.

BTW, the sample process is :
<java>
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask2" name="User Task"></userTask>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
  </process>
</java>

and the following process did not work:
<java>
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="mailtask1" name="Mail Task" activiti:type="mail"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="mailtask1"></sequenceFlow>
    <userTask id="usertask1" name="User Task"></userTask>
    <sequenceFlow id="flow2" sourceRef="mailtask1" targetRef="usertask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
  </process>
</java>

trademak
Star Contributor
Star Contributor
That's because the mail task doesn't contain any elements like to recipient, subject etc. So this can't work. Or did you not include all the details?

Best regards,

wenweikun
Champ in-the-making
Champ in-the-making
I did contain the necessary elements of email task, actually the engine works well at another sample project using the same process.
The difference of  current project is I call the startProcess method at a asynchronous method of a stateless bean, I use this bean to listen to the change of a folder, once there is new xml file come in, then start a new process. I dont know if it is the source of the problem.

jbarrez
Star Contributor
Star Contributor
That shouldn't be a problem.

Can you reproduce it in a unit test? That's the easiest and quickest way  for us to verify and fix it.