cancel
Showing results for 
Search instead for 
Did you mean: 

couldn't instantiate class message in ACT_RU_JOB, but no exception thrown in Tomcat

ctri
Champ in-the-making
Champ in-the-making
Hello,

I am using the Activiti Explorer in order to deploy my process and I trigger its execution by using the REST api (both activiti-explorer and activiti-rest share the same database). The first task in my process is an async Java Service Task. I am pretty sure that the corresponding class is contained in a jar that's in the right places i.e. %catalina_home%/webapps/activiti-explorer/WEB-INF/lib and %catalina_home%/webapps/activiti-rest/WEB-INF/lib.
The problem is that sometimes (not always) some process executions freeze in this very first task but no exception is thrown (at least it is not visible in Tomcat's console/logs). However, I am able to see some exception messages in the ACT_RU_JOB table: couldn't instantiate class my.package.InitTask
I am using Activiti 5.16.1, Tomcat 8.0.14 and JDK 1.8.25

Thank you in advance,
Christos





3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
Is that the only exception log you see "couldn't instantiate class my.package.InitTask"? there should be a root cause for it.
The only thing I can think of is that the class is not on the classpath, but you say you've verified the jar is in /lib of both …

ctri
Champ in-the-making
Champ in-the-making
Thank you for your prompt response. Indeed, there is a root cause stored in the ACT_GE_BYTEARRAY table:

org.activiti.engine.ActivitiException: couldn't instantiate class gr.grnet.middleware.fulfillment.vpn.InitTask
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:132)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.instantiateDelegate(ClassDelegate.java:192)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.getActivityBehaviorInstance(ClassDelegate.java:165)
at org.activiti.engine.impl.bpmn.helper.ClassDelegate.execute(ClassDelegate.java:114)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:621)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:616)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:621)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:616)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:621)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:616)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:35)
at org.activiti.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:83)
at org.activiti.engine.impl.persistence.entity.MessageEntity.execute(MessageEntity.java:29)
at org.activiti.engine.impl.cmd.ExecuteJobsCmd.execute(ExecuteJobsCmd.java:73)
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.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.activiti.engine.ActivitiClassLoadingException: Class not found: gr.grnet.middleware.fulfillment.vpn.InitTask
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:82)
at org.activiti.engine.impl.util.ReflectUtil.instantiate(ReflectUtil.java:129)
… 34 more
Caused by: java.lang.ClassNotFoundException: gr.grnet.middleware.fulfillment.vpn.InitTask
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1293)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1145)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.activiti.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:63)
… 35 more

I have merged the activiti-rest and the activiti-explorer apps in a single app and retried (I made sure there is only one running instance of the process engine). The point is that this ClassNotFoundException error, occurs only under stress conditions, i.e. when I try to create many process instances over a short period of time and - more importantly - does not occur every time I try to create the Activiti process. I have double-checked the jar file is in the WEB-INF/lib directory of the merged activiti webapp but nowhere else in the Tomcat installation directory.

Thank you very much.


vasile_dirla
Star Contributor
Star Contributor
somehow the class you are trying to instantiate is not in the current class loader.
Where is located this class? gr.grnet.middleware.fulfillment.vpn.InitTask

you could just investigate around this method in ReflectUtil class:
<code>
public static Object instantiate(String className) {
        try {
            Class e = loadClass(className);
            return e.newInstance();
        } catch (Exception var2) {
            throw new ActivitiException("couldn\'t instantiate class " + className, var2);
        }
    }
</code>

you could check what's the classLoader used when it fails.