Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating project's jackson version causes container creation to fail #13635

Closed
laurentgo opened this issue Dec 2, 2020 · 15 comments
Closed

Updating project's jackson version causes container creation to fail #13635

laurentgo opened this issue Dec 2, 2020 · 15 comments
Labels
area/container-image kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant

Comments

@laurentgo
Copy link

Describe the bug
When updating jackson's version in a Maven project using quakus, build failed when building the container.
From https://github.com/projectnessie/nessie/runs/1475113588?check_suite_focus=true:

Error:  Failed to execute goal io.quarkus:quarkus-maven-plugin:1.10.1.Final:build (default) on project nessie-quarkus: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
Error: r]: Build step io.quarkus.container.image.jib.deployment.JibProcessor#buildFromNative threw an exception: java.lang.RuntimeException: Unable to create container image
Error:  	at io.quarkus.container.image.jib.deployment.JibProcessor.containerize(JibProcessor.java:153)
Error:  	at io.quarkus.container.image.jib.deployment.JibProcessor.buildFromNative(JibProcessor.java:132)
Error:  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Error:  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:  	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
Error:  	at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:972)
Error:  	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
Error:  	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
Error:  	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
Error:  	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
Error:  	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
Error:  	at java.base/java.lang.Thread.run(Thread.java:834)
Error:  	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Error:  Caused by: java.util.concurrent.ExecutionException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Instant` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: java.util.ArrayList[0]->com.google.cloud.tools.jib.cache.LayerEntriesSelector$LayerEntryTemplate["sourceModificationTime"])
Error:  	at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:564)
Error:  	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:525)
Error:  	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:88)
Error:  	at com.google.cloud.tools.jib.builder.steps.StepsRunner.realizeFutures(StepsRunner.java:94)
Error:  	at com.google.cloud.tools.jib.builder.steps.StepsRunner.lambda$buildImage$8(StepsRunner.java:346)
Error:  	at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
Error:  	at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:69)
Error:  	at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
Error:  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
Error:  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
Error:  	at java.base/java.lang.Thread.run(Thread.java:834)
Error:  Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Instant` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: java.util.ArrayList[0]->com.google.cloud.tools.jib.cache.LayerEntriesSelector$LayerEntryTemplate["sourceModificationTime"])
Error:  	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
Error:  	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
Error:  	at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
Error:  	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
Error:  	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
Error:  	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
Error:  	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
Error:  	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
Error:  	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
Error:  	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
Error:  	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
Error:  	at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4485)
Error:  	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3699)
Error:  	at com.google.cloud.tools.jib.json.JsonTemplateMapper.writeTo(JsonTemplateMapper.java:187)
Error:  	at com.google.cloud.tools.jib.json.JsonTemplateMapper.writeTo(JsonTemplateMapper.java:173)
Error:  	at com.google.cloud.tools.jib.hash.Digests.lambda$computeJsonDigest$0(Digests.java:44)
Error:  	at com.google.cloud.tools.jib.hash.Digests.computeDigest(Digests.java:102)
Error:  	at com.google.cloud.tools.jib.hash.Digests.computeJsonDigest(Digests.java:45)
Error:  	at com.google.cloud.tools.jib.cache.LayerEntriesSelector.generateSelector(LayerEntriesSelector.java:169)
Error:  	at com.google.cloud.tools.jib.cache.Cache.retrieve(Cache.java:182)
Error:  	at com.google.cloud.tools.jib.builder.steps.BuildAndCacheApplicationLayerStep.call(BuildAndCacheApplicationLayerStep.java:102)
Error:  	at com.google.cloud.tools.jib.builder.steps.BuildAndCacheApplicationLayerStep.call(BuildAndCacheApplicationLayerStep.java:38)
Error:  	... 6 more

This seems to also impact quarkus itself in #13570:

[ERROR] Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.Instant` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: java.util.ArrayList[0]->com.google.cloud.tools.jib.cache.LayerEntriesSelector$LayerEntryTemplate["sourceModificationTime"])
Error: [ERROR] 	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77)
Error: [ERROR] 	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1276)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:35)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:728)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4485)
Error: [ERROR] 	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:3699)
Error: [ERROR] 	at com.google.cloud.tools.jib.json.JsonTemplateMapper.writeTo(JsonTemplateMapper.java:187)

Originally posted by @gsmet in #13570 (comment)

Expected behavior
The build should have succeeded and docker image created

Actual behavior
build fails during image creation

To Reproduce

Link to a small reproducer (preferably a Maven project if the issue is not Gradle-specific).

Or attach an archive containing the reproducer to the issue.

Steps to reproduce the behavior:

  1. Create a small maven project with quarkus quarkus-container-image-jib extension
  2. Build project with quarkus.container-image.build property set to true

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin Laurents-MBP.local 18.7.0 Darwin Kernel Version 18.7.0: Mon Aug 31 20:53:32 PDT 2020; root:xnu-4903.278.44~1/RELEASE_X86_64 x86_64 (can reproduce on Linux too)
  • Output of java -version:
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.10.1
  • Build tool (ie. output of mvnw --version or gradlew --version):

Additional context
The visible issue seems to be caused by Jib project not importing the Jackson jsr310 module which is now "required" by Jackson 2.12. But there might be a separate issue regarding Quarkus as it seems that build extensions are directly impacted by changes in project dependencies, whereas Maven plugins usually have their own dependency management.

@laurentgo laurentgo added the kind/bug Something isn't working label Dec 2, 2020
@ghost ghost added the area/container-image label Dec 2, 2020
@ghost
Copy link

ghost commented Dec 2, 2020

/cc @geoand

@gsmet
Copy link
Member

gsmet commented Dec 2, 2020

Could you add the quarkus-jackson extension to your project if not already there?

I suspect one of the reasons it's failing is because the Jib extension doesn't depend on quarkus-jackson.

@gsmet
Copy link
Member

gsmet commented Dec 2, 2020

It's not enough.

Looks like we will need to customize the ObjectMapper used by Jib to register the appropriate module. But really, it should be Jib doing that.

@geoand
Copy link
Contributor

geoand commented Dec 2, 2020

Looks like we will need to customize the ObjectMapper used by Jib to register the appropriate module. But really, it should be Jib doing that.

Pffff... That sucks really...

@gsmet
Copy link
Member

gsmet commented Dec 2, 2020

It should probably be reported to the Jib project. They will probably figure it out when upgrading Jackson.

What I don't understand though is that the JSR 310 extension has a service file pointing to the module so I would have expected Jackson to register it automatically?

@geoand
Copy link
Contributor

geoand commented Dec 2, 2020

It should probably be reported to the Jib project. They will probably figure it out when upgrading Jackson.

Great idea! @laurentgo would you like to do that?

What I don't understand though is that the JSR 310 extension has a service file pointing to the module so I would have expected Jackson to register it automatically?

IIRC, in Jackson you need to call a method in order for it to find modules, I don't think it does it automatically.

@gsmet
Copy link
Member

gsmet commented Dec 2, 2020

Yeah, I don't see why the service files, then :).

But I can live with this mystery :).

@laurentgo
Copy link
Author

Yeah, I don't see why the service files, then :).

But I can live with this mystery :).

There's no automatic registration of module by default (probably for backward compatibility with existing code registering modules manually?), but if desired, one can use ObjectMapper#findAndRegisterModules.

@laurentgo
Copy link
Author

It should probably be reported to the Jib project. They will probably figure it out when upgrading Jackson.

Great idea! @laurentgo would you like to do that?

That's my plan, but the reason why I opened this bug in the first place was to understand why changing jackson version of my project would impact generating the docker image, and if there's something to be done in quarkus about it.

@geoand
Copy link
Contributor

geoand commented Dec 2, 2020

We don't deal with the ObjectMapper that Jib uses at all. We probably could if we wanted to, but I would prefer not to unless it's absolutely necessary.

@laurentgo
Copy link
Author

I was not thinking of changing ObjectMapper but more on how Quarkus Maven plugin manages dependencies for extensions maybe?

@geoand
Copy link
Contributor

geoand commented Dec 2, 2020

Most likely your update to Jackson breaks what Jib expects for Jackson.

@laurentgo
Copy link
Author

But is it expected that a code dependency update breaks a build/tool dependency? For regular maven project, it would be a bug if changing a code dependency would break the jar plugin for example...

@laurentgo
Copy link
Author

fyi proposed patch for Jib: GoogleContainerTools/jib#2908

@geoand
Copy link
Contributor

geoand commented Feb 23, 2022

Closing as GoogleContainerTools/jib#2908 has been merged

@geoand geoand closed this as completed Feb 23, 2022
@geoand geoand added the triage/out-of-date This issue/PR is no longer valid or relevant label Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/container-image kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant
Projects
None yet
Development

No branches or pull requests

3 participants