cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti initializes engine twice under WebLogic

mmaker1234
Champ in-the-making
Champ in-the-making
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);
      }
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
Seems like a valid improvement. I'll add this to trunk. To prevent this issue for now, maybe best to initialize the engine yourself, based on the configuration-file URL rather that just use the "default" initialization.

mmaker1234
Champ in-the-making
Champ in-the-making
Hello Frederik,

Thank you for your quick reply!

We also thought on the approach to provide a configuration URL but here are our concerns:
- We prefer to non burden our administrators with file placements and application configuration tasks;
- Our application is deployed in different directories on the different servers (dev, test, prod, …)  because some of them share the same file/operating system;
- WebLogic (as you can see in the provided log excerpt) unpacks the application .EAR(s) in different temporary directories.
As a consequence:
- It is not easy to "invent" an URL that to be valid on all environments where our application works
- We decided to deliver the Activiti configuration with our .EARs and to use the "default" initialization;

The original post was not a complaint (in contrast to http://forums.activiti.org/en/viewtopic.php?f=6&t=4121&p=16036 where I still expect an answer) - I only shared our experience. Actually the duplicated WF engine initialization is not a big issue for us:
- The first engine is stopped during the second initialization because the engine names appear to be equal;
- The initialization is fast enough (a couple of seconds, as you can see in the logs);
- As a result we have only one engine, which is the desired behavior;
- I already patched Activiti 5.9 and built it for our environment.