Flowable connection with MongoDB

Hi Team,

We recently tried to connect the latest Flowable version (6.4.0.alpha) with MongoDB as per the instruction provided in Read.md file on GitHub. We used 4.0.2 version of MongoDB to connect to Flowable. But while running the application we were facing issues with the startSession method. The error which we faced is as below :


Exception in thread “main” java.lang.NoSuchMethodError: com.mongodb.MongoClient.startSession(Lcom/mongodb/ClientSessionOptions;)Lcom/mongodb/client/ClientSession;
at org.flowable.mongodb.persistence.MongoDbSession.(MongoDbSession.java:69)
at org.flowable.mongodb.persistence.MongoDbSessionFactory.openSession(MongoDbSessionFactory.java:151)
at org.flowable.common.engine.impl.interceptor.CommandContext.getSession(CommandContext.java:241)
at org.flowable.mongodb.transaction.MongoDbTransactionContext.(MongoDbTransactionContext.java:46)
at org.flowable.mongodb.transaction.MongoDbTransactionContextFactory.openTransactionContext(MongoDbTransactionContextFactory.java:29)
at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:47)
at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:71)
at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
at org.flowable.engine.impl.ProcessEngineImpl.(ProcessEngineImpl.java:78)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:888)
at com.example.test.TestApplication.main(TestApplication.java:26)


Post this error, we tried to run the Junit Test cases using the replicate set of Mongo instances, which was executed successfully. Which infers there is no issue with the Mongo version, but still we are not able to run the Springboot application, where we injected Flowable engine dependencies.

Image attached contains the code, dependencies and the error which we faced.
Please go through it once and let us know in case we forget to add something or missed some configuration.

Thanks in advance.!

errorImg

First of all many thanks for trying it out :-)!

I see in your dependencies you’re using Spring Boot. There is an annoying thing when using Spring Boot + latest MongoDB that I also noticed when building an example: the version of the driver gets overridden by the parent pom.

To fix it, you need to set explicitly the version, see here: https://github.com/flowable/flowable-examples/blob/master/demo/demo-jax-2018/demo-process-mongo/pom.xml#L22
Also, I’ve excluded the driver there in the pom, just to be sure (but don’t think it’s needed).

We’ve planned to add our own flowable-mongo starter when using Spring Boot, this will also solve this.

1 Like

Hi Joram,

Thanks for the solution. It worked for us.

Now we have a situation where we want to use only flowable-rest module for all the transaction, which we were able to used directly by deploying previous versions war file in tomcat. But if we want to use flowable-rest module with MongoDB , then how can we achieve that?

Awaiting for your response.

That’s currently not possible out of the box. To do it, you’d need to clone the flowable-rest code and change the engine configuration to the MongoDb one, and then rebuild. The reason is because there’s a mismatch with the type in the default Spring Boot config (it’s SpringProcessEngineConfiguration, which doesn’t exist yet for MongoDb). This is something we want to fix soon.

@Kratyos one way to achieve this could be by pulling the flowable-spring-boot-autoconfigure and and provide your own configuration for the ProcessEngine and ProcessEngineConfiguration based on MongoDB. Then pull the flowable-rest dependency into your project. With this you should be able to have the process REST api under process-api.

Note: I have not tried this myself yet.