Hello, I'm trying to compile a spring boot 3.2.2 application using maven (mvn clean -Pnative native:compile) and it fails with the following error message:
Exception in thread "main" java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:470)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader$TrackedConditionEvaluator.shouldSkip(ConfigurationClassBeanDefinitionReader.java:459)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:131)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:428)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:289)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:349)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788)
at org.springframework.context.support.GenericApplicationContext.refreshForAotProcessing(GenericApplicationContext.java:415)
at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:54)
at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80)
Caused by: java.lang.IllegalArgumentException: Circular placeholder reference 'spring.datasource.url' in property definitions
The application.yaml file has this configuration:
liquibase:
change-log: classpath:db/changelog/controller.yaml
url: ${spring.datasource.url}
user: ${liquibase.datasource.username}
password: ${liquibase.datasource.password}
enabled: ${LIQUIBASE_ENABLED:true}
datasource:
url: ${spring.datasource.url}
username: ${spring.datasource.username}
password: ${spring.datasource.password}
driver-class-name: oracle.jdbc.OracleDriver
type: oracle.ucp.jdbc.PoolDataSource
oracleucp:
connection-factory-class-name: oracle.jdbc.pool.OracleDataSource
connection-pool-name: Customer32ConnectionPool
initial-pool-size: 15
min-pool-size: 10
max-pool-size: 30
Where the liquibase.url is using the same env var as datasource.url. If I change the liquibase.url value to something else the compilation succeeds. Is this expected, is there a workaround besides adding another environment variable? Attached is a sample application.
I'm using the following Java version:
java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment Oracle GraalVM 17.0.10+11.1 (build 17.0.10+11-LTS-jvmci-23.0-b27)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 17.0.10+11.1 (build 17.0.10+11-LTS-jvmci-23.0-b27, mixed mode, sharing)
I spoke with the GraalVM dev team and they told me the following:
correct me if I am wrong but this build has never reached the native-image builder. It seems to fail in java in the following task: org.springframework.boot:spring-boot-maven-plugin:3.2.2:process-aot. If this is the case, it would be the best to report this ticket to the Spring Boot issue tracker
Thanks Andy
Comment From: wilkinsona
The problem's in your YAML file where spring.datasource.url has been set to ${spring.datasource.url}:
spring:
application:
name: customer32
liquibase:
change-log: classpath:db/changelog/controller.yaml
url: ${spring.datasource.url}
user: ${liquibase.datasource.username}
password: ${liquibase.datasource.password}
enabled: ${LIQUIBASE_ENABLED:true}
datasource:
url: ${spring.datasource.url}