Bug Report for Spring Boot 3 Native (GraalVM 22.3) Having a simple Spring Boot application (generated on start.spring.io) building the native image (via ./gradlew nativeCompile) fails to "process field ReactiveTypeHandler#isContextPropagationPresent" due to "SLF4JServiceProvider: LogbackServiceProvider not a subtype" error which doesn't make sense since the class is a subtype of the provider. The full log message is:

...
> Task :nativeCompile
...
Field org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build time
Processing of field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent skipped due the following error : org.slf4j.spi.SLF4JServiceProvider: ch.qos.logback.classic.spi.LogbackServiceProvider not a subtype
Field org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build time
...

Also adding the io.micrometer:context-propagation doesn't change anything, still same error log.

To be clear, I'm not fully sure what are the consequence of the above, since I'm new to GraalVM. I'm filling this since the field seems to be directly in the handler. Also I'm not sure where exactly I need to post this issue. There's so many moving parts 🙂 here. Apologies in advance. Let me know if I need to provide more information. Thanks.

Comment From: akefirad

OK, it turns out the issue is related to org.springframework.aot.nativex.feature.PreComputeFieldFeature. It can be reproduced for any class like the following:

package org.springframework.demo;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.ClassUtils;

public class Foo {
    private static final Log logger = LogFactory.getLog(Foo.class);

    public static final boolean fooPresent = ClassUtils.isPresent("io.micrometer.context.ContextSnapshot", Foo.class.getClassLoader());
}

As soon as you remove logger field, the error message disappear. Interestingly having the above class, you don't see the error message for ReactiveTypeHandler#isContextPropagationPresent which I guess is due to the way service loader works maybe?

Comment From: mhalbritter

Interesting, can reproduce. @sdeleuze Any idea?

It doesn't break the build, it's "just" a warning. We should fix it nonetheless.

Comment From: sdeleuze

Yeah that's a known issue on classes with static loggers due to the fact that Logback 1.4 is using service loader so the related Logback classes are initialized at build time which is incompatible with the classloader we use in the feature. Fields impacted will be initialized at runtime. There is no known workaround.

2 potential actionable items: - Refining the message on Spring Framework side. - I can ask to GraalVM team if we have a way to only print logs for PreComputeFieldFeature when verbose native build is enable.

Any thoughts?

Comment From: akefirad

Maybe

Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent will be set at runtime (due to the following error : org.slf4j.spi.SLF4JServiceProvider: ch.qos.logback.classic.spi.LogbackServiceProvider not a subtype)

Similar enough to other logs not to cause any panic. (Happy to send the PR.)

Comment From: sdeleuze

Thanks, no need, I will handle it via https://github.com/spring-projects/spring-framework/issues/29406, you can close this issue on Boot side I think.