cloudfoundry / java-buildpack-auto-reconfiguration

Auto-reconfiguration functionality for the Java Buildpack
Apache License 2.0
219 stars 103 forks source link

spring-data-mongodb > 3.0 not compatible #78

Closed oliveti closed 3 years ago

oliveti commented 3 years ago

According to java buildpack documentation (here : https://docs.cloudfoundry.org/buildpacks/java/configuring-service-connections/spring-service-bindings.html#mongodb) auto configuration happen in that case : Auto-reconfiguration occurs if Cloud Foundry detects an org.springframework.data.document.mongodb.MongoDbFactory

But, since spring-data-mongodb 3.0 MongoDbFactory is deprecated, MongoDatabaseFactory is used instead.

In result, there is no MongoDbFactory bean to reconfigure and connection fails in java application with these kind of errors :

Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'} com.mongodb.MongoSocketOpenException: Exception opening socket

Is that a known issue ? Are there plans to support spring-data-mongodb > 3.0 ?

scottfrederick commented 3 years ago

This is related to #74. As discussed in that issue, the Spring Cloud Connectors library that is used to implement Java buildpack auto-reconfiguration is in maintenance mode. Supporting spring-data-mongodb 3.0 would require major changes to Spring Cloud Connectors, which we won't do for reasons discussed in this issue.

As a work-around until there is a resolution to #74, you can add the Java CFEnv library to your application and disable Java buildpack auto-reconfiguration as shown in the project documentation.

dmikusa commented 3 years ago

Thanks @scottfrederick +1 to that

oliveti commented 3 years ago

Hello,

Thank you a lot for your detailed answer, sounds good and we will go with include Java CFEnv as a workaround for now.