Skip to content

Question: Graalvm Native support - Spring boot 3.0 #2163

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

Closed
Dam14n opened this issue Nov 15, 2022 · 8 comments
Closed

Question: Graalvm Native support - Spring boot 3.0 #2163

Dam14n opened this issue Nov 15, 2022 · 8 comments
Labels

Comments

@Dam14n
Copy link

Dam14n commented Nov 15, 2022

Hi team,

First, thanks for this amazing project that you are working on!

I have been testing Spring boot 3.0 (SNAPSHOT) with Graalvm Native support and Spring Boot Admin. Running locally is working as expected but I'm having some issues when building the Docker image in native mode.

Quick question, are you planning to support graalvm configuration? like autoconfiguration for native-hints (I mean this https://docs.spring.io/spring-boot/docs/3.0.0-SNAPSHOT/reference/htmlsingle/#native-image.advanced.custom-hints) in Spring boot 3.0 or adding some reachability-metadata (if needed) in the graalvm repo.

Or is it something that we should config on our end?? thanks a lot

@erikpetzold
Copy link
Member

Hi @Dam14n

I think we don't have any native hints yet.

We have a branch for spring boot 3 support (https://github.com/codecentric/spring-boot-admin/tree/experimental/spring-boot-3-playground) and you can use our snapshot release by adding the snapshot repo: https://github.com/codecentric/spring-boot-admin#snapshot-builds

If you find something that should be added to SBA directly we would be happy if you file a Pull Request with the native hints against this branch.

Regards, Erik

@Dam14n
Copy link
Author

Dam14n commented Nov 15, 2022

Hi @erikpetzold,

Thanks for the fast reply!

I will give it a look and I will try to submit a PR this week.

Thanks!

@trcoelho
Copy link

trcoelho commented Dec 21, 2022

Hi @Dam14n , am having same trouble!

What is being displayed is:

d.c.b.a.c.r.ApplicationRegistrator : Failed to register application as Application(name=rem-authentication-service, managementUrl=http://localhost:2100/actuator, healthUrl=http://localhost:2100/actuator/health, serviceUrl=http://localhost:2100/) at spring-boot-admin ([http://localhost:2100/admin/instances]): No HttpMessageConverter for de.codecentric.boot.admin.client.registration.Application and content type "application/json""

Am guessing that might be something with org.springframework.web.client.RestTemplate when it tries to register an application into server.

That is pretty weird since it only happened when we build a native image.

Do you have any additional configuration, as well as native hints that might help?

It should be considered if SBA is part of Spring Boot 3.0.0.

Am using https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-starter-client/3.0.0-M7 SBA client version btw.

Any updates @erikpetzold ?

Thank you.

@Dam14n
Copy link
Author

Dam14n commented Jan 3, 2023

Hi @trcoelho,

I didn't work on this again since I did the question due to I have other tasks with a higher priority.

It was only a POC what I did but for replicating the same you can follow these steps:

  • Run your application with the native-image-agent:
SPRING_PROFILES_ACTIVE=dev,secure java -Dspring.aot.enabled=true \
    -agentlib:native-image-agent=config-output-dir=C:/Projects/spring-boot-admin/config/ \
    -jar build/libs/spring-boot-admin-0.0.1-SNAPSHOT.jar
  • After that some files should be generated and you have to put them all in the resources folder

image

Just in case, as it was only a POC I didn't set up all the hints but if it works with the files generated by the agent you should be able to recreate the necessary hints.

Missing tests

  • I dint try it with a k8s configuration

Considerations

  • JVM memory information was not working due to it is native now (I mean the jvm.memory.max is not present, maybe some work can be done in order to make it work)
  • Thread dump and heap dump were not working at that moment (It might be possible that there are new changes so I should test this again)

Related information to thread dump and heap dump:

I hope to have some time to work on this again next month. Thankfully due to the release of Spring boot 3 now some stuff should be easier.

@bjorntj
Copy link

bjorntj commented Jan 29, 2023

Hi.

I am having the same problem ("d.c.b.a.c.r.ApplicationRegistrator : Failed to register application as Application(name=rem-authentication-service, managementUrl=http://localhost:2100/actuator, healthUrl=http://localhost:2100/actuator/health, serviceUrl=http://localhost:2100/) at spring-boot-admin ([http://localhost:2100/admin/instances]): No HttpMessageConverter for de.codecentric.boot.admin.client.registration.Application and content type "application/json"")

Using the agent is not a solution, when I do this the build of my native image fails.

So just wondering which hint(s) are needed to make SBA work when running native?

@929541303
Copy link

929541303 commented Feb 7, 2023

Hi.
I im having another problem: could not find index template
`
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1103)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1077)
at org.thymeleaf.spring6.view.ThymeleafView.renderFragment(ThymeleafView.java:372)
at org.thymeleaf.spring6.view.ThymeleafView.render(ThymeleafView.java:192)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1414)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1158)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1097)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:973)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:705)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:814)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:223)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:110)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:110)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:110)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:441)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:367)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:295)
at de.codecentric.boot.admin.server.ui.web.servlet.HomepageForwardingFilter.doFilter(HomepageForwardingFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:185)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:158)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:119)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:400)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:859)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

`
image

erikpetzold pushed a commit that referenced this issue Mar 31, 2023
* WIP - Spring Boot Admin Server GraalVM sample

* Spring Boot Admin Server GraalVM sample

* Spring Boot Admin Server GraalVM sample

* Documented the Spring Boot Admin Server GraalVM sample (might be addressing #2271 and #2163)

* cleanup

* Added a hint to use a v17 BaseJDK GraalVM to build the sample within the docs.

* Extended docs regarding native build with separate profile.

* Added RuntimeHints

* WIP: RuntimeHints

* WIP: RuntimeHints

* Removed awt from implementation of converting hex to rgb since graal cannot cope with it right now

* Extended RuntimeHints

* Extended RuntimeHints

* Extended documentation

* OCI image building + documentation

* cleanup dependencies

* Corrected GraalVM version

* Added info endpoint configuration

* Cleanup

* Added build-info and general cleanup

* Cleanup

* Fixed checkstyle issues

* Fixed documentation on image builder for common x86 architectures

---------

Co-authored-by: Stephan Köninger <[email protected]>
@ulischulte
Copy link
Contributor

@Dam14n,

the current snapshot (3.0.4-SNAPSHOT) now includes autoconfigurations with RuntimeHints for SBA client and server running as Spring Boot 3 native applications. You can find a running GraalVM SBA server sample (+ self registration as a client) right here: https://github.com/codecentric/spring-boot-admin/tree/master/spring-boot-admin-samples/spring-boot-admin-sample-servlet-graalvm
This should solve your problem. If you encounter any other issues regarding GraalVM native support, feel free to open a new issue.

Regards,
Uli

@929541303
Copy link

929541303 commented May 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants