cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti listeners not working

logic3
Champ in-the-making
Champ in-the-making
HI,

I am trying to catch all the events for a process running on the Activiti explorer. I have implemented the bpmnparselistener class and moved my handler classes as Jars file to the WEB-INF/lib folder (ParseListener.jar). I have uploaded my process to the explorer using the bar file. However. no events are generated for the deployed process i.e. start event. I think It is my code below, which i am not sure where to put. Currently, it is in \webapps\activiti-explorer\WEB-INF\applicationContext.xml. I tried embedding the Listener with in the BPMN xml file and it worked but look like the Activiti can not read when using BPMNParseListener (implemented). It doesn't raise any exceptions or errors. My understanding is that Activiti engine automatically understand the customPostBPMNParseListeners property and there is nothing to declare in the process itself

 <property name="customPostBPMNParseListeners">
      <list>
        <bean class="org.handler.ParseListener"></bean>
      </list>
    </property>



Any help would be highly appreciated

thanks,
32 REPLIES 32

frederikherema1
Star Contributor
Star Contributor
The jar was there for the activiti-rest, probably. Glad it worked out for you, there needed to be a simple explanation for your problem. Only the road to it was far from simple Smiley Wink

udoderk
Champ in-the-making
Champ in-the-making
I don't see any other customizations in your app-context.xml file. Are you sure there is NO activiti.cfg.xml on your class path somewhere?

Because it *could* be that the wrong default-process-engine has been initialized BEFORE, so the one that your spring-context fires up, is not registered as default. All explorer-app code uses ProcessEngines.getDefaultProcessEngine() to obtain a process-engine.

So the presence of a activiti.cfg.xml-file will cause that engine to be used, while all other parts (UI, …) are taken from spring.

Hi frederikheremans,

that tip to check the activiti.cfg.xml is very helpful Smiley Indifferent
But the logging output with all configUrls  would be make a easier the troubleshooting (imho) on that method (activiti 5.10 used as example):

org.activiti.engine.ProcessEngines.init()

  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);
      }
     
      // Remove duplicated configuration URL's using set. Some classloaders may return identical URL's twice, causing duplicate startups
      Set<URL> configUrls = new HashSet<URL>();
      while (resources.hasMoreElements()) {
         current=resources.nextElement(); // nice to have
        configUrls.add( current );
        log.info("the configuration url {0} was added", current); // nice to have
      }
      for (Iterator<URL> iterator = configUrls.iterator(); iterator.hasNext():smileywink: {
        URL resource = iterator.next();
        initProcessEnginFromResource(resource);
      }
     
      try {
        resources = classLoader.getResources("activiti-context.xml");
      } catch (IOException e) {
        throw new ActivitiException("problem retrieving activiti-context.xml resources on the classpath: "+System.getProperty("java.class.path"), e);
      }
      while (resources.hasMoreElements()) {
        URL resource = resources.nextElement();
        initProcessEngineFromSpringResource(resource);
      }

      isInitialized = true;
    } else {
      log.info("Process engines already initialized");
    }
  }

frederikherema1
Star Contributor
Star Contributor
The 5.12 codebase contains a logging-entry that logs the config URL used:

for (Iterator<URL> iterator = configUrls.iterator(); iterator.hasNext():smileywink: {
        URL resource = iterator.next();
        log.info("Initializing process engine using configuration '{}'",  resource.toString());
        initProcessEnginFromResource(resource);
      }