s2i-java icon indicating copy to clipboard operation
s2i-java copied to clipboard

[ERROR] No app.jar file located in /opt/openshift

Open dhanugithub opened this issue 7 years ago • 6 comments

Hello,

I am trying to use this repo to create builder image and use it with source code (git repo) to create a docker image of an application (using s2i build). While the build is successful, I still get following error:

Copying all jar artifacts from /opt/app-root/src/source/target directory into /opt/openshift for later deployment... ls: cannot access /opt/openshift/*.jar: No such file or directory [ERROR] No app.jar file located in /opt/openshift Build failed ERROR: An error occurred: non-zero (13) exit code from openmeetings-builder

Here, openmeetings-builder is my builder image. I am a beginner in Docker, s2i. I am failing to understand the issue. Can anyone please point out where I am making mistake? Thank you.

dhanugithub avatar Jul 31 '18 11:07 dhanugithub

@jorgemoralespou can you please help me with this? Thank you.

dhanugithub avatar Aug 06 '18 10:08 dhanugithub

A good starting point to solve your problem is an assemble script: s2i-java/sti/bin/assemble.

If you are using gradle build then following line in the script:
https://github.com/jorgemoralespou/s2i-java/blob/221c47a3c27c6e422c12ad5989cef7d06b4d1229/sti/bin/assemble#L136 results with following error: ls: cannot access /opt/openshift/*.jar: No such file or directory

Obviously no jars were copied to the deploy directory. You should probably set ARTIFACT_DIR which points to directory where build artifact resides.

mcurcija avatar Aug 06 '18 20:08 mcurcija

i had also the problem. After i defined the "ARTIFACT_DIR" variable i got the problem solved. Is there any way to get only the artifacts into the container without the source code ?

der-ali avatar Sep 27 '18 09:09 der-ali

@uocxp you're probably wanting to use the binary-build option. Particularly if you've got a "fat jar".
oc start-build myapp --from-dir . --follow that would push any artifacts you've got in your local folder into the build.

https://docs.openshift.com/container-platform/3.10/dev_guide/dev_tutorials/binary_builds.html

welshstew avatar Sep 27 '18 10:09 welshstew

@welshstew I am not sure if you got my point. When i use this s2i i get in addition to the jar file also the whole source code of the app in the container which makes the docker image really heavy. Usually i have a multistaging dockerfile to avoid this problem. Therefore i asked if it's possible while using this s2i to get only the jar file staged to the image without the source code.

der-ali avatar Sep 27 '18 12:09 der-ali

@uocxp checkout the buildconfig in this template: https://github.com/welshstew/fis2-generic-buildtemplate/blob/master/template.yml you'll have to change the imagestream to this one - that one is using the red hat fis-java-openshift - but should get the same results.

Note that the buildconfig doesn't have any git repository source defined, and is a binary build.

Once you have the buildconfig ensure you're building from a directory which only has a fat jar in it, and run: oc start-build my-app --from-dir=. -w --follow

hope these may help: https://github.com/welshstew/fis2-generic-buildtemplate https://github.com/welshstew/fis2-generic-runtemplate

welshstew avatar Sep 27 '18 14:09 welshstew