I have created a Spring Boot application to consume messages from a Kafka topic using Avro schema. The application works fine on my local machine and also runs successfully on a Linux server when I execute it using “java -jar application.war”.
However, when I deploy the WAR package on the WebLogic server, it throws the following errors.
24-08-21 10:45:00.665 [org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] ERROR o.s.k.listener.LoggingErrorHandler - Error while processing: null
org.apache.kafka.common.errors.SerializationException: Error deserializing key/value for partition PKY.Organization.openingShop.topic.public.any.v2-1 at offset 4130208. If needed, please seek past the record to continue consumption.
Caused by: org.apache.kafka.common.errors.SerializationException: Error retrieving Avro schema for id 729
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alert.createSSLException(Alert.java:131)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:377)
I have already set the correct keystore path on the server.
Could anyone please guide me on what changes I need to make at the code level or the WebLogic configuration level to resolve this issue?
Spring boot version 2.4.13.
Weblogic version: 12.2.1c
Java version: “1.8.0_412”
I am including some important code snippets below for reference.
Configuration.java
public ConsumerFactory<KeySchema, CountryShop> consumerFactory(KafkaProperties kafkaProperties) {
Map<String,Object> config = new HashMap<>();
config.put("bootstrap.servers","rp-dkxn-qi-akz-qq-os:9080");
config.put("sasl.mechanism","SCRAM-SHA-256");
config.put("security.protocol", "SASL_SSL");
config.put("ssl.truststore.location", "/u02/oracle/certs/truststore.jks");
config.put("ssl.truststore.password", "**********");
config.put("sasl.jaas.config", "org.apache.kafka.common.security.scram.ScramLoginModule required username="pp.countryShop.v1" password="*************************";");
config.put("schema.registry.url", "https://mq-us-ap-uu-xc-dk-ia:8081");
config.put("schema.registry.ssl.truststore.location", "/u02/oracle/certs/truststore.jks");
config.put("schema.registry.ssl.truststore.password", "**********");
config.put("schema.registry.ssl.keystore.location", "/u02/oracle/certs/keystore.jks");
config.put("schema.registry.ssl.keystore.password", "***************");
config.put("group.id", "PKY.schedule.PKYDev.consumerGroup.v1");
config.put("key.deserializer", KafkaAvroDeserializer.class.getName());
config.put("value.deserializer", KafkaAvroDeserializer.class.getName());
config.put("auto.register.schemas", false);
config.put("specific.avro.reader", true);
config.put("use.latest.version", true);
I have changed the some name for security purposes.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.13</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.maersk</groupId>
<artifactId>CountryShopListener</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Emp_gsisListener</name>
<description>Consuming message from GSIS</description>
<properties>
<java.version>1.8</java.version>
<start-class>com.countryShop.countryShopListener</start-class>
<confluent.version>5.5.0</confluent.version>
</properties>
<repositories>
<repository>
<id>confluent</id>
<url>https://packages.confluent.io/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>common-config</artifactId>
<version>${confluent.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>mq-jms-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-avro-serializer</artifactId>
<version>${confluent.version}</version>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry-client</artifactId>
<version>${confluent.version}</version>
</dependency>
<dependency>
<groupId>io.confluent</groupId>
<artifactId>common-utils</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0</version>
<scope>test</scope>
</dependency>
<!--Add this block : Start -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!--Add this block : End -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>com.CountryShop</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have also added the certificate detail in weblogic startup Java argument
-Djavax.net.ssl.trustStore=/u02/oracle/certs/truststore.jks
-Djavax.net.ssl.trustStorePassword=*****************
-Djavax.net.ssl.keyStore=/u02/oracle/certs/keystore.jks
-Djavax.net.ssl.keyStorePassword=*******************
Please suggest How can I resolve the error encountering after deploying application on weblogic server.
I had tried many configuration change.
1- Tried by adding custom Identity keystore and truststore on weblogic console keystore and ssl.– It throw Received fatal alert: bad_certificate
2- Define config.java file info on application.yml file as well.
3- tried by importing schema registry public certificate in JAVA_HOME/lib/security/cacerts.– It throw Received fatal alert: bad_certificate
I appreciate your suggestion to resolve this issue.