iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

iceberg-kafka-connect-runtime fails with NoClassDefFoundError for org.apache.commons.configuration2.Configuration when used with Hadoop catalog

Open picarro-sdivakar opened this issue 1 year ago • 13 comments

Apache Iceberg version

None

Query engine

None

Please describe the bug 🐞

I’m trying to use the Kafka Connect Iceberg sink connector built from the latest main branch (v1.10.0-SNAPSHOT), following the instructions in the iceberg-kafka-connect-runtime module.

After unzipping the built connector JARs into the Kafka Connect plugin path and starting a sink connector with type=hadoop catalog, the connector fails with the following error:

java.lang.NoClassDefFoundError: org/apache/commons/configuration2/Configuration at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:43) ... Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration2.Configuration at org.apache.kafka.connect.runtime.isolation.PluginClassLoader.loadClass(PluginClassLoader.java:103) and

java.lang.NoClassDefFoundError: Could not initialize class org.apache.hadoop.security.UserGroupInformation at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:557) ...

Steps to Reproduce

  1. Checkout https://github.com/apache/iceberg and build the connector by ./gradlew build -x test -x integrationTest

  2. Copied the zip output from build/distributions/iceberg-kafka-connect-runtime-1.10.0-SNAPSHOT.zip to Kafka Connect plugin path and unzipped it.

  3. Started the connector by submitting `{ "name": "iceberg-sink", "config": { "connector.class": "org.apache.iceberg.connect.IcebergSinkConnector", "tasks.max": "1", "topics": "company.product.conc.level2",

    "iceberg.catalog.name": "hadoop", "iceberg.catalog.type": "hadoop", "iceberg.catalog.warehouse": "s3a://domain/product/iceberg/", "iceberg.catalog.hadoop.fs.s3a.endpoint": "<>:443", "iceberg.catalog.hadoop.fs.s3a.access.key": "<>", "iceberg.catalog.hadoop.fs.s3a.secret.key": "<>", "iceberg.catalog.hadoop.fs.s3a.path.style.access": "<>", "iceberg.catalog.hadoop.fs.s3a.impl": "org.apache.hadoop.fs.s3a.S3AFileSystem",

    "flush.size": "500", "key.converter": "org.apache.kafka.connect.storage.StringConverter", "value.converter": "com.company.cdp.avroconverter.CustomAvroConverter", "value.converter.avro.schema.file": "/etc/kafka-connect/data.avsc", "value.converter.schemas.enable": "true", "iceberg.tables": "db.processed_concentration",

    "iceberg.table.schema.file": "/etc/kafka-connect/data.avsc" } }` Analysis It seems that the commons-configuration2 transitive dependency required by org.apache.hadoop.security.UserGroupInformation is not bundled into the connector distribution. Since Kafka Connect uses isolated classloading per plugin, these dependencies must be explicitly included.

Suggested Fix Could we consider either:

Adding the missing commons-configuration2 dependency (and any other Hadoop transitive dependencies required at runtime) to the runtimeClasspath of iceberg-kafka-connect-runtime, or

Publishing a shaded uber-JAR (similar to how some other connectors are bundled), or

Updating documentation to guide users to manually include required Hadoop dependencies in the plugin path.

Please advise on the preferred direction. Happy to contribute a patch if needed.

Willingness to contribute

  • [ ] I can contribute a fix for this bug independently
  • [ ] I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • [ ] I cannot contribute a fix for this bug at this time

picarro-sdivakar avatar Jul 27 '25 16:07 picarro-sdivakar

+1 same

whitepowder avatar Jul 28 '25 07:07 whitepowder

Hi I have the same issue, i'd love to know what jars (and their versions) can i manually add for it to work, if you know what they are Thanks

blob321 avatar Jul 28 '25 10:07 blob321

Hi I have the same issue, i'd love to know what jars (and their versions) can i manually add for it to work, if you know what they are Thanks

iceberg-kafka-connect-runtime-hive-1.10.0-SNAPSHOT org/apache/hive/hive-exec/2.3.10/hive-exec-2.3.10.jar org/apache/commons/commons-configuration2/2.10.1/commons-configuration2-2.10.1.jar org/apache/commons/commons-text/1.11.0/commons-text-1.11.0.jar

did the trick for me

whitepowder avatar Jul 28 '25 10:07 whitepowder

I'm facing issue with the Iceberg Sink Connector for Kafka Connect. The connector is not able to implement the upsert functionality as expected. It is creating new records instead of updating existing ones. The connector is configured to use the _id field as the primary key, but it seems to be ignoring this and treating all records as new inserts.

Sink connector Table related config

"iceberg.tables": "iceberg.table_staging",
"iceberg.tables.default-namespace": "iceberg",
"iceberg.tables.default-id-columns": "_id",
"iceberg.tables.default-partition-by": "AccountId",
"iceberg.tables.dynamic-enabled": "false",
"iceberg.tables.auto-create-enabled": "true",
"iceberg.tables.evolve-schema-enabled": "true",

rishisolutionsbysms avatar Jul 29 '25 06:07 rishisolutionsbysms

The connector is not able to implement the upsert

iceberg.tables.upsert-mode-enabled ?

whitepowder avatar Jul 29 '25 06:07 whitepowder

Hi I have the same issue, i'd love to know what jars (and their versions) can i manually add for it to work, if you know what they are Thanks

iceberg-kafka-connect-runtime-hive-1.10.0-SNAPSHOT org/apache/hive/hive-exec/2.3.10/hive-exec-2.3.10.jar org/apache/commons/commons-configuration2/2.10.1/commons-configuration2-2.10.1.jar org/apache/commons/commons-text/1.11.0/commons-text-1.11.0.jar

did the trick for me

Thanks for your answer! Im using the version with hive runtime, I added the jars to /lib inside the connector's files I noticed there was alerady org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar there, tried to run the connector with that jar and without it. Got the same error message in both cases: "NoClassDefError: Could not initialize class org.hadoop.security.UserGroupInformation..."

blob321 avatar Jul 29 '25 06:07 blob321

Hi, I am facing the same issue with Iceberg Sink Connector with Kafka Connect. I am implementing a custom sink connector, nessie as a catalog. Any inclusions of jars or any procedure to address would be appreciated.

mgpradeepa avatar Aug 18 '25 08:08 mgpradeepa

@picarro-sdivakar can you try removing the following line, rebuilding and testing again?

https://github.com/apache/iceberg/blob/f6632e98f8b603822b8e656b2b9bf7d9d03b35c8/kafka-connect/build.gradle#L108

manuzhang avatar Oct 22 '25 12:10 manuzhang

Same here, tested on version 1.9.2 from Confluent Hub as well as rebuilding the current main branch

I've tried to remove exclude group: 'org.apache.commons', module: 'commons-configuration2' but got this instead:

java.lang.NoClassDefFoundError: org/apache/hadoop/util/PlatformName

Then tried to removed exclude group: 'org.apache.hadoop', module: 'hadoop-auth' but got this instead:

ClassNotFoundException: Class org.apache.hadoop.fs.azurebfs.SecureAzureBlobFileSystem not found

loicgreffier avatar Mar 04 '26 00:03 loicgreffier

I spent some time reproducing this locally and I can confirm the classloading failures people are reporting here are real.

I built the runtime zip from current main, unpacked it, and tested Hadoop UGI init using only jars from the plugin bundle (same isolation constraints Kafka Connect has). It fails first with: NoClassDefFoundError: org/apache/commons/configuration2/Configuration

Then I added only commons-configuration2 and hit the next one: NoClassDefFoundError: org/apache/hadoop/util/PlatformName

Looking at kafka-connect/build.gradle, runtime currently excludes both:

  • org.apache.commons:commons-configuration2
  • org.apache.hadoop:hadoop-auth

I removed those two excludes locally, rebuilt the runtime zip, and reran the same repro with only bundled jars. That resolved both failures and UGI initialized successfully.

So from what I can see, for Hadoop catalog mode these two excludes are too aggressive.

I do think there are tradeoffs to including them (larger bundle, wider transitive surface, possible Connect classpath/version conflicts in some environments), but functionally this seems to be the correct fix for the immediate breakage.

Curious what maintainers think: should we just include these deps in runtime for correctness, or do we want a different packaging approach for Hadoop-catalog usage?

adp2201 avatar Mar 12 '26 21:03 adp2201

I opened a draft PR with the minimal packaging change discussed here so it is easier to review in concrete form:

  • https://github.com/apache/iceberg/pull/15608

This PR removes the two excludes in iceberg-kafka-connect-runtime for hadoop-auth and commons-configuration2.

Would appreciate feedback on whether this is the right long-term direction or if maintainers prefer a different packaging strategy for Hadoop-catalog usage.

adp2201 avatar Mar 12 '26 21:03 adp2201

This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.

github-actions[bot] avatar Sep 09 '26 00:09 github-actions[bot]

This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'

github-actions[bot] avatar Sep 24 '26 00:09 github-actions[bot]