远程Hazelcast Quartz JobStore抛出ClassNotFoundException

时间:2018-01-31 22:47:03

标签: java hazelcast quartz

我使用此hazelcast quartz scheduler JobStore来安排后台作业。我正在使用:

  • quartz:2.2.3
  • Hazelcast:3.7.2(在默认配置的docker容器中运行)
  • Hazelcast-client:3.7.2

在hazelcast-quartz调度程序中添加新触发器时,我在hazelcast实例上遇到以下异常:

  

[3.7.2] java.lang.ClassNotFoundException:   com.bikeemotion.quartz.jobstore.hazelcast.TriggerWrapper   com.hazelcast.nio.serialization.HazelcastSerializationException:   抛出java.lang.ClassNotFoundException:   com.bikeemotion.quartz.jobstore.hazelcast.TriggerWrapper at   com.hazelcast.internal.serialization.impl.JavaDefaultSerializers $ JavaSerializer.read(JavaDefaultSerializers.java:224)     在   com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:46)     在   com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:172)     在   com.hazelcast.map.impl.record.Records.tryStoreIntoCache(Records.java:149)     在   com.hazelcast.map.impl.record.Records.getValueOrCachedValue(Records.java:118)     在   com.hazelcast.map.impl.recordstore.AbstractRecordStore.saveIndex(AbstractRecordStore.java:146)     在   com.hazelcast.map.impl.recordstore.DefaultRecordStore.putInternal(DefaultRecordStore.java:741)     在   com.hazelcast.map.impl.recordstore.DefaultRecordStore.set(DefaultRecordStore.java:919)     在   com.hazelcast.map.impl.operation.SetOperation.run(SetOperation.java:44)     在   com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:181)     在   com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl.run(OperationExecutorImpl.java:375)     在   com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl.runOrExecute(OperationExecutorImpl.java:402)     在   com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvokeLocal(Invocation.java:283)     在   com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvoke(Invocation.java:268)     在   com.hazelcast.spi.impl.operationservice.impl.Invocation.invoke0(Invocation.java:232)     在   com.hazelcast.spi.impl.operationservice.impl.Invocation.invoke(Invocation.java:207)     在   com.hazelcast.spi.impl.operationservice.impl.InvocationBuilderImpl.invoke(InvocationBuilderImpl.java:59)     在   com.hazelcast.client.impl.protocol.task.AbstractPartitionMessageTask.processMessage(AbstractPartitionMessageTask.java:64)     在   com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:119)     在   com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:99)     在   com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:137)     在   com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.process(OperationThread.java:127)     在   com.hazelcast.spi.impl.operationexecutor.impl.OperationThread.run(OperationThread.java:102)   引起:java.lang.ClassNotFoundException:   com.bikeemotion.quartz.jobstore.hazelcast.TriggerWrapper at   java.net.URLClassLoader $ 1.run(URLClassLoader.java:366)at   java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)at   java.security.AccessController.doPrivileged(Native Method)at   java.net.URLClassLoader.findClass(URLClassLoader.java:354)at   java.lang.ClassLoader.loadClass(ClassLoader.java:425)at   sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:308)at at   java.lang.ClassLoader.loadClass(ClassLoader.java:358)at   com.hazelcast.nio.ClassLoaderUtil.tryLoadClass(ClassLoaderUtil.java:151)     在   com.hazelcast.nio.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:120)     在   com.hazelcast.nio.IOUtil $ ClassLoaderAwareObjectInputStream.resolveClass(IOUtil.java:358)     在   java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)     在   java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)     在   java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1779)     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)     在   com.hazelcast.internal.serialization.impl.JavaDefaultSerializers $ JavaSerializer.read(JavaDefaultSerializers.java:219)     ......还有22个

关于可能出现什么问题的任何想法?我真的很讨厌必须让hazelcast实例知道hazelcast jobstore包。应该能够存储触发器而无需在hazelcast实例上反序列化它。

1 个答案:

答案 0 :(得分:1)

@ philip-wiebe,请参阅https://github.com/FlavioF/quartz-scheduler-hazelcast-jobstore/blob/master/src/main/java/com/bikeemotion/quartz/jobstore/hazelcast/HazelcastJobStore.java#L116

triggersByKeynextFireTime属性上有一个索引,在这种情况下是方法。这就是节点尝试创建索引的原因。尝试反序列化数据。您还需要在成员类路径中包含quartz-scheduler-hazelcast-jobstorequartz相关类。

注意:HazelcastJobStore也有自定义谓词,这也需要成员可用:https://github.com/FlavioF/quartz-scheduler-hazelcast-jobstore/blob/master/src/main/java/com/bikeemotion/quartz/jobstore/hazelcast/HazelcastJobStore.java#L1259