cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to initiazlize process engine

afshad
Champ in-the-making
Champ in-the-making
I am unable to initialize the process engine. My code is as follows:
            ProcessEngines.init();
            ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
It returns processEngine as null.
I am not using the spring framework. Just a java project with the activiti jar and its other dependent jars.
The config file activiti.cfg.xml is what i got from the activiti setup:

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
 
    <property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />
   
    <!– Database configurations –>
    <property name="databaseSchemaUpdate" value="true" />
   
    <!– job executor configurations –>
    <property name="jobExecutorActivate" value="false" />
   
    <!– mail server configurations –>
    <property name="mailServerPort" value="5025" />   
  </bean>

</beans>

While debugging i see that in init(), there resources has no elements. What could be the cause of this??

  public synchronized static void init() {
    if (!isInitialized) {
      if(processEngines == null) {
        // Create new map to store process-engines if current map is null
        processEngines = new HashMap<String, ProcessEngine>();       
      }
      ClassLoader classLoader = ReflectUtil.getClassLoader();
      Enumeration<URL> resources = null;
      try {
        resources = classLoader.getResources("activiti.cfg.xml");
      } catch (IOException e) {
        throw new ActivitiException("problem retrieving activiti.cfg.xml resources on the classpath: "+System.getProperty("java.class.path"), e);
      }
////NOTE resources has no elements here. So never enters the while
      while (resources.hasMoreElements()) {
        URL resource = resources.nextElement();
        initProcessEnginFromResource(resource);
      }

Thank you.
3 REPLIES 3

afshad
Champ in-the-making
Champ in-the-making
Its ok I finally got activiti to work with OSGI

mhp
Champ in-the-making
Champ in-the-making
I am also having this same problem for initializing the process engine…
can u please reply how u did this..
Its very urgent for me…

afshad
Champ in-the-making
Champ in-the-making
I hope the following code helps you:

            ProcessEngineConfiguration processEngineConfiguration = StandaloneInMemProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
            ClassLoader classLoaderBefore = processEngineConfiguration.getClassLoader();
            try {
                processEngineConfiguration.setClassLoader(Thread.currentThread().getContextClassLoader());
            } finally {
            }
            ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
            RepositoryService repositoryService = processEngine.getRepositoryService();
            RuntimeService runtimeService = processEngine.getRuntimeService();
            Deployment deploy = null;
            try {
                deploy = repositoryService.createDeployment()
                        .addInputStream("THE_BPMN_FILE.bpmn20.xml", new FileInputStream(new File ("C:\\THE_BPMN_FILE.bpmn20.xml")))
                        .deploy();
                String procId = runtimeService.startProcessInstanceByKey("THE_PROCESSID_IN_XML_FILE").getId();

            } catch (FileNotFoundException e1) {
                e1.printStackTrace();
            } catch (IOException e2) {
                e2.printStackTrace();
            }