redhat-buildpacks / snowdrop-buildpack

Buildpacks for Spring Boot Applications
Apache License 2.0
0 stars 1 forks source link

Argument "content" is null #9

Open iocanel opened 2 years ago

iocanel commented 2 years ago

I tried using the buildpacks against a spring and quarkus sample app. In both cases I got this error on examples that we working fine with other builder images.

[jbang] Building jar...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.IllegalArgumentException: argument "content" is null
        at com.fasterxml.jackson.databind.ObjectMapper._assertNotNull(ObjectMapper.java:4429)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2718)
        at dev.snowdrop.buildpack.Buildpack.prep(Buildpack.java:239)
        at dev.snowdrop.buildpack.Buildpack.build(Buildpack.java:102)
        at dev.snowdrop.buildpack.Buildpack.<init>(Buildpack.java:96)
        at dev.snowdrop.buildpack.EditableBuildpack.<init>(EditableBuildpack.java:16)
        at dev.snowdrop.buildpack.BuildpackBuilder.build(BuildpackBuilder.java:72)
        at pack.main(pack.java:15)

Steps to reproduce (requires jbang)

Clone the project:

git clone git@github.com:snowdrop/java-buildpack-client.git
cd java-buildpack-client/samples/hello-spring

Edit pack.java and add the following line to the builder:

        .withBuildImage("redhat/buildpacks-stack-snowdrop-build:jvm")

Invoke the build:

./pack.java
cmoulliard commented 2 years ago
iocanel commented 2 years ago
  • Why do you think that we have an issue with this builder as the error is reported by the Java Buildpack client and not during the image build ?

The client is processing the metadata that are obtained from the builder image and fails. It works fine with the quarkus builder image and the default builder image, too.

  • Why do we have to use jbang ? What is the added value of using jbang ? @iocanel

We don't have to. It's just the easier way possible to use the java client without setting up a project.

BarDweller commented 2 years ago

To expand a bit here.. builder images should have a label 'io.buildpacks.builder.metadata' which is looked for by the platform, because it contains json that defines (amongst other things) the runImage that should be used when building apps with the builder image.

From the stack trace, it would appear that the label is absent, or is being given back to the buildpack client code as null.

What does docker inspect (or pack inspect) show for the builder image ?

cmoulliard commented 2 years ago

fails

Is there a way to get a more verbose response ? @BarDweller

BarDweller commented 2 years ago

fails

Is there a way to get a more verbose response ? @BarDweller

Yes, we can probably update the client to have a more graceful error in this situation. It's unexpected though.. I guess you'd see it if you used a non-builder image by mistake. Could add some basic checks to see if the image has the required metadata and exit appropriately. That won't fix this image tho, it'll just make it less stack-tracey ;)

cmoulliard commented 2 years ago

That won't fix this image tho, it'll just make it less stack-tracey ;)

So 2 actions are needed; 1) add the missing label top of this builder image and 2) Make the java buildpack client a bit more verbose. Can you work on that (create issues, ...) ? @BarDweller

BarDweller commented 2 years ago

I'm having a quick peek first to try to confirm where that property is referenced in the specs. It's nearly a year since I wrote the java buildpack client, the specs have moved on a few revisions since... makes sense to go back and ensure the label is valid (and if not, what it should be doing instead)

BarDweller commented 2 years ago

Aha.. so .. a bit more digging, @iocanel the problem is you're trying to use a stack as a builder.

   .withBuildImage("redhat/buildpacks-stack-snowdrop-build:jvm")  

should be

   .withBuildImage("redhat/buildpacks-builder-maven-jvm:latest")  

That's why the image you've selected is missing the metadata label, and fails =)

BarDweller commented 2 years ago

That won't fix this image tho, it'll just make it less stack-tracey ;)

So 2 actions are needed; 1) add the missing label top of this builder image and 2) Make the java buildpack client a bit more verbose. Can you work on that (create issues, ...) ? @BarDweller

1) not required, builder image already has correct labels, initial reported bug is using incorrect image. 2) https://github.com/snowdrop/java-buildpack-client/issues/27