flowable-engine icon indicating copy to clipboard operation
flowable-engine copied to clipboard

IdmBootstrapper not triggered

Open fanticat opened this issue 4 years ago • 1 comments

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

fanticat avatar Jan 20 '22 03:01 fanticat

I had the same problem.

icuxika avatar Mar 08 '22 06:03 icuxika