Getting ConfluentHubClient exception while installing kafka connectors
Asked Answered
C

4

9

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?

Casino answered 17/4, 2021 at 4:27 Comment(0)
A
28

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.

Astera answered 5/7, 2022 at 12:3 Comment(5)
You save me! Rly thanks!Him
Thank you! But why is this problem happening? Is this responsible for confluent?Vergara
Thank you, you save me too: sudo ln -s /opt/homebrew/Caskroom/confluent-hub-client/7.1.2/bin/confluent-hub /usr/local/bin/Aerodonetics
I would suggest adding a TL;DR section at the beginning of this solution.Thayer
I don't seem to have sudo access on my org's mac. Is there any other way I can resolve it?Nanon
C
0

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

Casino answered 17/4, 2021 at 4:57 Comment(0)
S
0

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

Silici answered 7/9, 2022 at 10:42 Comment(0)
N
0

Add

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

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

Nanon answered 22/2, 2024 at 15:28 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.