Embedded ProcessEngine and ServletProcessApplication: contextInitialized called twice

Hello :slight_smile:

I’ve got a JBoss EAP 7.2 installation with the camunda version 7.11.19 installed as modules. Within my standalone.xml there is a process engine ‘default’ configured. And a ‘default’ JobExecutor.

For some reason I have to deploy my application with a embedded process engine and I want to deploy my Process-Application with a subclass of the ServletProcessApplication.

I changed the jboss-deployment.xml to exclude all possibly available camunda-modules; so I’m sure, there should no classpath conflicts with the camunda artifacts I deploy together with my application.war.

The embedded engine is configured with a JtaProcessEngineConfiguration and the name of the engine is not ‘default’.

My plan was to bootstrap the embedded engine when it comes to deploy my ProcessApplication. Since this is a ServletProcessApplication, I check within the contextInitialized-Method, if my engine is - for any reason - already bootstrapt. If this is the case, I don’t bootstrap it again but just deploy the application. If it is not bootstraped already, I do the engine bootstrap and afterwards I deploy the application.

Everything works pretty fine. But for any reason, the contextInitialized-Method ist called twice!

For the first time, the engine is not bootstraped, so this is done before the deployment; for the second time, the method recognizes the already bootstraped engine and does no bootstraping anymore but just the deployment.

And then it comes to the error, saying the application can’t be deployed because there is a application with the same name already registered.

When I erase the camunda-subsystem (engine plus JobExecutor), the bootstrap and deployment just works as it it is supposed to work.

How can I figure out, why the contextInitialized is called twice?
How can I figure out, that my application is deployed already and registered to my engine?

And a bit other topic but related to my problem:

When I start my application with a embedded Engine and not the ‘default’ name, for example the listeners within my process-definitions are not recognized anymore when I try to complete a human-task within the camunda-webapps. I deploy the camunda-webapps with a embedded engine as well. To make the camunda-webapps able to connect to the same database as my application-embedded-engine does, I changed the applicationContext.xml. But I changed only the database-parameter not the engine name.

How would the camunda-webapp know of the listeners etc. which are deployed together with my application? Or do I have to use the same process-engine as my application does? In that case: do I have to take care of a correct deployment sequence (like application deployment before the webapp-deployment).

Thanks in advance

Dieter