Run code after database creation in spring boot


for setting up default permissions I am creating and saving authorizations in the postInit-Method of the SpringBootProcessEnginePlugin:

public class MyProcessEngineConfiguration extends AbstractCamundaConfiguration implements CamundaProcessEngineConfiguration {
    private final Logger logger = getLogger(WebAppSecurityConfig.class.getName());

    public void postInit(SpringProcessEngineConfiguration configuration) {

// lines omitted


This works if the database has already been created. But during the first startup in a test run, the database tables are not yet created when postInit method runs and setupPermissions fails.

Is it possible to run code after the database tables have been created?


The way to do something like that is to jump into the ProcessEngine’s lifecylce creation, instead of Spring’s. To do so, create a ProcessEnginePlugin implementation and add your initialisation to the postProcessEngineBuild method that passes you the engine that was built (the others give you the configuration). At that point you’re gauranteed that not only the tables are in place, but you can use the ProcessEngine’s services to work with them.


Thanks for the hint. I have implemented a ProcessEnginePlugin like this and it works now.

public class SetupDefaultPermissionsPlugin extends AbstractProcessEnginePlugin {

    public void postProcessEngineBuild(ProcessEngine processEngine) {

[setupPermissions: code omitted]
1 Like

Great! Happy to see that worked out :slight_smile: