I have a jhipster-generated Spring Boot + mongo project that deploys locally with success, but deploying to Heroku with the ObjectRocket add-on is failing with this error:
[org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception;
nested exception is org.springframework.dao.DataAccessResourceFailureException: Timed out after 30000 ms while waiting for a server that matches
com.mongodb.client.internal.MongoClientDelegate$1@4339e0de. Client view of cluster state is {type=REPLICA_SET, servers=[];
nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@4339e0de.
Client view of cluster state is {type=REPLICA_SET, servers=[]
I believe that my config vars with my MONGODB_URI
variable are correct because in a shell, I have connected to my mongo database with the same connection string from my config vars with success. This connection string, stored in MONGODB_URI
, has the form mongodb://<USERNAME>:<PASSWORD@<host1>:<port1>,<host2>:<port2>,<host3>:<port3>/<DATABASE_NAME>?replicaSet=<replicaSetID>
. This also means I have already set up my mongodb dbname, user, and password on the ObjectRocket side.
My procfile has the line --spring.data.mongodb.database=$(echo "$MONGODB_URI" | sed "s/^.*:[0-9]*\///g")
referencing MONGODB_URI
. My application-prod.yml
config file has the entry:
spring:
data:
mongodb:
uri: ${MONGODB_URI}?authMode=scram-sha1
Yet I am not succeeding with deployment because of the failed connection to my mongo database instance. Any help would be appreciated.
The error with more context from the stacktrace at this pastebin paste: https://pastebin.com/wNd3TxUL