question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Class could not be found

See original GitHub issue

I’ve built the JAR and put it in the plugin.path:

root@4cc770014999:/# ls -lR /usr/share/java/
/usr/share/java/:
total 80
drwxr-xr-x 2 root root  4096 Dec 15 06:17 confluent-common
drwxr-xr-x 2 root root  4096 Dec 15 06:18 confluent-control-center
drwxr-xr-x 2 root root  4096 Dec 15 06:18 confluent-hub-client
drwxr-xr-x 2 root root  4096 Dec 15 06:18 confluent-rebalancer
-rw-r--r-- 1 root root   957 May  6  2014 java_defaults.mk
drwxr-xr-x 1 root root  4096 Dec 15 06:18 kafka
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-activemq
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-elasticsearch
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-hdfs
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-ibmmq
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-jdbc
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-jms
drwxr-xr-x 2 root root  4096 Dec 15 06:21 kafka-connect-s3
drwxr-xr-x 2 root root 12288 Dec 15 06:21 kafka-connect-storage-common
drwxr-xr-x 9 root root   288 Jan 22 09:23 kafka-connect-transform-common
drwxr-xr-x 2 root root  4096 Dec 15 06:17 kafka-serde-tools
drwxr-xr-x 2 root root  4096 Dec 15 06:18 monitoring-interceptors
drwxr-xr-x 2 root root  4096 Dec 15 06:17 rest-utils
drwxr-xr-x 2 root root  4096 Dec 15 06:17 schema-registry
…
/usr/share/java/kafka-connect-transform-common:
total 5400
-rw-r--r-- 1 root root  133937 Jan 22 09:18 connect-utils-0.3.141.jar
-rw-r--r-- 1 root root 1493680 Jan 22 09:18 freemarker-2.3.25-incubating.jar
-rw-r--r-- 1 root root 2256213 Jan 22 09:19 guava-18.0.jar
-rw-r--r-- 1 root root   55784 Jan 22 09:18 jackson-annotations-2.8.0.jar
-rw-r--r-- 1 root root  281079 Jan 22 09:18 jackson-core-2.8.5.jar
-rw-r--r-- 1 root root 1236315 Jan 22 09:18 jackson-databind-2.8.5.jar
-rw-r--r-- 1 root root   64477 Jan 22 09:22 kafka-connect-transform-common-0.1.0-SNAPSHOT.jar

When Kafka Connect runs it loads the plugins

 [2019-01-22 09:53:36,256] INFO Loading plugin from: /usr/share/java/kafka-connect-transform-common (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,347] INFO Registered loader: PluginClassLoader{pluginLocation=file:/usr/share/java/kafka-connect-transform-common/} (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,348] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ToLong$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,348] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.BytesToString$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,348] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ExtractNestedField$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,348] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.TimestampNow' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,364] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ExtractNestedField$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,365] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.BytesToString$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,365] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ChangeTopicCase' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,365] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.PatternRename$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,365] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.SetNull$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,366] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.SetNull$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,366] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.PatternRename$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,366] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.PatternFilter$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,366] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ToJSON$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,367] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.PatternFilter$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,367] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ToLong$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,367] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ToJSON$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,367] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ChangeCase$Key' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,368] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ExtractTimestamp$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)
 [2019-01-22 09:53:38,368] INFO Added plugin 'com.github.jcustenborder.kafka.connect.transform.common.ChangeCase$Value' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader)

But when I try to use a transform I get a Class… could not be found error:

$ curl -X POST http://localhost:8083/connectors -H "Content-Type: application/json" -d '{
          "name": "file_sink_99",
          "config": {
                  "connector.class": "org.apache.kafka.connect.file.FileStreamSinkConnector",
                  "topics":"test_topic",
                  "value.converter":"org.apache.kafka.connect.json.JsonConverter",
                  "value.converter.schemas.enable": false,
                  "key.converter":"org.apache.kafka.connect.json.JsonConverter",
                  "key.converter.schemas.enable": false,
                  "file":"/data/file_sink_99.txt",
                  "transforms":"tojson",
                  "transforms.tojson.type":"com.github.jcustenborder.kafka.connect.transform.common.ToJSON$Value",
                  "transforms.tojson.schemas.enable":true
                  }
          }'
{"error_code":400,"message":"Connector configuration is invalid and contains the following 2 error(s):\nInvalid value com.github.jcustenborder.kafka.connect.transform.common.ToJSON$Value for configuration transforms.tojson.type: Class com.github.jcustenborder.kafka.connect.transform.common.ToJSON$Value could not be found.\nInvalid value null for configuration transforms.tojson.type: Not a Transformation\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"}⏎

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jcustenbordercommented, May 25, 2020

Don’t feel bad. Issues like these are the hardest to figure out.

0reactions
ecararuscommented, Feb 24, 2022

Had similar issue so in case you’re using x.properties the type should be: transforms.HoistValue.type= org.apache.kafka.connect.transforms.HoistField\$\Value

also to mention if you still get the “Class could not be found” check the class path or load the dependency i classpath

Read more comments on GitHub >

github_iconTop Results From Across the Web

The type or namespace name 'GradeBook' could not be found ...
It is the class GradeBook that the error message appears from when im trying to create and object in "GradeBook myGradeBook = new...
Read more >
Java Guide: How to Fix "Could not find or load main class"
The Java “Could not find or load main class” error is thrown when the JVM fails to find or load the main class...
Read more >
Java – “Could Not Find or Load Main Class” Error | Baeldung
And it failed with the error “Could not find or load main class helloworld.” As discussed earlier, the compiler will generate the .class...
Read more >
Compiler Error CS0246 | Microsoft Learn
A type or namespace that is used in the program was not found. You might have forgotten to reference (References) the assembly that...
Read more >
Error the type or namespace name [Class] could not be found ...
Class Libraries are created for saving Core,Entities,DataAccess & Business Layers.Asp.Net Mvc Core references Core,Entities & Business layers.This error is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found