Hello there,
I have trouble with email processes (to set up). When I try to run the following Hi-Task, I get this error message in the task list.
I use Spring Boot for the project and didn’t do the 10 steps from the bmp-mail examples (why see the following topic. Would this even be necessary for own (Spring Boot) projects)?
I would be very grateful for any small help
An error happened while submitting the task form: Unable to load mail configuration from: C:\Users\user\Documents\Camunda Projekte\homerMail\src\main\resources\
From the console:
log.txt (77.2 KB)
2021-07-27 11:23:13.120 ERROR 7636 --- [nio-8080-exec-7] org.camunda.bpm.engine.context : ENGINE-16004 Exception while closing command context: Unable to load mail configuration from: C:\Users\user\Documents\Camunda Projekte\homerMail\src\main\resources\
java.lang.IllegalStateException: Unable to load mail configuration from: C:\Users\user\Documents\Camunda Projekte\homerMail\src\main\resources\
Caused by: java.io.FileNotFoundException: C:\Users\user\Documents\Camunda Projekte\homerMail\src\main\resources (Zugriff verweigert)
(“Access denied”, but it is not the path)
and the other classes:
pom.xml (2.7 KB)
camunda.cfg.xml (954 Bytes) processes.xml (446 Bytes) (for Bean Configuration, see: Mail : Could not parse BPMN process)
Applicaton.java
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngines;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String... args) {
SpringApplication.run(Application.class, args);
}
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
}
ReactOnIncomingMail.java (see PrintServiceProcessApplication (bpm-mail example print); yes the pdf is atm missing)
import org.camunda.bpm.application.PostDeploy;
import org.camunda.bpm.application.PreUndeploy;
import org.camunda.bpm.application.ProcessApplication;
import org.camunda.bpm.application.impl.ServletProcessApplication;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.variable.Variables;
import org.camunda.bpm.extension.mail.config.MailConfiguration;
import org.camunda.bpm.extension.mail.config.MailConfigurationFactory;
import org.camunda.bpm.extension.mail.notification.MailNotificationService;
import org.camunda.bpm.extension.mail.service.MailService;
import org.camunda.bpm.extension.mail.service.MailServiceFactory;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
@ProcessApplication(name="Print Service App")
public class ReactOnIncomingMail extends ServletProcessApplication {
private MailConfiguration configuration;
private MailNotificationService notificationService;
@PostDeploy
public void startService(ProcessEngine processEngine) throws Exception {
RuntimeService runtimeService = processEngine.getRuntimeService();
configuration = MailConfigurationFactory.getConfiguration();
notificationService = new MailNotificationService(configuration);
notificationService.registerMailHandler(mail -> {
runtimeService.startProcessInstanceByKey("printProcess",
Variables.createVariables()
.putValue("mail", mail)
.putValue("invoice", getInvoicePath()));
});
notificationService.start();
}
protected String getInvoicePath() {
URL resource = getClass().getResource("/invoice.pdf");
if (resource == null) {
throw new IllegalStateException("Cannot found invoice file: invoice.pdf");
}
try {
File file = new File(resource.toURI()); //TODO :möglicherweise falscher Import
return file.getPath();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
@PreUndeploy
public void stopService() throws Exception {
notificationService.stop();
MailService mailService = MailServiceFactory.getService(configuration);
mailService.close();
}
}
/* MailNotificationService notificationService = new MailNotificationService(configuration);
notificationService.registerMailHandler(mail -> {
runtimeService.startProcessInstanceByKey("process",
Variables.createVariables().putValue("mail", mail));
});
notificationService.start();
// ...
notificationService.stop();*/