Open salvalabajos opened 1 year ago
@salvalabajos Thanks for the analysis and providing a workaround to demonstrates how the jib.container.entrypoint
can be leveraged in case you don't want to rely on the default entrypoint. Adding in a reference doc link as a supplement: https://github.com/GoogleContainerTools/jib/blob/afe98e7f23a0ea56b6b3bbde29600280777fe75e/jib-gradle-plugin/README.md#custom-container-entrypoint
@mpeddada1 Is this issue need fix should I pick this up ?
@Abhijeetmishr Thanks for reaching out. We are accepting contributions for this issue.
@mpeddada1 Hey Mridula, I have tried building project locally using this command ./gradlew build but I am getting some error any hints/suggestion.
Regrads
Environment:
Description of the issue: When packaging a Java application with
jib-gradle-plugin
and running the resulting docker image the application crashes with a ClassNotFoundException. In our particular example the error wasClassNotFoundException: com.scurrilous.circe.checksum.Crc32cIntChecksum
, which is a dependency of Pulsar.Expected behavior: The application should run fine and all dependencies should be included in the docker image.
Steps to reproduce: I tried creating a project with as little dependencies as possible but there aren't that many
.nar
libraries out there. So I used Pulsar but I don't know how to reproduce the class not found error, there must be some specific configuration for Pulsar that I am missing.Anyways, I think we can clearly see the problem without getting to the ClassNotFoundException:
cat /app/jib-classpath-file
to see the list of dependencies. You will not seecirce-checksum-4.14.5.nar
norcpu-affinity-4.14.5.nar
.ls /app/libs/ | grep nar
you will see the.nar
files there.So this means the dependencies are copied to the image, as they should, but they are not included in the classpath file and thus are "invisible" to the application, which explains the class not found.
Additional Information: I think the issue is the way jib calculates dependencies:
https://github.com/GoogleContainerTools/jib/blob/master/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java#L309 This excludes anything that is not a
.jar
file and would explain the problem.Workaround: If you are facing this problem, one thing you can do is override the entrypoint of the docker image like this:
This will add all
*.nar
files from/app/libs/
to the classpath, on top of whatever thejib-classpath-file
contains.