FlowableEventListener not found

Hi,

We are testing a new way of listener for flowable Events and we have found that not always but often, flowable are throwing a NotClassFoundError when event occurs because a Timer Event. It has to be and Async Executor thread that has not the correct classpath, we guess.

Our test enviroment is a Tomcat with the five .war files of flowable (6.2.1), without further modification and a custom EventListener class to the /lib directory in a .jar file, which implements FlowableEventListener interface. The EventListener it is registered on a process definition through the modeler.

So we are confused why this error. It seems it is not always flowable-rest which has the Async Executor and/or there is an AsyncExecutor that doesn’t has FlowableEventListener in its classpath.

Logs at the end,

Thanks a lot,

03:42:04,699 [http-nio-8080-exec-10] ERROR com.dj.api.bpm.flowable.listeners.BpmFlowableExecutionListener - E collectin
g event: start on 2037519
03:42:20,109 [flowable-async-job-executor-thread-1] INFO org.flowable.engine.impl.app.AppDeployer - Processing app res
ource TEST-App.app
03:42:20,581 [flowable-async-job-executor-thread-1] WARN org.flowable.engine.common.impl.event.FlowableEventSupport -
Exception while executing event-listener, which was ignored
org.flowable.engine.common.api.FlowableException: couldn’t instantiate class com.dj.api.bpm.flowable.listeners.BpmFlowab
leEventListener
at org.flowable.engine.common.impl.util.ReflectUtil.instantiate(ReflectUtil.java:140)
at org.flowable.engine.impl.bpmn.helper.DelegateFlowableEventListener.getDelegateInstance(DelegateFlowableEventL
istener.java:57)
at org.flowable.engine.impl.bpmn.helper.DelegateFlowableEventListener.onEvent(DelegateFlowableEventListener.java
:43)
at org.flowable.engine.common.impl.event.FlowableEventSupport.dispatchEvent(FlowableEventSupport.java:104)
at org.flowable.engine.common.impl.event.FlowableEventSupport.dispatchEvent(FlowableEventSupport.java:97)
at org.flowable.engine.delegate.event.impl.BpmnModelEventDispatchAction.dispatchEvent(BpmnModelEventDispatchActi
on.java:43)
at org.flowable.engine.common.impl.event.FlowableEventDispatcherImpl.dispatchEvent(FlowableEventDispatcherImpl.j
ava:73)
at org.flowable.engine.impl.jobexecutor.TriggerTimerEventJobHandler.execute(TriggerTimerEventJobHandler.java:41)

    at org.flowable.job.service.impl.asyncexecutor.DefaultJobManager.executeJobHandler(DefaultJobManager.java:379)
    at org.flowable.job.service.impl.asyncexecutor.DefaultJobManager.executeTimerJob(DefaultJobManager.java:358)
    at org.flowable.job.service.impl.asyncexecutor.DefaultJobManager.execute(DefaultJobManager.java:227)
    at org.flowable.job.service.impl.cmd.ExecuteAsyncJobCmd.execute(ExecuteAsyncJobCmd.java:79)
    at org.flowable.engine.impl.interceptor.CommandInvoker$1.run(CommandInvoker.java:51)
    at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:93)
    at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:72)
    at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:56)
    at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.ja

va:25)
at org.flowable.engine.common.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextIntercept
or.java:53)
at org.flowable.engine.common.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:
72)
at org.flowable.idm.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:49)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.flowable.idm.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:46)
at org.flowable.engine.common.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
at org.flowable.engine.common.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:125)
at org.flowable.job.service.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.flowable.engine.common.api.FlowableClassLoadingException: Could not load class: com.dj.api.bpm.flowable.l
isteners.BpmFlowableEventListener
at org.flowable.engine.common.impl.util.ReflectUtil.loadClass(ReflectUtil.java:90)
at org.flowable.engine.common.impl.util.ReflectUtil.instantiate(ReflectUtil.java:137)
… 29 more
Caused by: java.lang.NoClassDefFoundError: org/flowable/engine/common/api/delegate/event/FlowableEventListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1261)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.flowable.engine.common.impl.util.ReflectUtil.loadClass(ReflectUtil.java:338)
at org.flowable.engine.common.impl.util.ReflectUtil.loadClass(ReflectUtil.java:71)
… 30 more
Caused by: java.lang.ClassNotFoundException: org.flowable.engine.common.api.delegate.event.FlowableEventListener
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Do you have multiple nodes running? This exception can happen when a node picks up the job but doesn’t have the class on its classpath. Meaning only one node has the right classes.

1 Like

Hi Joram,

This happen in single machine test case.
We suspect that is flowable-task.war the one fires this exception.

Thanks,

Hi @toni.gamez!

I think that the issue is related with the way Tomcat tomcat does the class loading. The classloader used for the stuff you put in Tomcat’s lib directory can be used by the classes from the web apps because the web apps’ classloader is under a deeper hiearchy. This does not work the other way. In other words, classes that are loaded with a higher level class loader are not able to “see” the classes that are loaded by the corresponding application classloader. In the case that you describe, your custom event listener is in /lib but the required class to implement is in a jar from an application. We can get into the details to be sure but I guess that this might be the issue.

In order to keep things more simple everything should be packed as application code. That’d mean creating you own war file with the flowable dependencies and your customizations.