Getting ConfluentHubClient exception while installing kafka connectors

3k Views Asked by At

I have set up Kafka cluster and installed confluent-hub on a EC2 instance. I have downloaded the confluent-hub tar file, extracted and placed the binary inside /usr/local/bin.

When I am now trying to install any connectors, I am getting the ClassNotFoundException.

[ec2-user@ip-172-31-88-110 bin]$ confluent-hub install confluentinc/kafka-connect-jdb c:latest --component-dir /opt/connectors --worker-configs /etc/kafka/connect.properties

/usr/local/bin/confluent-hub: line 13: cd: /usr/local/bin/../share/java: No such file or directory
Error: Could not find or load main class io.confluent.connect.hub.cli.ConfluentHubClient
Caused by: java.lang.ClassNotFoundException: io.confluent.connect.hub.cli.ConfluentHubClient

Where am I going wrong?

4

There are 4 best solutions below

0
On

The binary was present in /usr/bin. I deleted the file from that location and it started working.

5
On

OS: macOS 12.4

I got a similar error: /opt/homebrew/bin/confluent-hub: line 13: cd: /opt/homebrew/bin/../share/java: No such file or directory Error: Could not find or load main class io.confluent.connect.hub.cli.ConfluentHubClient

I can see that the /opt/homebrew/bin/confluent-hub has symbolic links to /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/bin/confluent-hub. Then I looked into the code in /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/bin/confluent-hub file :

#!/usr/bin/env bash

# (Copyright) [2018 - 2018] Confluent, Inc.

base_dir=$(dirname $0)

if [ -L /usr/local/bin/confluent-hub ]; then <<= line 9: I don't have this file and it should be a symbolic link to /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/bin/confluent-hub
    #brew cask installation
    base_dir=$(dirname $( ls -l /usr/local/bin/confluent-hub | awk '{print $11}' ))
    #base_dir refers to Caskrooom/confluent-hub-client
fi
#cd -P deals with symlink from /bin to /usr/bin
java_base_dir=$( cd -P "$base_dir/../share/java" && pwd ) <<= line 13: where error thrown
HUB_CLI_CLASSPATH="${HUB_CLI_CLASSPATH}:${java_base_dir}/confluent-hub-client/*"
BIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

exec java -cp "${HUB_CLI_CLASSPATH}" -Dbin.abs.path="${BIN_DIR}" io.confluent.connect.hub.cli.ConfluentHubClient "$@"

Since there is no such file/symbolic link at line 9, the code jumps to line 13 straightaway and starts complaining the java binary file not found. Without going inside the if statement, the current $base_dir = /opt/homebrew/bin and there is no /opt/hombrew/share/java file.

Actually the java file is at /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/share/java/. We have to let the code goes inside the if statement so that $base_dir can get overwritten to use the right path as of /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/bin.

In order to ensure that the code executes inside the if else statement, I manually created a symbolic link: sudo ln -s /opt/homebrew/Caskroom/confluent-hub-client/<CONFLUENT-HUB-VERSION>/bin/confluent-hub /usr/local/bin/confluent-hub. Then problem solved.

0
On

Add

export PATH="/opt/homebrew/Caskroom/confluent-hub-client/<version>/bin:$PATH"

to ~/.bash_profile or ~/.zshrc end of file

0
On

go to /opt/homebrew/Caskroom/confluent-hub-client/

rename 7.1.2 or any other to 7.1.1

now go to /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/

copy "share" folder and paste inside /opt/homebrew/Caskroom/confluent-hub-client/7.1.1/bin