I am trying to deploy a maven project in minishift using the openjdk8 source to image strategy. The application is built and deployed, however, it fails at run-time with the following error:
Starting the Java application using /opt/run-java/run-java.sh ...
exec java -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/app-1.0-SNAPSHOT.jar
no main manifest attribute, in /deployments/app-1.0-SNAPSHOT.jar
I have this on my pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.mypackage.MyClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
I thought adding the manifest entry on the maven pom was enough.
Do I have to provide a separate manifest file? Do I have to provide extra VM argument to specify the main class? if so, how do I do that in openshift?
Any other better alternative?
Add a new environment variable JAVA_MAIN_CLASS
to your deployment config or via the Openshift user interface.
JAVA_MAIN_CLASS=com.mypackage.MyClass
That should resolve the issue.