Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..
724 views

Not able to execute Kafka Producer Code in Vugen

I am trying to send a message to Kafka cluster through a java program in Vugen 12.50 using Java Vuser(over HTTP) protocol. The code looks like:

import lrapi.lr;
import java.util.*;
import org.apache.kafka.clients.producer.*;
import org.apache.kafka.clients.producer.internals.*;
import org.apache.kafka.clients.*;

public class Actions
{
  
 
    public int init() throws Throwable {
        return 0;
    }

  public int action() throws Throwable {
      String topicName = "TopicName";
      String value = "PTTest1";

      Properties props = new Properties();      props.put("bootstrap.servers", "AAA-abcde-001:9092");      props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");         
      props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

     Producer<String, String> producer = new KafkaProducer <String,String>(props);

      ProducerRecord<String, String> record = new ProducerRecord<String,String>(topicName,value);      producer.send(record);           
      producer.close();
      return 0;
    }//end of action
	
  public int end() throws Throwable {
        return 0;
    }

  }

Though it does not give any compilation errors in Vugen, it fails during run time with below error:

Error: at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at DummyClassLoader.loadClass(DummyClassLoader.java:15) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at ScriptFactory.getScriptObject(ScriptFactory.java:50) Error: Can't create script object. Error: Exception was raised when calling abort-cleanup function in extension java_int.dll: System Exceptions: EXCEPTION_ACCESS_VIOLATION 

I have used kafka-clients-0.9.0.0.jar(kafka-clients-0.10.0.0. jar as well), java-util-1.3.1.jar and jre6\lib\rt.jar in runtime classpath and have JDK 1.6 for Vugen compatibility.

I have tried setting up environment and system variables but the error still persists. Can you please point me in the right direction to resolve this error.

Shlomi Nissim

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.