我正在使用Trident风暴并尝试在函数prepare方法中启动网格实例。相同的配置文件适用于本地群集。当我在remore群集中提交它时,我收到错误。
代码:
public class MemoryGrid extends BaseFunction {
private static final long serialVersionUID = -4574506761580804738L;
private static final String configFileLocation = "file:///home/path/config.xml";
MemGridDAO memgriddao;
public void prepare(Map conf, TridentOperationContext context){
this.memgriddao = new MemGridDAO (configFileLocation);
}
public void execute(TridentTuple tuple, TridentCollector collector) {
try {
memgriddao.put("cahcename",tuple.getValue(0),tuple.getValue(1));
} catch (GridException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
collector.emit(null);
}
public class MemGridDAO {
public MemGridDAO(String configFile){
Grid grid = GridGain.start(configFile);
}
}
错误
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.7.0_45]
at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[na:1.7.0_45]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.7.0_45]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[na:1.7.0_45]
at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[na:1.7.0_45]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.7.0_45]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_45]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_45]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_45]
at java.lang.ClassLoader.loadClass(ClassLoader.java:425) ~[na:1.7.0_45]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.7.0_45]
at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[na:1.7.0_45]
at java.lang.Class.forName0(Native Method) ~[na:1.7.0_45]
at java.lang.Class.forName(Class.java:190) ~[na:1.7.0_45]
at org.gridgain.grid.util.GridUtils.addLog4jNoOpLogger(GridUtils.java:7697) ~[stormjar.jar:na]
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:732) ~[stormjar.jar:na]
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:677) ~[stormjar.jar:na]
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:524) ~[stormjar.jar:na]
at org.gridgain.grid.kernal.GridGainEx.start(GridGainEx.java:494) ~[stormjar.jar:na]
at org.gridgain.grid.GridGain.start(GridGain.java:314) ~[stormjar.jar:na]
答案 0 :(得分:1)
这可能是编译问题。尝试做一个干净的构建。它可能是因为所有依赖类之间的.class文件不匹配。
IncompatibleClassChangeError扩展了LinkageError,它与从编译子类后更改的基类引发的问题有关。
答案 1 :(得分:1)
您的远程集群应用程序类路径中似乎有多个不兼容的Log4j jar版本(很可能是其中一个是GridGain依赖项,另一个已经存在您的应用程序依赖项)。
您需要使用与GridGain相同版本的Log4j,或者将GridGain配置为使用非log4j日志记录。例如,如果要保留Log4j的版本,可以使用GridSlf4jLogger
和正确的SLF4j-to-Log4j绑定。