sagrawal31 opened a new issue, #14381:
URL: https://github.com/apache/grails-core/issues/14381
# Thanks to @AbhishekTaparia for finding out the issue 👏🏻
## Environment
- Grails 4.0.4
- GORM 7.0.6
- GORM MongoDB 7.0.1
## Problem
We were recently trying to connect to a remote MongoDB instance (hosted on
MongoDB Atlas) and we configured the app with the following config in
`application.groovy` (shows fake credentials)-
```groovy
String mongoDBUsername = "root"
String mongoDBPassword = "67ERH@45hu12"
String mongoDBName = "myFirstDatabase"
String mongoDBHost = "example-development.garhn.mongodb.net"
grails {
mongodb {
url =
"mongodb+srv://${mongoDBUsername}:${mongoDBPassword}@${mongoDBHost}/${mongoDBName}?retryWrites"
+
"=true&w=majority"
}
}
```
When we ran the app using `./gradlew bootRun` the app started properly and a
few domain instances created properly (which we defined in `Bootstrap.groovy`).
But when we got to see in the MongoDB Atlas (both using their console and
`mongo shell`, we were not finding the collection and any document created.
After 4-5 hours of debugging, we got to know that somehow the Grails is
skipping the configuration and connecting to the local instance of MongoDB with
`test` database.
Further investigation leads us to the solution that since the password was
having `@`, it needs to be URL encoded-
```groovy
String mongoDBPassword = URLEncoder.encode("67ERH@45hu12", "UTF-8")
```
So when we changed our line as above, the app connected properly to the
remote MongoDB host.
## Actual Behaviour
The app silently ignores the error and connects to the `test` database in
local MongoDB instance.
## Expected Behaviour
The app startup should fail and correct errors should be shown.
Demo application- https://github.com/AbhishekTaparia/test-grails-mongo-issue
## Additional Info 1
After upgrading Grails to `4.0.9` to and GORM to `7.0.8`, the silent
connection to the database does not work instead the app startup freezes and
the app never bootstraps.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]