I am using Redisson scheduler to schedule tasks. It runs perfectly on the first deployment or when I clear all the schedulers. But starts to fail on next deployment.
RedisJsonServiceImpl class is my custom class.
Can't execute: RemoteServiceRequest [requestId=36dfa93ee183b2054f3ce7c1961897eb, methodName=scheduleRunnable, signature=[3143983607692024834, -697753227114447020], args=[org.redisson.executor.params.ScheduledParameters@1f586f11], options=RemoteInvocationOptions[ackTimeoutInMillis=null, executionTimeoutInMillis=3600000], date=1663144183733]
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.redisson.executor.RedissonExecutorRemoteService.invokeMethod(RedissonExecutorRemoteService.java:107)
at org.redisson.RedissonRemoteService.lambda$executeMethod$11(RedissonRemoteService.java:434)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mpl.services.gs2.mm.service.impl.RedisJsonServiceImpl
at com.mpl.services.gs2.mm.scheduler.SchedulerCancel.run(SchedulerCancel.java:22)
at org.redisson.executor.TasksRunnerService.executeRunnable(TasksRunnerService.java:342)
at org.redisson.executor.TasksRunnerService.executeRunnable(TasksRunnerService.java:361)
at org.redisson.executor.TasksRunnerService.scheduleRunnable(TasksRunnerService.java:200)
My clas looks like this.
@Slf4j
public class SchedulerCancel implements Runnable, Serializable {
String redisKey;
public SchedulerCancel(String redisKey) {
this.redisKey = redisKey;
}
@Override
public void run() {
log.info("request to cancel task {}",redisKey);
RedisJsonServiceImpl instance = new RedisJsonServiceImpl();
String taskId = instance.get(redisKey);
if(taskId==null){
log.info("task id not present");
return;
}
instance.cancelTask(REDISSON_ASYNC_MM_EXECUTOR,taskId);
instance.delete(redisKey);
}
}