cancel
Showing results for 
Search instead for 
Did you mean: 

org.activiti.engine.ActivitiException: couldn't instantiate class com.stud.listener.PrinterListener

natedawg
Champ in-the-making
Champ in-the-making
Hi,

I did try to read other similar forum posts reported on this forum but I cannot see if those are exactly the same as mine issue. So here I go. Process is attached, ending as txt as xmls are not allowed to be uploaded.

The process starts with executing a service task (SequenceJob1) calling a java class. Then the process sleeps for 10 seconds (intermediate timer catching event, wait10S) so I can check the status of SequenceJob1 in another service task (CheckSequenceJob1Status). If the job is not finished (varStatus == 'F') then the loop of sleeping for 10 secs and checking status is repeated again. The error occurs right after the second time intermediate timer catching event executes. It manages to execute the PrinterListener (like the first time) but then throws exception (see below log).


<b>From the log</b> (take a look at 12:43:55,28 when a new thread is fired.

12:43:23,490 [http-apr-8080-exec-10] INFO  org.activiti.engine.impl.bpmn.deployer.BpmnDeployer  - Processing resource ProcDS1.bpmn20.xml
12:43:36,997 [http-apr-8080-exec-8] INFO  com.stud.service.StageService  - starting Stage job execution
12:43:38,202 [http-apr-8080-exec-8] INFO  com.stud.service.StageService  - execution completed
12:43:38,202 [http-apr-8080-exec-8] INFO  com.stud.service.StageService  - Variable name: varLastActivity
12:43:38,202 [http-apr-8080-exec-8] INFO  com.stud.service.listener.PrinterListener  - Activity name:wait10S    variables: [varLastActivity]
12:43:55,281 [pool-1-thread-2] INFO  com.stud.service.listener.PrinterListener  - Activity name:CheckSeqJob1Status    variables: [varLastActivity]
12:43:55,297 [pool-1-thread-2] INFO  com.stud.service.StageService  - checking job status
12:43:55,297 [pool-1-thread-2] INFO  com.stud.service.StageService  - calling getJobStatus
12:43:55,593 [pool-1-thread-2] INFO  com.stud.service.StageService  - checking job status completed. value equals 'R'
12:43:55,593 [pool-1-thread-2] INFO  com.stud.service.StageService  - Variable name: varLastActivity
12:43:55,593 [pool-1-thread-2] INFO  com.stud.service.listener.PrinterListener  - Activity name:wait10S    variables: [varLastActivity, varDSJobStatus]



<b>Exception:</b>

12:43:55,693 [pool-2-thread-2] ERROR org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable  - Job 127578 failed
org.activiti.engine.ActivitiException: couldn't instantiate class com.stud.service.listener.PrinterListener
        at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:137)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.defaultInstantiateDelegate(ClassDelegate.java:242)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:232)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getExecutionListenerInstance(ClassDelegate.java:103)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:95)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:42)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:80)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:116)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:35)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:636)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:629)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:453)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:431)
        at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:140)
        at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:66)
        at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
        at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:47)
        at org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBehavior.signal(IntermediateCatchEventActivityBehavior.java:27)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:410)
        at org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler.execute(TimerCatchIntermediateEventJobHandler.java:58)
        at org.activiti.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:85)
        at org.activiti.engine.impl.persistence.entity.TimerEntity.execute(TimerEntity.java:95)
        at org.activiti.engine.impl.cmd.ExecuteAsyncJobCmd.execute(ExecuteAsyncJobCmd.java:52)
        at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
        at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
        at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
        at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.executeJob(ExecuteAsyncRunnable.java:96)
        at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:50)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
Caused by: org.activiti.engine.ActivitiClassLoadingException: Class not found: com.stud.service.listener.PrinterListener
        at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:87)
        at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:134)
        … 58 more
Caused by: java.lang.ClassNotFoundException: com.stud.service.listener.PrinterListener
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
        at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270)
        at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:291)
        at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:68)
        … 59 more
14 REPLIES 14

natedawg
Champ in-the-making
Champ in-the-making
this is a big show stopper for me. I had this problem for days now.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

did you add Caused by: java.lang.ClassNotFoundException: com.stud.service.listener.PrinterListener into the classpath?

Regards
Martin

natedawg
Champ in-the-making
Champ in-the-making
hi,
yes, PrinterListener is in the classpath. As you can see from the log, all artefacts were able to use this class in the first iteration. however in the second iteration the problem occures. i am not using Spring and ActivitiExplorer is used to execute all processes.

kind regards
A.H.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Is it possible to reproduce the issue in the jUnit test?
https://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin

natedawg
Champ in-the-making
Champ in-the-making
Ok but as I mentioned previously, I ran Explorer app to execute the process…

Kind regards
A.H.

trademak
Star Contributor
Star Contributor
Hi,

In the BPMN XML you included in your post I don't see an asynchronous task, but the stacktrace mentions the job executor (ExecuteAsyncRunnable) being used. Are you sure you included the correct BPMN XML?
A unit test showing the unit test would still help, also if you are using the Activiti Explorer, because that is also just using the Activiti Engine API.

Best regards,

natedawg
Champ in-the-making
Champ in-the-making
Hi guys,

I downloaded unit test template and run the test simply by line:
<java>ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey("ProcDS1");</java>

In the log I see no error but I also notice that only start event and first service task are executed. It means intermediate timer catching event and last service task are never executed (maybe something to do with new thread kicked off by the timer event?).

Here is the zip (just remove .txt as zip-uploads are not allowed), not yet sure this is a bug. Contains activiti-unit-test-template-master and service folders.
Sry, I am not an experienced maven user so just add a classpath ref to service-folder (contains some simple java code executed by service tasks). I did update pom.xml to reflect activiti version I am using (5.19.0.2).


Kind regards
A.H.

jbarrez
Star Contributor
Star Contributor
" It means intermediate timer catching event and last service task are never executed"

The reason is because your config does not have the job executor enabled. Once you enable it, timers will be executed.

natedawg
Champ in-the-making
Champ in-the-making
Hi,

When you say enable JobExecutor you refer to the engine.properties-file in Explorer-app? Like this:
<code>
engine.activate.jobexecutor=true
engine.asyncexecutor.enabled=false
engine.asyncexecutor.activate=false
</code>

If that is the case I can report the same problem occurring when JobExecutor enabled but not all the time, maybe every third time. Ref. Job Executor, in the doc I read that new Async Executor is the preferred one (http://www.activiti.org/userguide/#jobExecutorConfiguration).
According to the same doc JobExecutor is used by default.
Now I tried to enable it specifically in the test project by adding
<code><property name="jobExecutorActivate" value="true" /></code>
in the activiti.cfg.xml
Still the same behavior as previously, last service task is never executed and no exception reported.


Kind regards
A.H.