openshift: no main manifest attribute in jar maven project

locorecto :

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?

user284856 :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=164421&siteId=1