Hi, I am trying to upgrade a spring boot web mvc 3.5.8 application to 4.0.0 (jdk 25, tomcat 11) I have the configuration of posgresql in an external tomcat context.xml file :
<Parameter name="spring.datasource.url" value="jdbc:postgresql://localhost:5432/ruchesdev" />
<Parameter name="spring.datasource.username" value="postgres" />
<Parameter name="spring.datasource.password" value="postgres" />
with spring boot 3.5.8 it works but not with spring boot 4.0.0, to make it work I am obliged to put this configuration in application.properties :
spring.datasource.url=jdbc:postgresql://localhost:5432/ruchesdev
spring.datasource.username=postgres
spring.datasource.password=postgres
The error in eclipse console is :
APPLICATION FAILED TO START Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
In fact I have the same problem with other parameters like :
<Parameter name="spring.jpa.properties.hibernate.id.db_structure_naming_strategy"
value="single" />
Thanks for your help,
Pierre
Comment From: snicoll
@pnoe that is using LDAP, isn't it? Try adding spring-boot-ldap to see if that helps?
Comment From: pnoe
No it is not using LDAP.
Complete file (and project) : https://codeberg.org/ooioo/ruches/src/branch/master/pom.xml
Comment From: snicoll
Sorry, I meant JNDI.
We can't really debug your application. Given that you claimed in another issue that things were working in 3.5.8 while they weren't, I think we'd probably need a bit more help before investigating. Can you please debug your application and check the state of the Environment. You coud inject the Environment in a bean and use a debugger to inspect its state. Check that ServletConfigPropertySource is present and its content.
Comment From: pnoe
The application is in production with spring boot 3.5.8. I'll do what you suggest, thanks again for your advices.
Comment From: pnoe
I have activated the /env management endpoint. On my spring boot 4.0.0 branch I have a PropertySource name: "servletContextInitParams" where I can find all the parameters of my context.xml file.
activeProfiles []
defaultProfiles
0 "default"
propertySources
0 { name: "servletContextInitParams", properties: {…} }
1 { name: "systemProperties", properties: {…} }
2 { name: "systemEnvironment", properties: {…} }
3 { name: "Config resource 'class path resource [application.properties]' via location 'optional:classpath:/'", properties: {…} }
4 { name: "applicationInfo", properties: {…} }
5 { name: "Management Server", properties: {…} }
Switching to my 3.5.8 branch this item is not present
activeProfiles | []
defaultProfiles |
0 | "default"
propertySources |
0 | { name: "systemProperties", properties: {…} }
1 | { name: "systemEnvironment", properties: {…} }
2 | { name: "Config resource 'class path resource [application.properties]' via location 'optional:classpath:/'", properties: {…} }
3 | { name: "applicationInfo", properties: {…} }
4 | { name: "Management Server", properties: {…} }
Comment From: snicoll
Thanks. I am assuming you meant the opposite, that servletContextInitParams isn't present in 4.0.0.
Comment From: pnoe
ho yes, sorry !
Comment From: philwebb
That property source is usually contributed by WebApplicationContextUtils.initServletPropertySources(...).