I'm trying to containerise a kafka consumer using docker. I'm using a multistage docker file to do this, but I'm grtting this error every time I run the command. The program runs fine when I try to run from the IDE but doesn't seem to work if I build it using maven and try running it using the Jar file.
I'm guess this is caused because the compiler doesn't see an executable jar file while searching for the given class and throws an exception. I tried out multiple solutions but nothing seemed to quite work.
Here's the pom.xml file
<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>
<groupId>com.sweethome</groupId>
<artifactId>notificationservice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.sweethome.notificationservice.Consumer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.sweethome.notificationservice.Consumer</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<finalName>notificationService</finalName>
</build>
<properties>
<java.version>11</java.version>
</properties>
</project>
Help! :')
Tried out multiple solutions from here but it did not work.