0
votes

I am trying to load kafka topic data into ignite caches with the help of Apache Ignite Sink connector. Facing following issue. All required jars are in place along with ignite configuration (xml) file.

I am pretty unsure why it is throwing ConnectException and NoClassDefFoundException for IgniteSinkTask$StreamerContext$Holder. Due to some reason java is unable to run these classes.

public static class StreamerContext {
    private StreamerContext() {
    }

    public static Ignite getIgnite() {
        return IgniteSinkTask.StreamerContext.Holder.IGNITE;
    }

    public static IgniteDataStreamer getStreamer() {
        return IgniteSinkTask.StreamerContext.Holder.STREAMER;
    }

    private static class Holder {
        private static final Ignite IGNITE;
        private static final IgniteDataStreamer STREAMER;

        private Holder() {
        }

        static {
            IGNITE = Ignition.start(IgniteSinkTask.igniteConfigFile);
            STREAMER = IGNITE.dataStreamer(IgniteSinkTask.cacheName);
        }
    }
}

How can I resolve this? Thanks in advance.

[ERROR] 2021-08-27 06:13:58,827 [task-thread-IgniteSinkConnectorConnector_0-0] org.apache.kafka.connect.runtime.WorkerSinkTask deliverMessages - WorkerSinkTask{​id=IgniteSinkConnectorConnector_0-0}​ Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted. Error: Could not initialize class org.apache.ignite.stream.kafka.connect.IgniteSinkTask$StreamerContext$Holder java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.stream.kafka.connect.IgniteSinkTask$StreamerContext$Holder at org.apache.ignite.stream.kafka.connect.IgniteSinkTask$StreamerContext.getStreamer(IgniteSinkTask.java:198) at org.apache.ignite.stream.kafka.connect.IgniteSinkTask.put(IgniteSinkTask.java:118) at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:586) at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:329) at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:232) at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:201) at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:185) at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:234) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) [ERROR] 2021-08-27 06:13:58,828 [task-thread-IgniteSinkConnectorConnector_0-0] org.apache.kafka.connect.runtime.WorkerTask doRun - WorkerSinkTask{​id=IgniteSinkConnectorConnector_0-0}​ Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted org.apache.kafka.connect.errors.ConnectException: Exiting WorkerSinkTask due to unrecoverable exception. at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:614) at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:329) at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:232) at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:201) at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:185) at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:234) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.stream.kafka.connect.IgniteSinkTask$StreamerContext$Holder at org.apache.ignite.stream.kafka.connect.IgniteSinkTask$StreamerContext.getStreamer(IgniteSinkTask.java:198) at org.apache.ignite.stream.kafka.connect.IgniteSinkTask.put(IgniteSinkTask.java:118) at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:586)

1
Please provide enough code so others can better understand or reproduce the problem. - Community
Show us the class in the error actually exists - stackoverflow.com/a/1343026/2308683 - OneCricketeer
Hi the class is part of kafka-ignite.2.9.1.jar, I have edited the problem. Please have a look and guide. Also, the error is popped only when I am trying to run it in distributed mode, in standalone it's not showing any such issue. Is it because of static nature of class? - CoderClown

1 Answers

0
votes

A NoClassDefFoundError is thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found. In simple words, the class was available at compile time but missing during runtime.

Refer below for further debugging:

http://javareferencegv.blogspot.com/2013/10/debugging-javalangnoclassdeffounderror.html