Flowable-custom-context.xm is too bad as configuration sample!

Hi!

After a hard battle configuring the FLOWABLE-REST to implement a custom authentication method.

I think is better to others that tries the same, is better to everyone an update of the flowable-custom-context.xml that comes into the flowable-rest.war to avoid this error:

WARN org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dmnEngineConfiguration' defined in class path resource [org/flowable/rest/conf/FlowableEngineConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flowable.dmn.api.DmnEngineConfigurationApi]: Factory method 'dmnEngineConfiguration' threw exception; nested exception is java.lang.ClassCastException: org.flowable.spring.ProcessEngineFactoryBean$$EnhancerBySpringCGLIB$$da38e03d cannot be cast to org.flowable.engine.ProcessEngine

And many other errors like thatā€¦ until figure out.

As the flowable-custom-context.xml comes is too far to make this works!

A better approach of this configuration sample:

<?xml version="1.0" encoding="UTF-8"?>

<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
	<property name="driverClass" value="com.mysql.jdbc.Driver" />
	<property name="url" value="jdbc:mysql://127.0.0.1:3306/flowable?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true" />
	<property name="username" value="root" />
	<property name="password" value="" />
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
	<property name="dataSource" ref="dataSource" />
</bean>

<bean id="dmnEngineConfigurator" class="org.flowable.dmn.spring.configurator.SpringDmnEngineConfigurator" />
<bean id="formEngineConfigurator" class="org.flowable.form.spring.configurator.SpringFormEngineConfigurator" />
<bean id="contentEngineConfigurator" class="org.flowable.content.spring.configurator.SpringContentEngineConfigurator" />

<bean id="processEngineConfiguration" class="org.flowable.spring.SpringProcessEngineConfiguration">
	<property name="dataSource" ref="dataSource" />
	<property name="transactionManager" ref="transactionManager" />
	<property name="databaseSchemaUpdate" value="true" />
	<property name="mailServerHost" value="localhost" />
	<property name="mailServerPort" value="5025" />
	<property name="customFormTypes">
		<list>
			<bean class="org.flowable.rest.form.UserFormType" />
			<bean class="org.flowable.rest.form.ProcessDefinitionFormType" />
			<bean class="org.flowable.rest.form.MonthFormType" />
		</list>
	</property>
	<property name="configurators">
		<list>
			<ref bean="dmnEngineConfigurator" />
			<ref bean="formEngineConfigurator" />
			<ref bean="contentEngineConfigurator" />
		</list>
	</property>
</bean>

<bean id="processEngineFactoryBean" class="org.flowable.spring.ProcessEngineFactoryBean">
	<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>

<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />

This post help me to solve this puzzle: How to configure flowable-rest.war using JNDI

But not works at firstā€¦ because the some extra that is not necessary.

Maybe the default flowable-custom-context.xml is too old and the sample commented is from older versions, but is clear to me that donā€™t helps.

Hope this help someone.

1 Like

Thanks Eduveks!

I was having some issues configuring the rest api with MySQL and your flowable-custom-context.xml fixed my issues.

Hi. Thanks for posting a solution. Iā€™m at witā€™s endā€¦ copied your config above (with different database) and still getting this error:

2018-03-11 22:50:27.411:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@7e0b0338{/flowable-rest,file:///flowable/webapps/flowable-rest/,UNAVAILABLE}{/flowable-rest}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ā€˜dmnEngineConfigurationā€™ defined in class path resource [org/flowable/rest/conf/FlowableEngineConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flowable.dmn.api.DmnEngineConfigurationApi]: Factory method ā€˜dmnEngineConfigurationā€™ threw exception; nested exception is java.lang.ClassCastException: org.flowable.spring.ProcessEngineFactoryBean$$EnhancerBySpringCGLIB$$da38e03d cannot be cast to org.flowable.engine.ProcessEngine