AnsweredAssumed Answered

Activiti initializes engine twice under WebLogic

Question asked by mmaker1234 on Jun 22, 2012
Latest reply on Jun 22, 2012 by mmaker1234
Hello,

I tried to run Activiti as a library in our application on WebLogic. What I observe is that Activiti finds the (single) configuration twice and initializes the engine twice. Here is an excerpt from the start log:

INFO | 2012-06-22 08:19:30.182 | workflow.engine.WfEngineManager | startEngine
Looking for workflow engines to start…

INFO | 2012-06-22 08:19:30.189 | org.activiti.engine.ProcessEngines | initProcessEnginFromResource
initializing process engine for resource zip:/home/weblogic1035/user_projects/domains/mydomain/servers/AdminServer/tmp/_WL_user/workflow/tizqbw/workflow.jar!/activiti.cfg.xml
- Loading XML bean definitions from resource loaded through InputStream

INFO | 2012-06-22 08:19:31.519 | org.activiti.engine.impl.ProcessEngineImpl | <init>
ProcessEngine myWFengine created

INFO | 2012-06-22 08:19:31.519 | org.activiti.engine.impl.jobexecutor.JobExecutor | start
Starting up the JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor].

INFO | 2012-06-22 08:19:31.523 | org.activiti.engine.ProcessEngines | initProcessEnginFromResource
initialised process engine myWFengine

INFO | 2012-06-22 08:19:31.527 | org.activiti.engine.impl.jobexecutor.AcquireJobsRunnable | run
JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor] starting to acquire jobs

INFO | 2012-06-22 08:19:31.527 | org.activiti.engine.ProcessEngines | initProcessEnginFromResource
initializing process engine for resource zip:/home/weblogic1035/user_projects/domains/mydomain/servers/AdminServer/tmp/_WL_user/workflow/tizqbw/workflow.jar!/activiti.cfg.xml
- Loading XML bean definitions from resource loaded through InputStream

INFO | 2012-06-22 08:19:33.413 | org.activiti.engine.impl.ProcessEngineImpl | <init>
ProcessEngine myWFengine created

INFO | 2012-06-22 08:19:33.413 | org.activiti.engine.impl.jobexecutor.JobExecutor | start
Starting up the JobExecutor[org.activiti.engine.impl.jobexecutor.DefaultJobExecutor].

INFO | 2012-06-22 08:19:33.413 | org.activiti.engine.ProcessEngines | initProcessEnginFromResource
initialised process engine myWFengine

INFO | 2012-06-22 08:19:33.414 | workflow.engine.WfEngineManager | startEngine
The available 1 workflow engines have been started.
(Please note the duplication of the resource URL)

To remove the redundant initializations I propose in the init() method of ProcessEngines class to replace
      while (resources.hasMoreElements()) {
        URL resource = resources.nextElement();
        initProcessEnginFromResource(resource);
      }
with
      //Remove duplicated configuration URLs
      Set<URL> configUrls = new HashSet<URL>();
      while (resources.hasMoreElements()) {
        configUrls.add( resources.nextElement() );
      }
      //Init engines
      for (Iterator<URL> iterator = configUrls.iterator(); iterator.hasNext();) {
        URL resource = iterator.next();
        initProcessEnginFromResource(resource);
      }

Outcomes