Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #239 from galasa-dev/fix-noclassdeferror
Browse files Browse the repository at this point in the history
Move class loader line for Kafka classes at runtime
  • Loading branch information
jadecarino authored Jun 28, 2024
2 parents 7a6df1c + 0ad3676 commit e3de882
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class KafkaEventProducer implements IEventProducer {

public KafkaEventProducer(Properties properties, String topic) {

Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

KafkaProducer<String, String> producer = new KafkaProducer<String, String>(properties);
this.producer = producer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public Properties createProducerConfig(IConfigurationPropertyStoreService cps, S
try {
String bootstrapServers = cps.getProperty("bootstrap", "servers");

// Needed to get the Kafka classes at runtime
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

properties.put("bootstrap.servers", bootstrapServers);
properties.put("topic", topic);
properties.put("key.serializer", StringSerializer.class.getName());
Expand Down

0 comments on commit e3de882

Please sign in to comment.