Solved

Issue with NeoLoad custom action dependencies

  • 27 February 2024
  • 4 replies
  • 112 views

Badge

I created a custom action for NeoLoad and used several dependencies that I added to the pom.xml file. I built a JAR file with all the dependencies, placed it in the extlib directory of my project, and added the action to one of my user paths. However, the following error appears when I try to execute the user path:

ERROR - neoload.CustomAction: Failed to construct kafka producer org.apache.kafka.common.KafkaException: Failed to construct kafka producer
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:439)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:289)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:316)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:301)
at com.company.platform.kafka.action.KafkaProducerActionEngine.sendMessage(KafkaProducerActionEngine.java:77)
at com.company.platform.kafka.action.KafkaProducerActionEngine.execute(KafkaProducerActionEngine.java:51)
at com.neotys.nl.lg.engine.L.internalExecute(L.java:100)
at com.neotys.nl.lg.engine.m.b(m.java:165)
at com.neotys.nl.lg.engine.w.d(w.java:169)
at com.neotys.nl.lg.engine.x.internalExecute(x.java:81)
at com.neotys.nl.lg.engine.m.b(m.java:165)
at com.neotys.nl.lg.engine.w.d(w.java:169)
at com.neotys.nl.lg.engine.x.internalExecute(x.java:81)
at com.neotys.nl.lg.engine.m.b(m.java:165)
at com.neotys.nl.lg.engine.I.E(I.java:236)
at com.neotys.nl.lg.engine.I.internalExecute(I.java:94)
at com.neotys.nl.lg.engine.m.b(m.java:165)
at com.neotys.nl.lg.engine.d.b(d.java:165)
at com.neotys.nl.lg.engine.d.run(d.java:96)
Caused by: java.lang.ExceptionInInitializerError
at io.confluent.kafka.serializers.KafkaAvroSerializer.configure(KafkaAvroSerializer.java:50)
at com.company.platform.kafka.common.serde.KafkaAvroCloudEventSerializer.configure(KafkaAvroCloudEventSerializer.java:77)
at org.apache.kafka.clients.producer.KafkaProducer.<init>(KafkaProducer.java:375)
... 18 more
Caused by: org.apache.kafka.common.config.ConfigException: Invalid value io.confluent.kafka.serializers.context.NullContextNameStrategy for configuration context.name.strategy: Class io.confluent.kafka.serializers.context.NullContextNameStrategy could not be found.
at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:744)
at org.apache.kafka.common.config.ConfigDef$ConfigKey.<init>(ConfigDef.java:1172)
at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:152)
at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:172)
at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:211)
at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:373)
at org.apache.kafka.common.config.ConfigDef.define(ConfigDef.java:386)
at io.confluent.kafka.serializers.AbstractKafkaSchemaSerDeConfig.baseConfigDef(AbstractKafkaSchemaSerDeConfig.java:193)
at io.confluent.kafka.serializers.KafkaAvroSerializerConfig.<clinit>(KafkaAvroSerializerConfig.java:43)
... 21 more

The class, which is one of the action's dependencies, is definitely present in the JAR file. The class and package names are correct. Also, there is a unit test that calls the method, and it works fine.

Please advise how to fix the issue.

icon

Best answer by Nouredine 27 February 2024, 10:55

View original

4 replies

Userlevel 2
Badge +1

Hello, it looks like a class loader issue. You should try this instead in your action:

 

final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

        Thread.currentThread().setContextClassLoader(KafkaProducerActionEngine.class.getClassLoader());

        try {

            // put here code that is initializing Kafka and Avro

        } finally {

            Thread.currentThread().setContextClassLoader(contextClassLoader);

        }

 

Also as a side note the next NeoLoad version 2024.1 planned for end of March will have support of Kafka.

Badge

Hello, it looks like a class loader issue. You should try this instead in your action:

 

final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();         Thread.currentThread().setContextClassLoader(KafkaProducerActionEngine.class.getClassLoader());         try {             // put here code that is initializing Kafka and Avro         } finally {             Thread.currentThread().setContextClassLoader(contextClassLoader);         }

 

Also as a side note the next NeoLoad version 2024.1 planned for end of March will have support of Kafka.

I can’t modify the code because it’s a part of one of the library dependencies. 

Could you please refrain from marking questions as 'Solved'? Let the topic starter decide whether your reply fully answers the question.

Userlevel 2
Badge +1

Hello, i did not do anything on my side to change the marking question to “Solved”. Actually i don’t think i have the permission to do it since it does not make sense. How could i know that it’s solved or not? :-)

Userlevel 5
Badge +2

Hey @Nouredine , apologies, it was our system that accidentally framed you by marking this solved. Thanks for your input!

@antonadamov the question is now back to it’s original state, we let you decide once it is solved which I hope it will be very soon 😊

 

Cheers!

Reply