flowable / flowable-engine

A compact and highly efficient workflow and Business Process Management (BPM) platform for developers, system admins and business users.
https://www.flowable.org
Apache License 2.0
7.92k stars 2.61k forks source link

IdmBootstrapper not triggered #3181

Open fanticat opened 2 years ago

fanticat commented 2 years ago

Describe the bug IdmBootstrapper using event.getApplicationContext().getParent() == null to avoid multiple child contexts refreshed event, but in my project, create admin user not be triggered. maybe because i use nacos as configuration, all ApplicationContext has a parent? I change the code as fowllowing, it works well.

@Autowired
ApplicationContext applicationContext;

@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) {
    if (event.getApplicationContext().equals(this.applicationContext)) {
        System.out.println("Fired only once!");
    }
}

Code

 @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (event.getApplicationContext().getParent() == null) { // Using Spring MVC, there are multiple child contexts. We only care about the root

            if ((ldapProperties == null || !ldapProperties.isEnabled()) && !idmAppProperties.getKeycloak().isEnabled()) {
                if (idmAppProperties.isBootstrap()) {
                    // First create the default IDM entities
                    createDefaultAdminUserAndPrivileges();
                }

            } else {

Additional context Flowable: 6.7.2 Springboot: 2.6.2

icuxika commented 2 years ago

I had the same problem.