How to use S2I for springboot application + gradle

Latest response

I am trying to build and deploy a simple spring boot appusing openshift S2I. It uses gradle. Below is the link to repo. Error details are as follows . Can someone share the guide lines for deploying springboot application using S2I.

I am getting following erroe when .class or .jar file is not checked in.

Starting the Java application using /opt/run-java/ ...
ERROR: Neither $JAVA_MAIN_CLASS nor $JAVA_APP_JAR is set and 0 JARs found in /deployments (1 expected)
exec java -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/ -Xms256m -Xmx256m -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:ParallelGCThreads=1 -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -XX:CICompilerCount=2 -XX:+ExitOnOutOfMemoryError -cp . -jar

After adding .jar file following error.

Starting the Java application using /opt/jboss/container/java/run/ ...
INFO exec java -javaagent:/opt/jboss/container/jolokia/jolokia.jar=config=/opt/jboss/container/jolokia/etc/ -XX:+UseParallelOldGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:+ExitOnOutOfMemoryError -cp ".:/deployments/*" StudentApplication.class


I have a similar situation, the following ones:

1- Dockerfile:

2- Fabric8/s2i:

But the 2nd options is from 3rd party and uses an obsolete docker image, but is the most closely to original openshift s2i java image (same experience).

I need to know too, what is the correct way to deploy a java + gradle application in an OpenShift cluster. Regards!


Not sure this will work for your gradle problem, but are you setting the "ARTIFACT_DIR" environment in your s2i build environments? This ENVAR should point to the folder containing the articfacts of your java build and these will then be copied to the /deployment folder. This fixed the exact same error for me in our java apps.

Some documentation: