0

I am working on a spring boot application with apache camel which uses applicationContext.xml to initialise the spring context. I want to convert this spring boot app to spring native image, i want to understand how would the spring ahead of time processing work in this case as the spring beans I want in the spring context must be picked from applicationContext.xml. Do I have to write custom hints so native image picks up the applicationContext.xml and includes the bean definitions from xml ? spring boot version 3, spring version 6, camel version 4 ( Milestone 3 ).

I tried :- I created the native image following the documentation https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html# The image is build successfully but when i try to run the native image it fails with error "native image Web application could not be started as there was no org.springframework.boot.web.servlet.server.ServletWebServerFactory bean defined in the context". I think this might be due to context xml not being parsed by the AOT processor. I was expecting the application to start as it does on Jit JVM.

learner
  • 11
  • 1
  • Do you have `spring-boot-autoconfigure` in your classpath? See https://central.sonatype.com/artifact/org.springframework.boot/spring-boot-autoconfigure/3.1.1/versions – Nicolas Filotto Jun 27 '23 at 10:58
  • Anyway you will need to wait for 4.0.0-RC1 that is about to be released for this https://issues.apache.org/jira/browse/CAMEL-19308 – Nicolas Filotto Jun 27 '23 at 10:59
  • @NicolasFilotto Thanks for your reply. Yes I have spring-boot-autoconfigure 3.1.0 in classpath. I guess as you suggest I will have to wait for camel 4.0.0-RC1. But I tried to run a simple native image spring boot application removing camel to load simple bean from applicationContext.xml file. This fails to create bean defined in xml file, It looks to me like beans cannot be initialised from xml and the xml is completely ignored in spring boot native image. – learner Jun 29 '23 at 10:19
  • This could help you https://github.com/spring-tips/spring-boot-3-aot#xml-configuration – Nicolas Filotto Jun 29 '23 at 12:26

0 Answers0