camunda-community-hub / camunda-platform-7-mail

Mail connectors for Camunda Platform 7
Apache License 2.0
85 stars 72 forks source link

Migrate from Java EE to Jakarta EE 10 #151

Closed roman-mkh closed 1 year ago

roman-mkh commented 1 year ago

Is your feature request related to a problem? Please describe.

Wildfly 27 adds support for Jakarta EE 10 and drops support for Jakarta EE 8. According Camunda Platform 7’s Road to Jakarta EE 10 with Camunda 7.19 running an WildFly 27 it is possible use only Jakarta EE 10 features.

Describe the solution you'd like

Wee need replace Java EE class references and dependencies (javax.) with Jakarta class references (jakarta.) May be it would be a good idea to introduce the 2-d artifact for it: 'camunda-bpm-mail-core-jakarta-x.x.x.jar'. (We keep 'camunda-bpm-mail-core-x.x.x.jar' for solution with Java EE).

Describe alternatives you've considered

We can use org.eclipse.transformer:transformer-maven-plugin to automate the migration. For easy transition we can even apply it direct to 'camunda-bpm-mail-core-x.x.x.jar' to produce 'camunda-bpm-mail-core-jakarta-x.x.x.jar' and provide it to maven repo under artifactId: camunda-bpm-mail-core-jakarta.

Additional context

Reference: update from Camunda Platform 7.18.x to 7.19.0.

jonathanlukas commented 1 year ago

@roman-mkh could you please verify that #152 provides you with a working version of

camunda-bpm-mail-core-jakarta-1.5.2-SNAPSHOT.jar?

You should be able to check out the branch and build the project locally

roman-mkh commented 1 year ago

@jonathanlukas thank you. I built it locally. We are going to test it with WildFly 27.0.1 and camunda 7.19.6.

roman-mkh commented 1 year ago

@jonathanlukas unfortunately I can't manage it work with WildFly 27.0.1. I installed it according shared-process-engine-wildfly.md with the replacing curresponding dependency to jakarta.* . There is classloader issues. It works wenn the connector called synchronously from RESTfull service (over servlet), but has a fatal issue if it calls from Job (in Tx): org.camunda.bpm.extension.mail.MailConnectorException: Failed to send mail: Provider for jakarta.activation.spi.MailcapRegistryProvider cannot be found. Activation implementation module org.eclipse.angus.activation and mail org.eclipse.angus.mail are under system modules of wildfly. Any suggestions how to make it work? See full stacktrace in the attachment. MailConnectorException.txt

jonathanlukas commented 1 year ago

@roman-mkh I looked into it and I was able to install the connector to wildfly-27.0.1.Final:

As base, I used the 7.19.0 Wildfly distro provided by Camunda.

Then, I deployed a project that calls the connector in a process. The connector is executed by the job executor. Beside from this log, everything works:

08:38:19,564 WARNING [jakarta.mail] (pool-8-thread-4) expected resource not found: /META-INF/javamail.default.address.map

Please double-check your setup

roman-mkh commented 1 year ago

@jonathanlukas thank You very much indeed that you took the problem seriously. I've downloaded camunda wildfly pre-packaged versions 'camunda-bpm-ee-wildfly-7.19.7-ee' and 'camunda-engine-7.20.0-ee' and installed them on Windows10 (java11). Additionaly I installed only 'camunda-bpm-mail-core-jakarta-1.5.2' according your notes. Unfortunately this does work only on synchronous calls. I prepared sample BPMN that reflect the problem. The first two activities "Send E-Mail 1" and "Send E-Mail 2" are working well, but "Send E-Mail 3" stuck until socket timeout (see stacktrace inthe attachment). (Database tx-timeout came before and created incident and process state cannot be stored any more. This cause that the process stucks forever). Could you please run attached BPMN on your installation and check the behaviour? you need to adjust 'to:' email-address (the variable "tx==true"can be used to skip synchronius sending emails) I observed the same behaviour on bothes 7.19 and 7.20. Thank You for support!

image SendMail.zip socket-timeout.txt

Maybe socket-timeout is just a follow-up error of ' Provider for jakarta.activation.spi.MailcapRegistryProvider cannot be found': MailcapRegistryProvider-stacktrace.txt

jonathanlukas commented 1 year ago

Hi @roman-mkh , thank you for coming back and providing a concrete example.

I am able to reproduce the behaviour, but only if the process is deployed directly from the modeler, without a process application.

Given you package the process to a .war file and deploy it to the engine (as it is intended usually when using wildfly), there is no issue.

Still, I am not sure why the issue appears...

roman-mkh commented 1 year ago

Hi @jonathanlukas , thank you for rush answer. I will pack it to war and test it and test again our real process with additional dependency to in the connector module.xml. In mean while I modified (localy) camunda-bpm-mail-core to try use configured wildfy mail session (acoring manual mail_subsystem. Unfortunately it gives me again 'java.lang.IllegalStateException: Not provider of jakarta.mail.util.StreamProvider was found'. I think this could be the root problem.

Anyway I found that such configuration could be useful to include in this connector. Here is my quick solution: MailServiceFactory.zip (need new property 'mailsession.jndi.name' (example: mailsession.jndi.name=java:jboss/mail/MyMailSession) in mail-config.properties)

jonathanlukas commented 1 year ago

I wonder why I don't have any problem with the mail session..

Anyway, this is an interesting point.

Could you please provide a PR for this?

roman-mkh commented 1 year ago

@jonathanlukas thank you for your support. I was able to configure and send email on linux WildFly 27.0.1 server when this connector is used with process application (in .war, as you proposed).

jonathanlukas commented 1 year ago

@roman-mkh thank you for the feedback. I will then merge the PR