Unable to load mail configuration from: <path> | Spring Boot

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 :slight_smile:


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();*/

(“Access denied”, but it is not the path)

I have tried it again now with File Channel: it can read it! (except for some line separators).

I’ll go through bpm-mail again in more detail ^^

Hello @KameraUndA ,

please try to configure your org.camunda.bpm.extension.mail.config.PropertiesMailConfiguration with a path that has the prefix classpath:. This signals the Configuration to find your properties file on your classpath instead of your file system.

Hope this solves the issue

Jonathan

1 Like

Do you mean that I should (for example) modify the getPropertiesPath so that only the .orElse case occurs?

protected String getPropertiesPath() {
  /*
      return Optional.ofNullable(path).orElseGet(() ->
      Optional.ofNullable(System.getenv(ENV_PROPERTIES_PATH))
        .orElse(DEFAULT_PROPERTIES_PATH));*/
    return DEFAULT_PROPERTIES_PATH;
  }

With that - I had to change the camunda-bpm-mail-core-1.2.0.jar manually right? - I don’t get any Access denied anymore, but now a ConnectorException: No connector found for connector id 'mail-poll' :thinking: (And this time mail-poll is right around correctly :smiley: )

Yeah ok, the three neccassary features are missing :confused:

with the normal .jar:

2021-07-29 11:18:59.061  INFO 19216 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'http-connector' and class 'org.camunda.connect.httpclient.impl.HttpConnectorImpl': 'org.camunda.connect.httpclient.impl.HttpConnectorProviderImpl'
2021-07-29 11:18:59.061  INFO 19216 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'soap-http-connector' and class 'org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorImpl': 'org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorProviderImpl'
2021-07-29 11:18:59.061  INFO 19216 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'mail-send' and class 'org.camunda.bpm.extension.mail.send.SendMailConnector': 'org.camunda.bpm.extension.mail.send.SendMailProvider'
2021-07-29 11:18:59.061  INFO 19216 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'mail-poll' and class 'org.camunda.bpm.extension.mail.poll.PollMailConnector': 'org.camunda.bpm.extension.mail.poll.PollMailProvider'
2021-07-29 11:18:59.077  INFO 19216 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'mail-delete' and class 'org.camunda.bpm.extension.mail.delete.DeleteMailConnector': 'org.camunda.bpm.extension.mail.delete.DeleteMailProvider'

and with the new (my) camunda-bpm-mail-core-1.2.0.jar:

2021-07-29 11:20:16.378  INFO 7284 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'http-connector' and class 'org.camunda.connect.httpclient.impl.HttpConnectorImpl': 'org.camunda.connect.httpclient.impl.HttpConnectorProviderImpl'
2021-07-29 11:20:16.382  INFO 7284 --- [           main] org.camunda.bpm.connect                  : CNCT-01004 Discovered provider for connector id 'soap-http-connector' and class 'org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorImpl': 'org.camunda.connect.httpclient.soap.impl.SoapHttpConnectorProviderImpl'
2021-07-29 11:20:16.672  INFO 7284 --- [           main] org.camunda.bpm.engine.persistence 

Hello @KameraUndA ,

to shorten this, maybe have a look at this section:

According to this, creating a file called mail-config.properties on your classpath will just do.
Have you tried this already?

Jonathan

1 Like

Ok, yeah, wooow :man_facepalming:
Because the file was there all along (I had thought of that, after all). However, I thought the %MAIL_CONFIG% was necessary (I think I read it that way)…
Now the the environment variable is gone and well, it works now, thanks! :slight_smile:

It’s nice to have something like this causing problems for a whole week :sweat_smile:

1 Like