AnsweredAssumed Answered

Can't create txt file with Service Task in Activiti Explorer

Question asked by nhhao1996 on Nov 23, 2018

I'm using Eclipse and Activiti Explorer to create and deploy a bpmn process. I'm following the Getting Started tutorial on activiti.org/quick-start. Everything is working fine. But I added some code to create a txt file in there service task's class to see if it's executed. My code:

public class AutomatedDataDelegate implements JavaDelegate {

public void execute(DelegateExecution execution) throws Exception {
try {
File file = new File("D:\\","data.txt");
if(!file.exists()) {
System.out.println("creating file");
if(file.createNewFile()) {
System.out.println("Succesfully created file");
}
else{
System.out.println("Failed to create file");
}
}

Date now = new Date();
execution.setVariable("autoWelcomeTime", now);
System.out.println("Faux call to backend for [" + execution.getVariable("fullName") + "]");
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}

 

This code working fine in console with command: java -jar target/my-jar-file.jar. But when I create deployment artifact and upload .bar file to activiti. It's still run but don't create any file in my D:\

Can someone help me?

Outcomes