我是新来点燃并尝试运行我的简单多节点计算示例。我写了以下简单的应用程序:
try(Ignite ignite = Ignition.start("example-cache.xml")){
IgniteCompute asyncCompute = ignite.compute().withAsync();
for(int i = 0; i < 100; i++) {
int[] a = new int[1];
a[0] = i;
asyncCompute.call(() -> {
out.println(a[0]);
return a[0];
});
}
}
首先,我运行了3个带有{{1}}的服务器节点,该服务器节点提供了二进制点火分发。每个都在不同的JVM实例中。
然后我构建这个应用程序并使用与之前的3个服务器节点相同的xml-spring配置运行它。
但实际上我遇到了以下异常:
ignite.sh
这个例外非常清楚。但是我们需要class org.apache.ignite.IgniteCheckedException: com.test.App
at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9826)
at org.apache.ignite.internal.processors.job.GridJobWorker.initialize(GridJobWorker.java:432)
at org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1108)
at org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1894)
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1222)
at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:850)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$2100(GridIoManager.java:108)
at org.apache.ignite.internal.managers.communication.GridIoManager$7.run(GridIoManager.java:790)
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: class org.apache.ignite.binary.BinaryInvalidTypeException: com.test.App
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:692)
at org.apache.ignite.internal.binary.BinaryUtils.doReadClass(BinaryUtils.java:1486)
at org.apache.ignite.internal.binary.BinaryUtils.doReadClass(BinaryUtils.java:1424)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.readClass(BinaryReaderExImpl.java:370)
at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.readFixedType(BinaryFieldAccessor.java:828)
at org.apache.ignite.internal.binary.BinaryFieldAccessor$DefaultFinalClassAccessor.read(BinaryFieldAccessor.java:639)
at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:833)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1498)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1450)
at org.apache.ignite.internal.binary.BinaryUtils.doReadObject(BinaryUtils.java:1640)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.readObject(BinaryReaderExImpl.java:1124)
at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2V2.readBinary(GridClosureProcessor.java:2073)
at org.apache.ignite.internal.binary.BinaryClassDescriptor.read(BinaryClassDescriptor.java:823)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize0(BinaryReaderExImpl.java:1498)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1450)
at org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:298)
at org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal0(BinaryMarshaller.java:99)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9820)
... 10 more
Caused by: java.lang.ClassNotFoundException: com.test.App
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8459)
at org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185)
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:683)
脚本?
答案 0 :(得分:2)
您应该在类路径中为所有点火节点添加App类或 打开对等类加载[1]。
[1] https://apacheignite.readme.io/v1.9/docs/zero-deployment#peer-class-loading
答案 1 :(得分:1)
您应该将JAR文件添加到Apache Ignite安装文件夹下的lib /文件夹中。然后你可以启动ignite.sh并自动加载你的所有类。
或者,您可以尝试按照上面的建议启用对等类加载,Ignite将自动加载类。