首页 > 解决方案 > 名称的重复类定义:“net/openhft/chronicle/queue/JDBCResultBinarylightMethodWriter”

问题描述

Chronicle Queue JDBC 测试代码:

try (JDBCService service = new JDBCService(in, out, () -> DriverManager.getConnection("jdbc:hsqldb:file:" + file.getAbsolutePath(), "SA", ""))) {

    JDBCStatement writer = service.createWriter();
    writer.executeUpdate("CREATE TABLE tableName (\n" +
                        "name VARCHAR(64) NOT NULL,\n" +
                        "num INT\n" +
                        ")\n");

    for (int i = 1; i < (long) noUpdates; i++)
        writer.executeUpdate("INSERT INTO tableName (name, num)\n" +
               "VALUES (?, ?)", "name", i);

        written = System.nanoTime() - start;
        AtomicLong queries = new AtomicLong();
        AtomicLong updates = new AtomicLong();
        CountingJDBCResult countingJDBCResult = new CountingJDBCResult(queries, updates);
        MethodReader methodReader = service.createReader(countingJDBCResult);
        while (updates.get() < noUpdates) {
            if (!methodReader.readOne())
                Thread.yield();
            }
            Closeable.closeQuietly(service);
        }
    }
}

似乎失败了:

java.lang.ClassNotFoundException: net.openhft.chronicle.queue.JDBCStatementBinarylightMethodWriterpackage net.openhft.chronicle.queue;
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:163)
    at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:76)
    at net.openhft.chronicle.wire.GenerateMethodWriter.createClass(GenerateMethodWriter.java:257)
    at net.openhft.chronicle.wire.GenerateMethodWriter.newClass(GenerateMethodWriter.java:101)
    at net.openhft.chronicle.wire.VanillaMethodWriterBuilder.newClass(VanillaMethodWriterBuilder.java:202)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at net.openhft.chronicle.wire.VanillaMethodWriterBuilder.get(VanillaMethodWriterBuilder.java:180)
    at net.openhft.chronicle.queue.JDBCService.createWriter(JDBCService.java:82)
    at fm.jdbc.Application.run(Application.java:73)
    at fm.jdbc.Application.main(Application.java:45)
java.lang.AssertionError: java.lang.LinkageError: loader (instance of  sun/misc/Launcher$AppClassLoader): attempted  duplicate class definition for name: "net/openhft/chronicle/queue/JDBCResultBinarylightMethodWriter"
    at net.openhft.compiler.CompilerUtils.defineClass(CompilerUtils.java:164)
    at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:157)
    at net.openhft.compiler.CachedCompiler.loadFromJava(CachedCompiler.java:76)
    at net.openhft.chronicle.wire.GenerateMethodWriter.createClass(GenerateMethodWriter.java:257)
    at net.openhft.chronicle.wire.GenerateMethodWriter.newClass(GenerateMethodWriter.java:101)
    at net.openhft.chronicle.wire.VanillaMethodWriterBuilder.newClass(VanillaMethodWriterBuilder.java:202)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at net.openhft.chronicle.wire.VanillaMethodWriterBuilder.get(VanillaMethodWriterBuilder.java:180)
    at net.openhft.chronicle.queue.JDBCService.runLoop(JDBCService.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    at net.openhft.chronicle.core.threads.CleaningThread.run(CleaningThread.java:38)
Caused by: java.lang.LinkageError: loader (instance of  sun/misc/Launcher$AppClassLoader): attempted  duplicate class definition for name: "net/openhft/chronicle/queue/JDBCResultBinarylightMethodWriter"
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:635)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.openhft.compiler.CompilerUtils.defineClass(CompilerUtils.java:159)
    ... 12 more

从...开始:

<groupId>net.openhft</groupId>
<artifactId>chronicle-bom</artifactId>
<version>2.19.291</version>

直到并包括最新版本 2.19.360。在此之前,版本 2.19.290 似乎可以工作。除了降级还有什么办法解决这个问题?

标签: javachronicle-queue

解决方案


这是Chronicle-Wire中的一个错误,现已修复


推荐阅读