Hi @Kobe_W, thanks
Our microservice does not run, we see this in the log:
Unsatisfied dependency expressed through method 'createCustomerUseCase' parameter 0: Error creating
bean with name 'customerRepository' defined in com.company.pocmongodb.infrastructure.CustomerRepository defined in @EnableMongoRepositories declared on MongoRepositoriesRegistrar.EnableMongoRepositoriesConfiguration: Cannot resolve refere
nce to bean 'mongoTemplate' while setting bean property 'mongoOperations'
at com.mongodb.ConnectionString.<init>(ConnectionString.java:410)
at org.springframework.boot.autoconfigure.mongo.MongoPropertiesClientSettingsBuilderCustomizer.applyHostAndPort(MongoPropertiesClientSettingsBuilderCustomizer.java:62)
at org.springframework.boot.autoconfigure.mongo.MongoPropertiesClientSettingsBuilderCustomizer.customize(MongoPropertiesClientSettingsBuilderCustomizer.java:51)
at org.springframework.boot.autoconfigure.mongo.MongoClientFactorySupport.customize(MongoClientFactorySupport.java:55)
at org.springframework.boot.autoconfigure.mongo.MongoClientFactorySupport.createMongoClient(MongoClientFactorySupport.java:49)
at org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.mongo(MongoAutoConfiguration.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:139) [1 skipped]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655)
... 94 common frames omitted
If we remove tls option from connection-string, microservice deploys but it fails to connect to the database
2023-06-29 09:18:06,600 [.com:30002] DEBUG [o.m.d.cluster] Updating cluster description to {type=REPLICA_SET, servers=[{address=mongo_3.ns.company.com:30003, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.Mon
goSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}, caused by {java.io.EOFException: SSL peer shut down incorrectly}}, {address=mongo_2.ns
.company.com:30002, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}, caused by {ja
va.io.EOFException: SSL peer shut down incorrectly}}, {address=mongo_1.ns.company.com:30001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {jav
ax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}, caused by {java.io.EOFException: SSL peer shut down incorrectly}}]
2023-06-29 09:18:06,601 [.com:30001] DEBUG [o.m.d.connection] Closing connection connectionId{localValue:21}
2023-06-29 09:18:06,601 [.com:30001] DEBUG [o.m.d.cluster] Updating cluster description to {type=REPLICA_SET, servers=[{address=mongo_3.ns.company.com:30003, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.Mon
goSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}, caused by {java.io.EOFException: SSL peer shut down incorrectly}}, {address=mongo_2.ns
.company.com:30002, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}, caused by {ja
va.io.EOFException: SSL peer shut down incorrectly}}, {address=mongo_1.ns.company.com:30001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {jav
ax.net.ssl.SSLHandshakeException: Remote host terminated the handshake}, caused by {java.io.EOFException: SSL peer shut down incorrectly}}]
2023-06-29 09:18:06,602 [.com:30002] DEBUG [o.m.d.connection] Closing connection connectionId{localValue:20}
2023-06-29 09:18:06,602 [.com:30003] DEBUG [o.m.d.connection] Closing connection connectionId{localValue:24}
I’ve been re-reading this part of the Mongo documentation DNS seed list Note and checking the ConnectionString.java at 410 line. And, it looks like in order to works we have to add ssl AND tls option.