Integrate flowable with spring boot


#1

Hello, I followed this https://blog.flowable.org/2018/12/19/building-your-own-flowable-spring-boot-application/ blog post to build a spring boot api, but I don’t know how to configure postgresql(the official doc is too much complicated for me), can anyone help me, I’m new to java and spring boot


#2

Hi @xcaptain,

You just need to configure your data source pointing to the postgres database. You can do this setting these parameters in your application.properties or as environment variables:

spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://:5432/flowable
spring.datasource.username=flowable
spring.datasource.password=flowable


#3

Demo project is at https://github.com/xcaptain/flowable-demo

I added postgresql in pom.xml and added FlowableConfig which I think will load all beans defined in flowable.cfg.xml, but still can’t run.

	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:330) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:273) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1237) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	... 98 common frames omitted
Caused by: org.flowable.common.engine.api.FlowableException: Could not update Flowable database schema: unknown version from database: '6.4.1.3'
	at org.flowable.common.engine.impl.FlowableVersions.getFlowableVersionIndexForDbVersion(FlowableVersions.java:146) ~[flowable-engine-common-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.db.ProcessDbSchemaManager.schemaUpdate(ProcessDbSchemaManager.java:184) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:54) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:28) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:51) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:93) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:72) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:56) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:25) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53) ~[flowable-engine-common-6.4.0.jar:6.4.0]
	at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:71) ~[flowable-engine-common-6.4.0.jar:6.4.0]
	at org.flowable.common.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:49) ~[flowable-spring-common-6.4.0.jar:6.4.0]
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:46) ~[flowable-spring-common-6.4.0.jar:6.4.0]
	at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) ~[flowable-engine-common-6.4.0.jar:6.4.0]
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56) ~[flowable-engine-common-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:78) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:888) ~[flowable-engine-6.4.0.jar:6.4.0]
	at org.flowable.spring.SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:72) ~[flowable-spring-6.4.0.jar:6.4.0]
	at org.flowable.engine.spring.configurator.SpringProcessEngineConfigurator.initProcessEngine(SpringProcessEngineConfigurator.java:58) ~[flowable-spring-configurator-6.4.0.jar:6.4.0]
	at org.flowable.engine.spring.configurator.SpringProcessEngineConfigurator.configure(SpringProcessEngineConfigurator.java:47) ~[flowable-spring-configurator-6.4.0.jar:6.4.0]
	at org.flowable.common.engine.impl.AbstractEngineConfiguration.configuratorsAfterInit(AbstractEngineConfiguration.java:859) ~[flowable-engine-common-6.4.0.jar:6.4.0]
	at org.flowable.app.engine.AppEngineConfiguration.init(AppEngineConfiguration.java:224) ~[flowable-app-engine-6.4.0.jar:6.4.0]
	at org.flowable.app.engine.AppEngineConfiguration.buildAppEngine(AppEngineConfiguration.java:182) ~[flowable-app-engine-6.4.0.jar:6.4.0]
	at org.flowable.app.spring.SpringAppEngineConfiguration.buildAppEngine(SpringAppEngineConfiguration.java:61) ~[flowable-app-engine-spring-6.4.0.jar:6.4.0]
	at org.flowable.app.spring.AppEngineFactoryBean.getObject(AppEngineFactoryBean.java:59) ~[flowable-app-engine-spring-6.4.0.jar:6.4.0]
	at org.flowable.app.spring.AppEngineFactoryBean.getObject(AppEngineFactoryBean.java:31) ~[flowable-app-engine-spring-6.4.0.jar:6.4.0]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.1.3.RELEASE.jar:5.1.3.RELEASE]
	... 108 common frames omitted

I think this error log means some flowable beans can’t setup correctly, but I don’t know why.


#4

Fixed this error in https://github.com/xcaptain/flowable-demo/commit/85bf9fcb4ea00f358dd6f8b7cc95f91306672f7e

it’s because I once build flowable from source, so in act_ge_property table, flowable version becomes 6.4.1.3, after I upgraded flowable-spring-boot-starter-rest version to 6.4.1-SNAPSHOT problem solved.


#5

Thanks, you are right, only need to add these lines to application.properties, no need to add flowable.cfg.xml stuff.


#6

I connected this spring api to existed flowable database, I can use the rest api to get process and tasks, but can’t start new process instance.

the error log says:

org.flowable.common.engine.api.FlowableException: Could not find org.flowable.http.HttpActivityBehavior:

#7

In this commit https://github.com/xcaptain/flowable-demo/commit/517d2617c7cef8648bdc0f3a8c583f5ed828e82c

after added

<dependency>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-http</artifactId>
    <version>6.4.1-SNAPSHOT</version>
</dependency>

to pom.xml, my demo app builds.

Original discuss can be found at https://github.com/flowable/flowable-engine/issues/458, https://github.com/flowable/flowable-engine/pull/459/files

Would be good to add this to flowable-spring-boot-starter-rest package.


#8

I added event listener in https://github.com/xcaptain/flowable-demo/commit/a3eb491b7c78efce459deb08d9e15838bb0721d6, works fine but don’t know why event listener config in flowable.cfg.xml doesn’t work, so I added a EventRegisterCommandLineRunner class to register flowable event listener at start up.