1

I am new at Docker and trying to build and run my own container with Spring Boot Application. It runs on Kotlin and Gradle. I have built the image with simply this command, provided by gradle with spring boot plugin (id("org.springframework.boot") version "2.7.0-SNAPSHOT")

gradlew bootBuildImage

As a result i am getting this. Here are the logs: https://pastebin.com/xMW82vcw

The problem is, while trying to run my built image i am getting this error.

C:\projects\monetka-app>docker run docker.io/library/monetka-app:0.0.1-SNAPSHOT
Setting Active Processor Count to 6
unable to determine class count
unable to walk /workspace
unable to open ZIP /workspace/META-INF/licenses/client-2.1.jar
read /workspace/META-INF/licenses/client-2.1.jar: is a directory
ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator': exit status 1

Here are the docker images i have locally in docker desktop. My gradle version is 7.4.1, and JDK in use is 17.

Lackier
  • 11
  • 2
  • 2
    You don't seem to have included what "this" you're getting, or what the actual error is. Can you [edit] the question to include a [mcve], including enough code to reproduce the error and the actual text of the error message? These details should be included directly in the question (not behind links) as plain text (not images). – David Maze Apr 03 '22 at 23:21
  • How did you include `client-2.1` to your app? – Huu Phuong Vu Apr 04 '22 at 02:27

1 Answers1

0

When you run gradlew bootBuildImage, you're using Cloud-Native buildpacks to generate the image. This is a bug in a tool installed by the buildpack.

The Java Cloud-Native buildpack will install a tool called memory-calculator. This tool runs prior to your application starting up and sets up all the JVM memory flags that are required to keep the JVM from going past the defined memory limit you set. For example, if you set the memory limit of your container to be 1G, the memory calculator will adjust settings like -Xmx accordingly.

To do this, the memory calculator needs to know how many class files you have in your application, so it searches for them. This process is failing because it sees something with an extension of .jar and so it's trying to read the number of class files in that JAR, however, what it's seeing META-INF/licenses/client-2.1.jar isn't actually a JAR. It's a directory.

I opened a bug report for you here: https://github.com/paketo-buildpacks/libjvm/issues/160

If you are able to remove the file META-INF/licenses/client-2.1.jar (or change so it doesn't have a .jar extension) you should be able to work around this until we can resolve the issue.

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28
  • Tried the way you adviced me, deleting the .jar directories. I used this command: `docker run --rm -it --entrypoint bash`. There were 4 of .jar directories: _client-2.1.jar, common-2.1.jar, saslprep-1.1.jar, stringprep-1.1.jar_. I deleted them, commited the change into a new image. Then trying to run image with `docker run ` and container simply is not running with no logs nor in the terminal where i run it, nor in docker desktop. – Lackier Apr 04 '22 at 22:18
  • I don't believe that will work. You need to delete them from your JAR file that gets built by Gradle. I'm not sure what is causing those directories to be added. Do you have a Gradle plugin or something that is writing the license info into `META-INF/licenses`? If so, disable that, then try a `gradlew bootBuildImage`. – Daniel Mikusa Apr 06 '22 at 13:28