How to integrate flowable-form-engine to a spring-boot application

Hi Brothers!

I wold like to know how to config my spring-boot-app to work with the flowable-form-engine. I have include the following dependencies:

  • flowable-spring-boot-starter-jpa
  • flowable-form-engine
  • flowable-form-engine-configurator
  • flowable-form-spring

My Java context looks like:

public class VcDataConfig {

@Autowired
private DataSource dataSource;

@Autowired
private PlatformTransactionManager transactionManager;

@Bean
public SpringFormEngineConfiguration formEngineConfiguration() {

    SpringFormEngineConfiguration configuration = new SpringFormEngineConfiguration();

    configuration.setDataSource(dataSource);
    configuration.setTransactionManager(transactionManager);
    configuration.setDatabaseSchemaUpdate("true");
    configuration.setDeploymentMode("single-resource");

    return configuration;
}

@Bean
public FormEngine formEngine() throws Exception {

    FormEngineFactoryBean formEngineFactoryBean = new FormEngineFactoryBean();
    formEngineFactoryBean.setFormEngineConfiguration(formEngineConfiguration());

    return formEngineFactoryBean.getObject();
}

@Bean
public FormManagementService formManagementService() throws Exception {
    return formEngine().getFormManagementService();
}

@Bean
public FormRepositoryService formRepositoryService() throws Exception {
    return formEngine().getFormRepositoryService();
}

}

When I try to complete a task I’m getting the exception: org.flowable.engine.common.api.FlowableIllegalArgumentException: Form engine is not initialized

I found the solution. Is just implement the interface ProcessEngineConfigurationConfigurer in a bean and pass a FormEngineConfigurator to the processEngineConfiguration.

Anyway, thank you.

Hi, can you tell me the exact complete process maybe share the code on how to use form-engine and dmn-engine with spring-boot?

It would be something like this (haven’t tried it, but this is the idea):

@Bean
public ProcessEngineConfigurationConfigurer configurationConfigurer() {
    return new ProcessEngineConfigurationConfigurer() {
        public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
            processEngineConfiguration.addConfigurator(new FormEngineConfigurator());
            processEngineConfiguration.addConfigurator(new DmnEngineConfigurator());
        }
    };
}

Hi joram,
thank you for the quick reply. Can you tell me how to integrate form api and dmn api with the spring-boot. I have added these dependencies :

org.flowable flowable-spring-boot-starter-basic 6.1.2
	<dependency>
	    <groupId>org.flowable</groupId>
	    <artifactId>flowable-spring-boot-starter-rest-api</artifactId>
	    <version>6.1.2</version>
	</dependency>
	
	
	<dependency>
	    <groupId>org.flowable</groupId>
	    <artifactId>flowable-form-spring-configurator</artifactId>
	    <version>6.1.2</version>
	</dependency>
	
	
	<dependency>
	    <groupId>org.flowable</groupId>
	    <artifactId>flowable-dmn-spring-configurator</artifactId>
	    <version>6.1.2</version>
	</dependency>
	
	<dependency>
	    <groupId>org.flowable</groupId>
	    <artifactId>flowable-rest</artifactId>
	    <version>6.1.2</version>
	</dependency>
	
	<dependency>
	    <groupId>org.flowable</groupId>
	    <artifactId>flowable-form-rest</artifactId>
	    <version>6.1.2</version>
	</dependency>
	
	<dependency>
	    <groupId>org.flowable</groupId>
	    <artifactId>flowable-form-api</artifactId>
	    <version>6.1.2</version>
	</dependency> 

But i am still not able to access : “form-repository/deployments” or any other form api.

1 Like

Besides the configurators, did you also add the configurationConfigurer bean from above?
If so, the form and dmn engine can be retrieved for example from the DmnEngines lookup class.

I have followed the given instructions , I have added the bean ProcessEngineConfigurationConfigurer as suggested by joram ,

@Configuration
public class ProcessEngineConfig {
@Bean
public ProcessEngineConfigurationConfigurer configurationConfigurer() {
return new ProcessEngineConfigurationConfigurer() {
public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
processEngineConfiguration.addConfigurator(new FormEngineConfigurator());
processEngineConfiguration.addConfigurator(new DmnEngineConfigurator());
}
};
}
}"

Then I added dependencies, but when trying to run the project I got the following error:

" Error creating bean with name ‘org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration’: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)"

I think it is the same error reported at:
https://forum.flowable.org/t/adding-form-engine-and-dmn-engine-in-spring-boot/799

those are the dependencies I have in my pom.xml

	<dependency>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-spring-boot-starter-rest-api</artifactId>
		<version>${flowable.version}</version>
	</dependency>

	<dependency>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-spring-boot-starter-jpa</artifactId>
		<version>${flowable.version}</version>
	</dependency>

	<dependency>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-form-spring-configurator</artifactId>
		<version>${flowable.version}</version>
	</dependency>


	<dependency>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-dmn-spring-configurator</artifactId>
		<version>${flowable.version}</version>
	</dependency>
	

	<dependency>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-form-rest</artifactId>
		<version>${flowable.version}</version>
	</dependency>

	<dependency>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-form-api</artifactId>
		<version>${flowable.version}</version>
	</dependency>

what am i doing wrong?, thanks in advance!!!

Hi Joram,

@Bean
public SpringDmnEngineConfiguration dmnEngineConfigure() {
	SpringDmnEngineConfiguration sdec = new SpringDmnEngineConfiguration();
	sdec.setDataSource(dataSource);
	sdec.setTransactionManager(transactionManager);
	sdec.setDatabaseSchemaUpdate("true");
	sdec.setDeploymentMode("single-resource");
	return sdec;
}

@Bean
public DmnEngineConfigurator dmnEngineConfigurator() {
	DmnEngineConfigurator dec = new DmnEngineConfigurator();
	dec.setDmnEngineConfiguration(dmnEngineConfigure());
	return dec;
}

@Bean
public DmnEngine getDmnEngine(SpringDmnEngineConfiguration sdec) {
	return sdec.buildDmnEngine();
}

@Bean
public SpringFormEngineConfiguration formEngineConfigure() {
	SpringFormEngineConfiguration sfec = new SpringFormEngineConfiguration();
	sfec.setDataSource(dataSource);
	sfec.setTransactionManager(transactionManager);
	sfec.setDatabaseSchemaUpdate("true");
	sfec.setDeploymentMode("single-resource");
	return sfec;
}

@Bean
public FormEngineConfigurator formEngineConfigurator() {
	FormEngineConfigurator dec = new FormEngineConfigurator();
	dec.setFormEngineConfiguration(formEngineConfigure());
	return dec;
}

@Bean
public FormEngine getFormEngine(SpringFormEngineConfiguration sfec) {
	return sfec.buildFormEngine();
}

@Bean
public FormRepositoryService getFormRepositoryService(SpringFormEngineConfiguration sfec) {
	return getFormEngine(sfec).getFormRepositoryService();
}

@Bean
public BeanPostProcessor activitiConfigurer() {
	return new BeanPostProcessor() {
		@Override
		public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
			if (bean instanceof SpringProcessEngineConfiguration) {
				List<ProcessEngineConfigurator> config = new ArrayList<ProcessEngineConfigurator>();
				config.add(dmnEngineConfigurator());
				config.add(formEngineConfigurator());
				((SpringProcessEngineConfiguration) bean).setConfigurators(config);
			}
			return bean;
		}

		@Override
		public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
			return bean;
		}
	};
}

This is the code i am using. Is their anything i am missing?
Here i am talking about Rest API for form and DMN which are not working.

Thank You,

HI,

I dont know how correct or wrong this solution is, but for me this works. i added

<?xml version="1.0" encoding="UTF-8"?> 
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
 
</databaseChangeLog> 

this to a file named “db.changelog-master.xml” and put this file into resources/db/changelog. It worked but i am not sure if this is the correct way to do it. I am also exploring things.

1 Like

If i working on tomcat server, do i need to change any file? and form that i created in “flowable-modeler” is not reflecting in “flowable-admin” of Form Engine Deployments