I'm working on a Java project which uses the msf4j library. In IntelliJ IDEA I'm able to run the project, everything works as expected. However, If I build a jar file from this project (aplying the first part of this answer), the jar file cannot run (using java -jar my_jar.jar
). It says:
Error: Could not find or load main class Main
I've cleaned the project several times, restarted everything, even tried to use older versions of the msf4j, nothing has helped. If I replace the msf4j with something else (e.g. javalin), the built jar file is runnable, the problem goes away.
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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group.id</groupId>
<artifactId>my_artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.wso2.msf4j</groupId>
<artifactId>msf4j-core</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
<properties>
<microservice.mainClass>src.main.java.Main</microservice.mainClass>
</properties>
</project>
MANIFEST.MF:
Manifest-Version: 1.0
Main-Class: Main
I think the problem is somewhere in the msf4j artifacts. Any idea how to fix this problem?
from the top of my head I thing you need to set in maven a project parent and remove the dependency.
<parent>
<groupId>org.wso2.msf4j</groupId>
<artifactId>msf4j-service</artifactId>
<version>2.5.2</version>
</parent>
HTH, Gal