Ravi Kumar Pisupati Member since 2015 75 posts
Posted: 9 months ago
Last activity: 9 months ago

Unable to pass the keystore file data in Kafka integration using java code in V722


We are using V722 in our application. We have a requirement to push the message to Kafka topic. As we don't have DataSet in our Pega version, we are using Java, Avro schema to connect Kafka. For that, we are writing a java code initially and will leverage the same in the Pega function. We have schema ready and we have all necessary jars imported in our system. While passing the message to Kafka, we need to add the SSL configuration given by the Kafka team. For that, we have created Keystore instances and added the jks files accordingly. Now we need to pass this information as a part of java code to call KafkaProducer(props) before writing the message on Topic. I am not sure how to send the Keystore files data in the below mentioned java code but what I did is like I have stored these files into ServicePath directory and passing the file with the password int he below java code but somehow system is not picking up this jks file and is throwing exception. Please help me on how to resolve this issue.


java.util.Properties props = new java.util.Properties();

String tempPath = tools.getProperty("pxProcess.pxServiceExportPath").getStringValue();

//configure the following three settings for SSL Encryption
props.put(org.apache.kafka.clients.CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
// configure the following three settings for SSL Authentication
props.put(org.apache.kafka.clients.producer.ProducerConfig.RETRIES_CONFIG, 0);
props.put(org.apache.kafka.clients.producer.ProducerConfig.ACKS_CONFIG, "all");
props.put(org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class);
props.put(org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.ByteArraySerializer.class);
/* oLog.error(props); */
oLog.infoForced("All properties values"+props);
org.apache.kafka.clients.producer.Producer producer = new org.apache.kafka.clients.producer.KafkaProducer(props);

org.apache.kafka.clients.producer.ProducerRecord prodRecord = new org.apache.kafka.clients.producer.ProducerRecord(Topic, out.toByteArray());
//oLog.infoForced("**Pushing data"+out.toByteArray());
catch(Exception e)
{ stringWriter = new; exceptionPrinter = new;
String sStackTrace = stringWriter.toString();
String[] lines = sStackTrace.split("\n\r|\r|\n");
for (int i = 0; i < lines.length; i++) {
oLog.infoForced("** Stack Trace Is: " + lines[i]);}
//oLog.infoForced("** Stack Trace Is: " + sStackTrace);
return false;


The highlighted portion is throwing exception in my case and not sure how to resolve it. Here is the java exception from log statement. Why there is a missing "/" after "file:" from the log statement given below. Not sure.


** Stack Trace Is: Caused by: org.apache.kafka.common.KafkaException: file:/web:/StaticContent/global/ServiceExport/keystore1.jks (No such file or directory)



Ravi Kumar.

***Edited by Moderator Marissa to update platform capability tags****

Pega Platform Low-Code App Development Low-Code App Development Dev/Designer Studio Data Integration Java and Activities
Share this page LinkedIn