Using CDI with Flowable 7?

Hi,

I’m trying to integrate Flowable 7.1.0 into an existing software running on WildFly. This software uses JakartaEE features and CDI for dependency injection, so using Flowable’s Spring Boot integration was not an option.
I followed the instructions in the documentation to inject a ProcessEngine, but receive the following exception:

13:27:22,320 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."xxx.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."xxx.ear".WeldStartService: Failed to start service
	at org.jboss.msc@1.5.4.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1609)
	at org.jboss.msc@1.5.4.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1438)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
	at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: org.jboss.weld.exceptions.DeploymentException: Could not find an implementation of the org.flowable.cdi.spi.ProcessEngineLookup service returning a non-null processEngine. Giving up.

I have the following flowable.cfg.xml in my <module_name>/src/main/resources folder:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration"
      class="org.flowable.cdi.CdiStandaloneProcessEngineConfiguration">
    <property name="jdbcUrl" value="jdbc:mysql://xxx.xxx.xxx.xxx:xxxxx/flowable"/>
    <property name="jdbcDriver" value="com.mysql.cj.jdbc.Driver"/>
    <property name="jdbcUsername" value="flowable"/>
    <property name="jdbcPassword" value="abc"/>
    <property name="databaseSchemaUpdate" value="true"/>
  </bean>
</beans>

Here are my maven dependencies:

<dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.11.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>5.11.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>5.14.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.platform</groupId>
      <artifactId>jakarta.jakartaee-api</artifactId>
      <version>10.0.0</version>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-engine</artifactId>
      <version>7.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-cdi</artifactId>
      <version>7.0.1</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.33</version>
    </dependency>
</dependencies>

Does anyone have an example project where CDI is up and running or does anyone have idea what prevents the ServiceLoader from finding the default org.flowable.cdi.impl.LocalProcessEngineLookup implementation? I also stepped through offending the Flowable code in the FlowableExtension class that is part of the flowable-cdi library, and it just doesn’t return any implementations of the ProcessEngineLookup interface, thus returning null and crashing. Implementing one myself and then adding a file in META-INF/services like described in the documentation didn’t work either.

Cheers!

I figured that I would write an answer for anyone who might have had similar issues since I have since solved the issue. The flowable-cdi works fine - the problem was in the Maven configuration of the larger project I was trying to integrate Flowable into. On its own, the example would likely have worked without a problem.

If you are having similar issues, make sure that your .pom files are sound. In my case, I was building an .ear file but forgot to package the module that introduced Flowable as a dependency, meaning that it couldn’t be looked up at runtime.