Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; #392

Closed
geniusjoe opened this issue Dec 21, 2021 · 1 comment

Comments

@geniusjoe
Copy link

geniusjoe commented Dec 21, 2021

Environment

  • OS version: tlinux2 (seems like centos)
  • JDK version:
compile JDK version:
  openjdk version "1.8.0_242" 
  OpenJDK Runtime Environment (Tencent Kona 8.0.1-internal) (build 1.8.0_242-b1)
  OpenJDK 64-Bit Server VM (Tencent Kona 8.0.1-internal) (build 25.242-b1, mixed mode, sharing)
runtime JDK version:
  openjdk version "11.0.13-ga" 2021-11-12
  OpenJDK Runtime Environment TencentKonaJDK (build 11.0.13-ga+1)
  OpenJDK 64-Bit Server VM TencentKonaJDK (build 11.0.13-ga+1, mixed mode)

You can find the JDK 1.8 ,JDK 1.11. And I think the exception can reproduce in any other JDK corporation version.

  • ClickHouse Server version: N/A
  • ClickHouse Native JDBC version:
<dependency>
    <groupId>com.github.housepower</groupId>
    <artifactId>clickhouse-native-jdbc-shaded</artifactId>
    <version>2.6.3</version>
</dependency>
  • (Optional) Spark version: N/A
  • (Optional) Other components' version: N/A

Error logs

[2021-12-21 23:45:17,827] ERROR WorkerSinkTask{id=clickhousesink-test3-0} Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted. (org.apache.kafka.connect.runtime.WorkerSinkTask)
java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
        at com.github.housepower.buffer.ByteArrayWriter.lambda$reset$0(ByteArrayWriter.java:79)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at com.github.housepower.buffer.ByteArrayWriter.reset(ByteArrayWriter.java:78)
        at com.github.housepower.data.ColumnWriterBuffer.reset(ColumnWriterBuffer.java:56)
        at com.github.housepower.data.ColumnWriterBufferFactory.getBuffer(ColumnWriterBufferFactory.java:52)
        at com.github.housepower.data.Block.initWriteBuffer(Block.java:157)
        at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.lambda$initBlockIfPossible$0(ClickHousePreparedInsertStatement.java:209)
        at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:64)
        at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.initBlockIfPossible(ClickHousePreparedInsertStatement.java:207)
        at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.<init>(ClickHousePreparedInsertStatement.java:111)
        at com.github.housepower.jdbc.ClickHouseConnection.prepareStatement(ClickHouseConnection.java:158)
        ......(omit business code)
        at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:642)
        at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:394)
        at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:265)
        at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:230)
        at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:223)
        at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:269)
        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 java.lang.Thread.run(Thread.java:748)

Steps to reproduce

I use Clickhouse JDBC as a kafka connect sink plugin to send messages from a kafka to a Clickhouse cluster.
When I compiled the code in JDK11, Clickhouse 2.6.3 to get a jar file, and ran it with SDK1.8, the error happened.
When I switched to use Clickhouse 2.5.7 version, the code worked properly.

Other descriptions

I think it is because the version of JDK 1.8+ not competitable with JDK1.8.
So it leads to error when use the function in
com/github/housepower/buffer/ByteArrayWriter.java at line 77 in version 2.6:

public void reset() {
    byteBufferList.forEach(b -> {
        b.clear();   # <----- here
        freeList.addLast(b);
    });
    byteBufferList.clear();
    
    reuseOrAllocateByteBuffer();
}

The exception looks like the same as the stackOverflow bug below. I think it is better to use a cast function to prevent the incompatible condition.
StackOverflow link

@pan3793
Copy link
Member

pan3793 commented Dec 22, 2021

Fixed in v2.6.4

@pan3793 pan3793 closed this as completed Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants