AnsweredAssumed Answered

JobExecutor Stops in Clustered Enviorment

Question asked by er3n on Jun 21, 2012
Latest reply on Jun 21, 2012 by frederikheremans1
Hi
  We are using activiti engine in our project in clustered enviorment. We are getting an error like.


java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
   at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
   at org.springframework.context.support.AbstractApplicationContext.containsBean(AbstractApplicationContext.java:1091)
   at org.activiti.engine.impl.cfg.SpringBeanFactoryProxyMap.containsKey(SpringBeanFactoryProxyMap.java:46)
   at org.activiti.engine.impl.scripting.BeansResolverFactory.containsKey(BeansResolverFactory.java:30)
   at org.activiti.engine.impl.scripting.ScriptBindings.containsKey(ScriptBindings.java:52)
   at javax.script.SimpleScriptContext.getAttributesScope(SimpleScriptContext.java:265)
   at com.sun.script.javascript.ExternalScriptable.put(ExternalScriptable.java:159)
   at com.sun.script.javascript.RhinoScriptEngine.getRuntimeScope(RhinoScriptEngine.java:285)
   at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:145)
   at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:167)
   at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:216)
   at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:75)
   at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:43)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:500)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:492)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:500)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:492)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:500)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:492)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:50)

We are starting JobExeturors in a thread manualy with the method above.

@Override
   public void run() {
      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
      if(((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getJobExecutor().isActive()==false){
         
         try {
            Thread.sleep(300000);
         } catch (InterruptedException e) {
            logger.fatal("JobExecutor aktiflestirme sirasinda interrupt geldi. JobExecutor aktiflestirilemedi!!!");
            return;
         }
         ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getJobExecutor().start();
         logger.info("JobExecutor aktiflestirme basarili.");
         

      } else {
         logger.info("JobExecutor zaten aktif.");
      }

When i get this error, without stoping application, i am calling ;
   
  ( (ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getJobExecutor().isActive()
and it return false but when job duedate reached jobexecuter triggers jobs.

To sum up my problem is proccess engine looses referance to JobExecutor and when jobExecutor triggers i get (BeanFactory not initialized or already closed ) error. I am manualy start proccess engine again at the runtime problem is solved but after a little time latter job executor getting the same error again and
   
  ( (ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getJobExecutor().isActive()

returns false.

Also my spring configuration is:

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="databaseType" value="oracle" />
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="hibernateTransactionManager" />
      <property name="databaseSchemaUpdate" value="false" />
      <property name="history" value="audit" />
      <property name="jobExecutorActivate" value="false" />
      <property name="jobExecutor" ref="jobExecutor"/>
      <property name="idBlockSize" value="${activiti.processEngineConfiguration.idBlockSize}"/>
   </bean>

   <bean id="jobExecutor" class="org.activiti.engine.impl.jobexecutor.JobExecutor">
      <property name="corePoolSize" value="${activiti.jobExecutor.corePoolSize}"/>
      <property name="lockTimeInMillis" value="${activiti.jobExecutor.lockTimeInMillis}"/>
      <property name="maxJobsPerAcquisition" value="${activiti.jobExecutor.maxJobsPerAcquisition}"/>
      <property name="maxPoolSize" value="${activiti.jobExecutor.maxPoolSize}"/>
      <property name="queueSize" value="${activiti.jobExecutor.queueSize}"/>
      <property name="waitTimeInMillis" value="${activiti.jobExecutor.waitTimeInMillis}"/>
   </bean>

Do u have any idea about this problem?

Kind regards…
Eren Öztürk

Outcomes