Comments (4)
This is quite similar to #38514 which the underlying cause being the same non-enumerable property source that comes from JNDI being available. You can work around the problem by adding a spring.properties
file to src/main/resources
that contains spring.jndi.ignore=true
.
The failure's occurring because DruidDataSource
isn't entirely compatible with configuration property binding.
When all property sources are enumerable, binding can be optimised to only try to bind properties that are present in the environment. For example, if there are no spring.datasource.log.connection.*
properties in the environment, the binder will never need to call getConnection()
on the DruidDataSource
.
When there's a non-enumerable property source in the environment, the binder does not know all of the properties that are available so it has to try to bind everything. As part of trying to bind everything, the binder's calling getConnection()
so that it can then introspect its result for setter methods and determine which properties need to be bound to it. This call fails as it's happening before the URL had been set. Even if the URL had been set, the call would still be unwanted as it would leak a connection.
Hopefully the workaround above is enough to get you past the problem. I'll leave this open for now as I'm not sure what, if anything, we can do to address it. One option would be to provide a way to indicate properties that should be ignored when binding to a third-party class. Another would be for you to bind properties to a safe class of your own and then use Boot's PropertyMapper
to apply those to the DruidDataSource
instance. Lastly, you could explore binding properties to Boot's DataSourceProperties
class and then building the DataSource
from those properties:
properties.initializeDataSourceBuilder().type(DruidDataSource.class).build();
from spring-boot.
I know it's risky, but can we ignore JndiPropertySource
by default since it's vulnerable and not much useful in practice?
from spring-boot.
I requested Spring Framework team to disable JndiPropertySource
by default. see spring-projects/spring-framework#18598 (comment)
from spring-boot.
We've opened #39932 to deal with the Jetty JNDI issue. Once that has been done this issue is effectively a duplicate of #34616
from spring-boot.
Related Issues (20)
- Document SBOM Support
- Docker Compose support doesn't work with Docker Compose 2.25.0 HOT 12
- Document CDS support HOT 4
- Implement strategy to redirect older documentation links to the new site
- Shorten fragment links HOT 1
- Review and split up large documentation pages
- Replace links to code with links to javadoc HOT 1
- Develop 'apiref' macro for use in Antora
- Provide configuration properties documentation
- Move tools javadoc to a different module HOT 2
- Migrate to always use xrefs in documentation HOT 1
- Use code-include for Gradle Groovy/Kotlin in documention
- Move older documentation to new location
- Create docs-build branch HOT 1
- resolveMainClassName fails when building with Gradle using a Java 22 toolchain HOT 5
- Configuration properties changelog generator misses items that are removed without prior deprecation
- spring.datasource.dbcp2.username and spring.datasource.dbcp2.password are incorrectly marked as deprecated HOT 6
- Make configuration properties for Pulsar failover more concise
- DateTime parsing slow in Spring Boot HOT 4
- Spring Boot Docker Compose reports exit code 0 on application run failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.