Hello!
i try to get activiti-cdi in an ear (a war, some ejbs, a pu jar and some libs) up and running and i seem to struggle with it.
What i tried first was to define dependencies in my wars pom and all activiti-cdi dependencies was therefore placed in the wars lib folder. The issue there was that it did not find the wars /WEB-INF/classes/META-INF/services/org.activiti.cdi.spi.ProcessEngineLookup and my implementation of the service interface. And, the service provided by activiti-cdi.jar was not found either. I found out that activiti-cdi is initialized using the ears classloader and therefore the wars libs and classes were not visible and thus the engine was not initialized.
The next attempt was to place activiti-cdi into the libs folder of the ear, there the engine was initialized, but due to the fact that the engine was initialized using cdi i was not able to hand in an EntityManagerFactory using a jndi lookup in the Spring based activiti.cfg.xml. The jndi context (the wars persistence-unit-ref) is not available in this phase where i can get a EntityManagerFactory. Using the jpaPersistenceUnitName property does not lead to the containers EntityManagerFactory to be used.
The next attempt, to initialize the engine programmatically using an ejb where i can use the PersistenceUnit annotation to get the EntityManagerFactory and set the other settings and build the engine resulted in an exception of the ActivitiExtension complaining that it could not initialize an engine because it does not find one. Yes, i did not place an META-INF/service or activiti.cfg.xml because i wanted to boot it programmatically. Is activiti-cdi simply not usable when the engine is initialized programmatically? And if the engine could be
initialized programmatically, how i can add it to cdi so that injection works? I thought of using ActivitiServices which can be injected because its ApplicationScoped to my ActivitiBooterEJB and set my constructed engine there to be in place when the Producer needs it.
Maybe somebody has some experience with Activiti initialization in an ear context where the webapp is jsf based and wants to use the comfort of cdi in combination with Activiti? There are already a lot of postings around explaining various deployment scenarios, but all of them are only a vew line of code or xml snippets and none covers the or a 'big picture'. And it seems my experiences are not so deep that i can apply those snippets to my environment successfully.
And, additionally, how about timer events? In what context are they fired? Is cdi usable there as well? If i imagine that the job executor of Activiti is run by a ThreadPool, i think cdi can not be available when a Activiti job is executed there. Till now i was only play with the basic samples where none of the JEE features mixed up things.
Thank u for some insights.