Closed DanielFran closed 1 year ago
I tried adjusting jhipster-bom/jhipster-dependencies/pom.xml
to remove the exclusions. Before:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
After:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
<version>${spring-boot.version}</version>
</dependency>
Then, I generated an app using the following .yo-rc.json
:
{
"generator-jhipster": {
"applicationType": "monolith",
"authenticationType": "jwt",
"baseName": "sampleWebfluxMongodb",
"blueprints": [],
"buildTool": "maven",
"cacheProvider": "no",
"clientFramework": "angular",
"clientPackageManager": "npm",
"clientTheme": "none",
"clientThemeVariant": "",
"creationTimestamp": 1596513172471,
"databaseType": "mongodb",
"devDatabaseType": "mongodb",
"devServerPort": 4200,
"dtoSuffix": "DTO",
"enableGradleEnterprise": false,
"enableHibernateCache": false,
"enableTranslation": true,
"entities": [],
"entitySuffix": "",
"jhiPrefix": "jhi",
"jhipsterVersion": "7.9.3",
"languages": ["en", "fr"],
"nativeLanguage": "en",
"otherModules": [],
"packageFolder": "tech/jhipster/sample",
"packageName": "tech.jhipster.sample",
"pages": [],
"prodDatabaseType": "mongodb",
"reactive": true,
"searchEngine": false,
"serverPort": "8080",
"serviceDiscoveryType": false,
"skipCheckLengthOfIdentifier": false,
"skipClient": false,
"skipFakeData": false,
"skipUserManagement": false,
"testFrameworks": ["gatling", "cypress"],
"websocket": false,
"withAdminUi": true
}
}
I removed the following from the generated pom.xml
:
<!-- Mongock doesn't support reactive yet, so this dependency is necessary. -->
<!-- See https://github.com/jhipster/generator-jhipster/pull/12536#issuecomment-696683592 for more information. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<!-- Mongo db driver was excluded from starter, adding manually. -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-reactivestreams</artifactId>
</dependency>
<!-- Mongo db driver was excluded from starter, adding manually. -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
</dependency>
And added:
<dependency>
<groupId>io.mongock</groupId>
<artifactId>mongodb-reactive-driver</artifactId>
</dependency>
Then, I start the app with mvn
and it fails to start:
2022-10-20T12:56:10.442-07:00 WARN 63429 --- [ restartedMain] onfigReactiveWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'getBuilder' defined in
class path resource [io/mongock/runner/springboot/config/MongockContext.class]: Unsatisfied dependency expressed
through method 'getBuilder' parameter 0: No qualifying bean of type 'io.mongock.driver.api.driver.ConnectionDriver'
available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2022-10-20T12:56:12.548-07:00 ERROR 63429 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
__***************************_APPLICATION FAILED TO START_***************************
__Description:__Parameter 0 of method getBuilder in io.mongock.runner.springboot.config.MongockContext
required a bean of type 'io.mongock.driver.api.driver.ConnectionDriver' that could not be found.
___Action:__Consider defining a bean of type 'io.mongock.driver.api.driver.ConnectionDriver' in your configuration._
Hi @mraible, @osantana85 was able to reproduce it and we are looking at it
Thank you @dieppa!
~Tracking it at jh lite too https://github.com/jhipster/jhipster-lite/issues/4067~ This is about SB 3 not in 2.x but looks similar/related.
@dieppa Do you have an update or issue we can track?
@mraible https://github.com/mongock/mongock/issues/583. I expect to have a a release by tonight or tomorrow. Thanks!
@mraible , as you have probably already seen in this Jhipster issue, we have released the mongock runner for springboot 3 and driver for springdata v4.
However I am looking again this ticket and I am wondering if what you need here is an upgrade in the reactive driver. Which, having build the foundation for the jdk7 modules mentioned above(springboot 3 runner and springdata 4 driver), it should be pretty straight forward.
Let me know if you need anything! 😃
I will have a look, I also think this is not related to springdata 4 and boot 3 as this is about boot 2. But the error looks the same.
I tried the steps to upgrade to Mongock 5.1.7, followed by these steps from above. I still get an error on startup:
2022-10-27T08:46:28.479+01:00 WARN 2694 --- [ restartedMain] onfigReactiveWebServerApplicationContext : Exception encountered during context
initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'getBuilder' defined in class path resource [io/mongock/runner/springboot/config/MongockContext.class]: Unsatisfied dependency expressed through method
'getBuilder' parameter 0: Error creating bean with name 'connectionDriver' defined in class path resource
[io/mongock/driver/mongodb/springdata/v4/config/SpringDataMongoV4Context.class]: Unsatisfied dependency expressed through method 'connectionDriver'
parameter 0: No qualifying bean of type 'org.springframework.data.mongodb.core.MongoTemplate' available: expected at least 1 bean which qualifies as
autowire candidate. Dependency annotations: {}
2022-10-27T08:46:30.552+01:00 ERROR 2694 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : __***************************_APPLICATION
FAILED TO START_***************************__Description:__Parameter 0 of method connectionDriver in
io.mongock.driver.mongodb.springdata.v4.config.SpringDataMongoV4ContextBase required a bean of type
'org.springframework.data.mongodb.core.MongoTemplate' that could not be found.___Action:__Consider defining a bean of type
'org.springframework.data.mongodb.core.MongoTemplate' in your configuration._
If I add the following back in, it starts!
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
Commits:
The mongock driver has the dependency for spring set to provided
so I think thats correct. Do I get it correct, this is indeed about boot 3 and not 2?
Yes, this is for Spring Boot 3.
Makes sense we don't do such an update for jh 7.x right now. Awesome, so everything looks good here?
@atomfrede I think so. We'll see what CI says.
I am keeping an eye here to see how it progresses and in what I can help with 👀
Increasing bug bounty since this wasn't easy to solve.
@mraible Can we close this from your point of view?
Yes.
@atomfrede : approved
Overview of the feature request
Mongock now supports reactive driver: https://docs.mongock.io/v5/driver/mongodb-reactive/index.html Thanks @dieppa
We can now remove the workaround created by @mishima with the update to spring-boot 2.6.x (use driver 4.2.3 instead of 4.4.x):
Motivation for or Use Case
Related issues or PR