Spring Boot Bean configuration

Hello everyone,

Essentially, I want dashes (-) to be allowed in group names. I’ve having trouble determining the correct place to configure the property ‘groupResourceWhitelistPattern’ on the Process Engine in the context of a Spring Boot app. This is likely due to my unfamiliarity with the Spring Boot ecosystem at large, but searching general SB resource hasn’t been particularly enlightening.

I’ve tried:

  • setting a <property name="groupResourceWhitelistPattern">[1-9a-zA-Z-]+</property> in processes.xml - it appears to be ignored.
  • Having a @Configuration class extend SpringProcessEngineConfiguration, and overriding getGroupResourceWhitelistPattern() - NPE on startup
  • creating camunda.cfg.xml with the below - also ignored :
    <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration">
        <property name="groupResourceWhitelistPattern" value="[1-9a-zA-Z-]+" />
    </bean>

Any help greatly appreciated!

Many thanks,

Simon

Update:

The duplicate bean definition error from the last one can be solved by setting:

spring.main.allow-bean-definition-overriding=true in application.properties

however, this yields the following error:

Description:

Field processEngineConfigurationImpl in org.camunda.bpm.spring.boot.starter.CamundaBpmAutoConfiguration$ProcessEngineConfigurationImplDependingConfiguration required a bean of type 'org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl' that could not be found.

The following candidates were found but could not be injected:
	- Bean method 'processEngineConfigurationImpl' in 'CamundaBpmConfiguration' not loaded because @ConditionalOnMissingBean (types: org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; SearchStrategy: all) found beans of type 'org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl' processEngineConfiguration

Action:

Consider revisiting the entries above or defining a bean of type 'org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl' in your configuration.

You should not create a new configuration bean and hassle with the spring context set up … the idea of the starter is that additional configuration is done via ProcessEnginePlugins, or as they are called in the camunda starter: CamundaProcessEngineConfiguration.

You provide a bean of that type, override the “preInit” method and use the configuration instance you get passed to call additional setters for your custom configuration.

For reference, have a look at how the history level is set: https://github.com/camunda/camunda-bpm-spring-boot-starter/blob/master/starter/src/main/java/org/camunda/bpm/spring/boot/starter/configuration/impl/DefaultHistoryConfiguration.java

as long as your configuration class makes its way in the spring context (@Bean or @Component), it will be automatically applied.

1 Like

Thanks Jan, that did the trick.

Specifically, to set the group white list pattern to allow ‘-’ in general:

@Configuration
public class MyProcessEngineConfiguration extends AbstractCamundaConfiguration implements CamundaProcessEngineConfiguration {

    @Override
    public void preInit(SpringProcessEngineConfiguration configuration) {
        setGroupResourceWhitelistPattern(configuration);
    }

    private void setGroupResourceWhitelistPattern(SpringProcessEngineConfiguration configuration) {
        configuration.setGroupResourceWhitelistPattern("[a-zA-Z0-9-]+");
    }

}

Hi @simonwibberley,

another option could be the generic configuration property: https://docs.camunda.org/manual/7.12/user-guide/spring-boot-integration/configuration/#generic-properties

Hope this helps, Ingo