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

There is an issue with the SystemTime in JdbcSourceTask in Kafka version 3.9.0. #1445

Open
kkh03291 opened this issue Nov 16, 2024 · 1 comment

Comments

@kkh03291
Copy link

kkh03291 commented Nov 16, 2024

I am not good at English, so I received help from GPT.

In Kafka version 3.9.0, the method for creating an instance of the SystemTime class has changed.

Previously, you could obtain an instance of SystemTime using new SystemTime(). However, it now appears that SystemTime has adopted the Singleton pattern, requiring you to call SystemTime.getSystemTime() to create an instance.

Below are the related Kafka 3.9.0 release notes and the GitHub link to the changes:
https://issues.apache.org/jira/browse/KAFKA-16879
apache/kafka#16266

Below is a portion of the modified source code for the SystemTime class:

class SystemTime implements Time {
    private static final SystemTime SYSTEM_TIME = new SystemTime();

    public static SystemTime getSystemTime() {
        return SYSTEM_TIME;
    }

   //...

    private SystemTime() {

    }
}

And below is the part of the JdbcSourceTask in Kafka Connect JDBC version 10.8.0 where the SystemTime field is initialized.

public class JdbcSourceTask extends SourceTask {
//..
  public JdbcSourceTask() {
    this.time = new SystemTime();
  }

  public JdbcSourceTask(Time time) {
    this.time = time;
  }
//..
}

Currently, even with the latest version of Kafka Connect JDBC (10.8.0), it cannot be used with Kafka version 3.9.0 due to the following error.

[2024-11-15 17:29:25,300] ERROR [test-connector-mysql|task-0] Failed to start task test-connector-mysql-0 (org.apache.kafka.connect.runtime.Worker:707)
org.apache.kafka.connect.errors.ConnectException: Instantiation error
	at org.apache.kafka.connect.runtime.isolation.Plugins.newPlugin(Plugins.java:142)
	at org.apache.kafka.connect.runtime.isolation.Plugins.newTask(Plugins.java:340)
	at org.apache.kafka.connect.runtime.Worker.startTask(Worker.java:664)
	at org.apache.kafka.connect.runtime.Worker.startSourceTask(Worker.java:592)
	at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.startTask(StandaloneHerder.java:504)
	at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.createConnectorTasks(StandaloneHerder.java:488)
	at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.createConnectorTasks(StandaloneHerder.java:482)
	at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.updateConnectorTasks(StandaloneHerder.java:541)
	at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.lambda$null$2(StandaloneHerder.java:255)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: org.apache.kafka.common.KafkaException: Could not instantiate class io.confluent.connect.jdbc.source.JdbcSourceTask
	at org.apache.kafka.common.utils.Utils.newInstance(Utils.java:405)
	at org.apache.kafka.connect.runtime.isolation.Plugins.newPlugin(Plugins.java:140)
	... 14 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:501)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:485)
	at org.apache.kafka.common.utils.Utils.newInstance(Utils.java:401)
	... 15 more
Caused by: java.lang.IllegalAccessError: failed to access class org.apache.kafka.common.utils.SystemTime from class io.confluent.connect.jdbc.source.JdbcSourceTask (org.apache.kafka.common.utils.SystemTime is in unnamed module of loader 'app'; io.confluent.connect.jdbc.source.JdbcSourceTask is in unnamed module of loader org.apache.kafka.connect.runtime.isolation.PluginClassLoader @63021689)
	at io.confluent.connect.jdbc.source.JdbcSourceTask.<init>(JdbcSourceTask.java:78)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	... 18 more
@movertaker
Copy link

We are not able to update our Kafka Connect instances because of this bug. When is it going to be fixed?

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