Deb
Deb

Reputation: 5649

Unable to Deploy Spring Boot Application In Openshift

I am following the below steps to run my Spring Boot app: https://github.com/debasen/springboot-demo.git in Open shift:

  1. Add Red Hat OpenJDK8 to my project.

enter image description here 2. Next enter image description here 3. Add hit repository enter image description here

After doing this. I am getting the following Log at Build:

Cloning "https://github.com/debasen/springboot-demo.git " ...
    Commit: c3b500b7c27540de6f1ef90734aca8b1a09d6fb6 (Initial Commit)
    Author: Admin <Admin@DESKTOP-78DNBRA>
    Date:   Sun Mar 18 20:48:29 2018 +0530
Pulling image "registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift@sha256:afe904fd986c4147d1905813eb1a2f5bc3480ecad5b70b4ccfec384271777429" ...
==================================================================
Starting S2I Java Build .....
S2I source build with plain binaries detected
Copying binaries from /tmp/src to /deployments ...
... done

Pushing image docker-registry.default.svc:5000/boot-test1/spring-demo:latest ...
Push successful

And Deployment fails with the following log:

Starting the Java application using /opt/run-java/run-java.sh ...
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/jolokia.properties -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
Error: -jar requires jar file specification
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32      use a 32-bit data model if available
    -d64      use a 64-bit data model if available
    -server   to select the "server" VM
                  The default VM is server,
                  because you are running on a server-class machine.


    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  Warning: this feature is deprecated and will be removed
                  in a future release.
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html  for more details.

As no jar is created at the time of build the deployment is failing. While the project in the sample repository https://github.com/jboss-openshift/openshift-quickstarts works fine. I tried Heroku to host my app. It works fine in Heroku. But not working in Openshift. Please tell me what am I missing.

Upvotes: 1

Views: 10900

Answers (2)

Eng.Ahmad
Eng.Ahmad

Reputation: 101

I got the same error. However, the solution for me was to make the application produce Jar instead of War.

I use maven to package the application. So, In pom.xml I changed

<packaging>war</packaging>

to

<packaging>jar</packaging>

Upvotes: 1

Jiri Fiala
Jiri Fiala

Reputation: 1400

The build log is not reporting an explicit error, but suggests that nothing was built actually:

S2I source build with plain binaries detected
Copying binaries from /tmp/src to /deployments ...
... done

As your repo "hides" the app source in a parent folder, try either specifying the contextDir (that is /, by default) to springboot-demo for your build, or move the app source to the root of your git repository.

You can edit the build Configuration using the oc CLI by oc edit bc/<build_config_name> or do the same using the web interface by clicking the "advanced options" link when you're providing the git repo URL during deployment of the application from the catalog, or by using Actions -> Edit menu item when browsing the existing build configuration.

Upvotes: 4

Related Questions