Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

GraalVM for Apple Silicon: management.metrics.distribution error #1538

Closed
mraible opened this issue Mar 22, 2022 · 11 comments · Fixed by #1565
Closed

GraalVM for Apple Silicon: management.metrics.distribution error #1538

mraible opened this issue Mar 22, 2022 · 11 comments · Fixed by #1565
Assignees
Labels
type: compatibility Native image compatibility issue
Milestone

Comments

@mraible
Copy link

mraible commented Mar 22, 2022

I was motivated to try out GraalVM for Apple Silicon after it was announced today.

How I installed it:

  1. Downloaded and extracted graalvm-ce-java11-darwin-aarch64-dev.tar.gz

  2. Installed it as an SDKMAN candidate:

     mv ~/Downloads/graalvm-ce-java17-22.1.0-dev/Contents/Home ~/.sdkman/candidates/java/22.1.0.dev.r17-grl
     sudo xattr -r -d com.apple.quarantine ~/.sdkman/candidates/java/22.1.0.dev.r17-grl
    
  3. Set SDKMAN to use it: sdk default java 22.1.0.dev.r17-grl

I used my recent example with JHipster on my M1 and ran:

./mvnw package -Pnative,prod -DskipTests

I was pleased to see it finished in 2m (vs 3m 10s on Intel). Unfortunately, it doesn't work if I try to start it:

$ ./target/native-executable
...
***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'management.metrics.distribution' to org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties$Distribution:

    Reason: java.lang.ClassNotFoundException: org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary

Action:

Update your application's configuration

If I add org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary.class to my type hints, it works.

--- a/src/main/java/com/auth0/flickr2/Flickr2App.java
+++ b/src/main/java/com/auth0/flickr2/Flickr2App.java
@@ -33,6 +33,7 @@ import tech.jhipster.config.JHipsterConstants;
         com.drew.metadata.exif.ExifThumbnailDirectory.class,
         com.drew.metadata.exif.makernotes.AppleMakernoteDirectory.class,
         com.drew.metadata.exif.GpsDirectory.class,
+        org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary.class
     }
 )
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 22, 2022
@sdeleuze sdeleuze added type: compatibility Native image compatibility issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 25, 2022
@sdeleuze sdeleuze added this to the 0.11.4 milestone Mar 25, 2022
@sdeleuze
Copy link
Contributor

We had the array variant, so I added the regular class one, please check with snapshots it works for you.

@mraible
Copy link
Author

mraible commented Mar 25, 2022

I tried 0.11.4-SNAPSHOT in this PR. The error still happens:

Failed to bind properties under 'management.metrics.distribution' to org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties$Distribution:

    Reason: java.lang.ClassNotFoundException: org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary

Steps to reproduce:

git clone -b graalvm-on-m1 https://github.com/oktadev/auth0-full-stack-java-example.git
cd auth0-full-stack-java-example
./mvnw package -Pprod,native -DskipTests
./target/native-executable

@sdeleuze sdeleuze reopened this Mar 28, 2022
@sdeleuze
Copy link
Contributor

I can't reproduce since I am on Linux. Could you please give me the output of ./target/native-executable --debug in order to allow to show the stacktrace?

@mraible
Copy link
Author

mraible commented Mar 28, 2022

I tried with release 22.2.0.dev.r17 from a few days ago.

  1. I downloaded and expanded graalvm-ce-java11-darwin-aarch64-dev.tar.gz.

  2. I moved it to SDKMAN's directory.

     mv ~/Downloads/graalvm-ce-java11-22.2.0-dev/Contents/Home ~/.sdkman/candidates/java/22.2.0.dev.r17-grl
     sudo xattr -r -d com.apple.quarantine ~/.sdkman/candidates/java/22.2.0.dev.r17-grl
    
  3. I ran sdk default java 22.2.0.dev.r17-grl to set it as my default image.

It appears that gu install native-image is now automated. That's pretty slick!

The error still happens. The output from ./target/native-executable --debug is as follows:

➜  auth0-full-stack-java-example git:(graalvm-on-m1) ./target/native-executable --debug

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster 🤓  :: Running Spring Boot 2.6.3 ::
:: https://www.jhipster.tech ::

2022-03-28 16:52:12.087  INFO 77943 --- [           main] com.auth0.flickr2.Flickr2App             : Starting Flickr2App using Java 11.0.15 on mando.local with PID 77943 (/Users/mraible/dev/auth0-full-stack-java-example/target/native-executable started by mraible in /Users/mraible/dev/auth0-full-stack-java-example)
2022-03-28 16:52:12.087  INFO 77943 --- [           main] com.auth0.flickr2.Flickr2App             : The following profiles are active: prod
2022-03-28 16:52:12.087 DEBUG 77943 --- [           main] w.s.c.ServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext@7320263d
2022-03-28 16:52:12.114 DEBUG 77943 --- [           main] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: /Users/mraible/dev/auth0-full-stack-java-example/target/native-executable
2022-03-28 16:52:12.114 DEBUG 77943 --- [           main] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: /Users/mraible/dev/auth0-full-stack-java-example/target/native-executable
2022-03-28 16:52:12.114 DEBUG 77943 --- [           main] .s.b.w.e.t.TomcatServletWebServerFactory : Document root: /Users/mraible/dev/auth0-full-stack-java-example/src/main/webapp
2022-03-28 16:52:12.115  INFO 77943 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-03-28 16:52:12.117 DEBUG 77943 --- [           main] w.s.c.ServletWebServerApplicationContext : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2022-03-28 16:52:12.117  INFO 77943 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 30 ms
2022-03-28 16:52:12.119 ERROR 77943 --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter': Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMeterRegistry': Initialization of bean failed; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'management.metrics-org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties': Could not bind properties to 'MetricsProperties' : prefix=management.metrics, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'management.metrics.distribution' to org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties$Distribution
2022-03-28 16:52:12.120  WARN 77943 --- [           main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2022-03-28 16:52:12.121 DEBUG 77943 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : Application failed to start due to an exception

org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'management.metrics.distribution' to org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties$Distribution
	at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:384) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:344) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:469) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder$$Lambda$a7699755bf3e6a042898e20def2fb0e119903bb0.bindProperty(Unknown Source) ~[na:na]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:95) ~[na:na]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:83) ~[na:na]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:59) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:473) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder$$Lambda$782cafb0c08942dac3f528803724cab8574ecfbc.get(Unknown Source) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:587) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:573) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder$Context.access$300(Binder.java:534) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:471) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:411) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:340) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:329) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:259) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:246) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:95) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:89) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:78) ~[native-executable:2.6.3]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$2c40051508af481f3e2b011afbd5800cdeae9fd3.getObject(Unknown Source) ~[na:na]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory$DependencyObjectProvider.getObject(DefaultListableBeanFactory.java:1988) ~[na:na]
	at org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryPostProcessor.getConfigurer(MeterRegistryPostProcessor.java:74) ~[native-executable:2.6.3]
	at org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryPostProcessor.postProcessAfterInitialization(MeterRegistryPostProcessor.java:64) ~[native-executable:2.6.3]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$2c40051508af481f3e2b011afbd5800cdeae9fd3.getObject(Unknown Source) ~[na:na]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[native-executable:5.3.15]
	at org.springframework.aot.beans.factory.InjectedConstructionResolver.lambda$resolve$0(InjectedConstructionResolver.java:83) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedConstructionResolver$$Lambda$2e00153b7e05d644436a095c0da3c269e26a6a7d.get(Unknown Source) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedConstructionResolver.resolveDependency(InjectedConstructionResolver.java:97) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedConstructionResolver.resolve(InjectedConstructionResolver.java:83) ~[na:na]
	at org.springframework.aot.beans.factory.InjectedElementResolver.resolve(InjectedElementResolver.java:35) ~[native-executable:0.11.4-SNAPSHOT]
	at org.springframework.aot.beans.factory.InjectedElementResolver.create(InjectedElementResolver.java:66) ~[native-executable:0.11.4-SNAPSHOT]
	at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$BeanInstanceContext.create(BeanDefinitionRegistrar.java:211) ~[na:na]
	at org.springframework.aot.ContextBootstrapInitializer.lambda$initialize$364(ContextBootstrapInitializer.java:1219) ~[na:na]
	at org.springframework.aot.ContextBootstrapInitializer$$Lambda$32e8f018c4da16a54d9d664ff8371e6707d97931.applyWithException(Unknown Source) ~[na:na]
	at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$ThrowableFunction.apply(BeanDefinitionRegistrar.java:294) ~[native-executable:0.11.4-SNAPSHOT]
	at org.springframework.aot.beans.factory.BeanDefinitionRegistrar.lambda$instanceSupplier$0(BeanDefinitionRegistrar.java:115) ~[na:na]
	at org.springframework.aot.beans.factory.BeanDefinitionRegistrar$$Lambda$a3df89430a3ba7d397d0053371a7f0bbfc99ecb2.get(Unknown Source) ~[na:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1249) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1191) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$2c40051508af481f3e2b011afbd5800cdeae9fd3.getObject(Unknown Source) ~[na:na]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[native-executable:5.3.15]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[native-executable:5.3.15]
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:212) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:203) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addServletContextInitializerBeans(ServletContextInitializerBeans.java:97) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:86) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:260) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:234) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext$$Lambda$86914da8b359387109eb85694b90e93c340c80f7.onStartup(Unknown Source) ~[na:na]
	at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:53) ~[na:na]
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219) ~[native-executable:9.0.56]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[native-executable:9.0.56]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[na:na]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[na:na]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[native-executable:na]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[na:na]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[native-executable:na]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[native-executable:9.0.56]
	at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835) ~[na:na]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[native-executable:9.0.56]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396) ~[na:na]
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386) ~[na:na]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[native-executable:na]
	at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[na:na]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140) ~[native-executable:na]
	at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919) ~[native-executable:9.0.56]
	at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263) ~[na:na]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[native-executable:9.0.56]
	at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432) ~[na:na]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[native-executable:9.0.56]
	at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927) ~[na:na]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[native-executable:9.0.56]
	at org.apache.catalina.startup.Tomcat.start(Tomcat.java:486) ~[na:na]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ~[na:na]
	at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[na:na]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:478) ~[native-executable:2.6.3]
	at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:182) ~[native-executable:2.6.3]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:160) ~[native-executable:2.6.3]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[native-executable:5.3.15]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[native-executable:2.6.3]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[native-executable:2.6.3]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[native-executable:2.6.3]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[native-executable:2.6.3]
	at com.auth0.flickr2.Flickr2App.main(Flickr2App.java:87) ~[native-executable:na]
Caused by: java.lang.TypeNotPresentException: Type org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary not present
	at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[na:na]
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[na:na]
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:na]
	at sun.reflect.generics.visitor.Reifier.visitArrayTypeSignature(Reifier.java:159) ~[na:na]
	at sun.reflect.generics.tree.ArrayTypeSignature.accept(ArrayTypeSignature.java:42) ~[na:na]
	at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[na:na]
	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[na:na]
	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[na:na]
	at sun.reflect.generics.repository.MethodRepository.computeReturnType(MethodRepository.java:75) ~[na:na]
	at sun.reflect.generics.repository.MethodRepository.getReturnType(MethodRepository.java:66) ~[na:na]
	at java.lang.reflect.Method.getGenericReturnType(Method.java:292) ~[native-executable:na]
	at org.springframework.core.MethodParameter.getGenericParameterType(MethodParameter.java:510) ~[native-executable:5.3.15]
	at org.springframework.core.SerializableTypeWrapper$MethodParameterTypeProvider.getType(SerializableTypeWrapper.java:291) ~[na:na]
	at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:107) ~[na:na]
	at org.springframework.core.ResolvableType.forType(ResolvableType.java:1421) ~[native-executable:5.3.15]
	at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1310) ~[native-executable:5.3.15]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder$BeanProperty.getType(JavaBeanBinder.java:330) ~[na:na]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:92) ~[na:na]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:83) ~[na:na]
	at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:59) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:473) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder$$Lambda$782cafb0c08942dac3f528803724cab8574ecfbc.get(Unknown Source) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:587) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:573) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder$Context.access$300(Binder.java:534) ~[na:na]
	at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:471) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:411) ~[native-executable:2.6.3]
	at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:340) ~[native-executable:2.6.3]
	... 109 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary
	at java.lang.Class.forName(DynamicHub.java:1081) ~[native-executable:na]
	at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114) ~[na:na]
	... 136 common frames omitted

2022-03-28 16:52:12.122 ERROR 77943 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'management.metrics.distribution' to org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties$Distribution:

    Reason: java.lang.ClassNotFoundException: org.springframework.boot.actuate.autoconfigure.metrics.ServiceLevelObjectiveBoundary

Action:

Update your application's configuration

@mhalbritter
Copy link
Contributor

I managed to build a minimal reproducer, with which I'll analyze what's happening here.

demo.zip fails when compiling and then running with https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/22.2.0-dev-20220330_2302

@sdeleuze
Copy link
Contributor

Great, likely worth to refine my initial try for a fix (bf12d54) with a better trigger.

@mhalbritter
Copy link
Contributor

mhalbritter commented Mar 31, 2022

This is not MacOS specific. I can reproduce the problem on Linux aarch64 with a GraalVM built from 22.1 source, too.

It works with

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment GraalVM CE 22.0.0.2 (build 17.0.2+8-jvmci-22.0-b05)
OpenJDK 64-Bit Server VM GraalVM CE 22.0.0.2 (build 17.0.2+8-jvmci-22.0-b05, mixed mode, sharing)

so this looks like a 22.1 regression.

mhalbritter added a commit to mhalbritter/spring-native that referenced this issue Mar 31, 2022
This triggers only if MetricsAutoConfiguration is active.

Closes spring-atticgh-1538
@mhalbritter
Copy link
Contributor

@mraible I have a PR which fixes the problem. I can build your jhipster-native sample and it now runs until it hits

Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:9080/auth/realms/jhipster/.well-known/openid-configuration": Connection refused; nested exception is java.net.ConnectException: Connection refused

which i guess is no native-image problem. Can you give the PR a try?

@mraible
Copy link
Author

mraible commented Mar 31, 2022

@mhalbritter This happens because Keycloak is not started. You can start it with:

docker-compose -f src/main/docker/keycloak.yml up -d

I'll test your PR and report back.

@mraible
Copy link
Author

mraible commented Mar 31, 2022

I should mention that Keycloak has its own issues because you have to build it on an M1 in order for it to work. I used these instructions with 16.0.1 to get things working.

@mhalbritter I tested your PR and it does solve the problem. Nice work!

@mhalbritter
Copy link
Contributor

Nice, thanks for the update!

sdeleuze pushed a commit that referenced this issue Apr 1, 2022
This triggers only if MetricsAutoConfiguration is active.

Closes gh-1538
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: compatibility Native image compatibility issue
Development

Successfully merging a pull request may close this issue.

4 participants