cancel
Showing results for 
Search instead for 
Did you mean: 

ClassNotFoundException when using timer start event

gunnar1
Champ in-the-making
Champ in-the-making
Hi folks,

I have a process using a timer start event followed by a java service task similar to the following example:

      
      <startEvent id="TestStart" name="TestStart">
          …
         <outgoing>SequenceFlow</outgoing>
         <timerEventDefinition id="sid-a94d4371-18ae-47e9-9fa6-7cd68a92d439">
            <timeCycle id="sid-f1f79392-82d9-4ba8-a510-6ce058ecc0e5" xsi:type="tFormalExpression">0 0/2 * * * ?</timeCycle>
         </timerEventDefinition>
      </startEvent>
      …
      <serviceTask id="TestTask0003" name="TestTask0003"  activiti:class="de.beck.test.delegate.SysoutDelegate">
         …
         <incoming>SequenceFlow</incoming>
         <outgoing>SequenceFlow_2</outgoing>
      </serviceTask>
      …

Using the demo environment (activiti 5.6, changed database to mysql, thats all) I deployed the JAR-File including the above service class to
apache-tomcat-6.0.32\webapps\activiti-rest\WEB-INF\lib

Deploying my process leads to the following somehow odd behavour:

The very first timer event works correctly  Smiley Happy -  producing test output like

Mon Jun 13 18:34:00 CEST 2011: Execution 116 passes by TestTask0003…

But the next call of the timer (2 minutes later) leads to a ClastCastException:


13.06.2011 18:36:00 org.activiti.engine.impl.interceptor.CommandContext close
SCHWERWIEGEND: Error while closing command context
org.activiti.engine.ActivitiException: couldn't instantiate class de.beck.test.delegate.SysoutDelegate
        at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:131)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:148)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:121)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:102)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListener
Start.java:48)

Caused by: org.activiti.engine.ActivitiClassLoadingException: Could not load class: de.beck.test.delegate.SysoutDelegate
   at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:81)
   at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:128)
   … 69 more
Caused by: java.lang.NoClassDefFoundError: org/activiti/engine/delegate/JavaDelegate
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
   at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1667)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:247)
   at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:62)
   … 70 more
Caused by: java.lang.ClassNotFoundException: org.activiti.engine.delegate.JavaDelegate
   at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
   … 86 more

Starting the process manually via Activiti Explorer is always successful. Any idea about the timer event classloading issue?

Thanks in advance
Gunnar
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
That's really strange behaviour… All timers are executed ion the same thread-pool and use the same classloading.

Does this always happen?

gunnar1
Champ in-the-making
Champ in-the-making
Yes, it does always happen in the demo environment… But:

After further research I found the following:

When removing the activitity applications kickstart, cycle, modeler, administrator
and leaving only explorer, probe, rest it seams to work stable.


This leads to the following question:

The demo setup includes activiti-engine.jar in activiti-rest, but as well in several other applications.
If all applications are configured correctly using the same database - how does Activiti decide which application (and which class loader!) to use for running my timer event triggered process?
Remember that the service class "de.beck.test.delegate.SysoutDelegate" has only been provided within the activiti-rest application.

You might want to describe the deployment scenarios more precisely within the user manual?

frederikherema1
Star Contributor
Star Contributor
The cycle, explorer and probe webapps don't use the engine DB itself, instead they go through activiti-rest webapp.

So if you manipulate your process from within explorer, it uses the activiti-rest classpath (since the actual engine call is done there). The async stuff is executed in the jobexecutor. In the demo-setup, two job-executors are running: one in activiti-rest and another one in activiti-kickstart. If you don't have all dependencies in all activiti-engine classpaths, you should disable the job-executors on all other engines.

Since all operations (apart from jobExecutor in the engine) kick-start and activiti-administrator don't affect any process (start/signal process or complete tasks) it's safe that they don't have the full classpath for executing the process.

gunnar1
Champ in-the-making
Champ in-the-making
Good catch!

So my Kick-Start configuration is causing trouble and disabling the Kick-Start's JobExecutor within the activiti.cfg.xml is the solution:


  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
    …   
    <property name="jobExecutorActivate" value="false" />
    …
  </bean>

Thank you  Smiley Happy

frederikherema1
Star Contributor
Star Contributor
That's the only thing I can think of Smiley Wink

sascha1
Champ in-the-making
Champ in-the-making
I also have similar problems on 5.6 I am getting the following exception when starting my process. The process contains a ServiceTask which uses Java-Class EventumBehavior as implementation. A jar containing this class is definitly in webapps/activiti-rest/WEB-INF/lib directory.

The problem doesn't occur on 5.4


com.vaadin.event.ListenerMethod$MethodException
Cause: org.activiti.engine.ActivitiException: couldn't instantiate class de.uni_stuttgart.informatik.eventum.activiti.activities.EventumBehavior
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1193)
at com.vaadin.ui.Button.fireClick(Button.java:539)
at com.vaadin.ui.Button.changeVariables(Button.java:206)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1299)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1219)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:735)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.activiti.engine.ActivitiException: couldn't instantiate class de.uni_stuttgart.informatik.eventum.activiti.activities.EventumBehavior
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:131)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:148)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:121)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:102)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:326)
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:92)
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:49)
at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:44)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:44)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:280)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:70)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:30)
at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceById(RuntimeServiceImpl.java:57)
at org.activiti.explorer.ui.process.listener.StartProcessInstanceClickListener.buttonClick(StartProcessInstanceClickListener.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
… 22 more
Caused by: org.activiti.engine.ActivitiClassLoadingException: Class not found: de.uni_stuttgart.informatik.eventum.activiti.activities.EventumBehavior
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:81)
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:128)
… 80 more
Caused by: java.lang.ClassNotFoundException: de.uni_stuttgart.informatik.eventum.activiti.activities.EventumBehavior
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:62)
… 81 more

I don't use kickstart.

EDIT: I was wrong - This Problem doesn't seem to occur with 5.6 but with current trunk.

jbarrez
Star Contributor
Star Contributor
Could you elaborate on that? What exactly is failing on trunk compared to before?

sascha1
Champ in-the-making
Champ in-the-making
At the moment I have no time to investigate. I need to complete my implementation for my thesis and therefore I switched back from trunk to 5.6.

I am having an process containing some custom ServiceTasks. Though I placed the jar containing the implementation of the custom ServiceTasks in the activiti-rest/WEB-INF/lib/ folder my classes aren't found and I am getting the StackTrace postet above when I start a process-instance.

If it helps I can investigate on this after completion of my thesis.