I created a Couchbase microservice as part of the following JDL:
application {
config {
baseName gateway,
packageName com.okta.developer.gateway,
applicationType gateway,
authenticationType oauth2,
databaseType neo4j,
devDatabaseType neo4j,
prodDatabaseType neo4j,
enableHibernateCache false,
reactive true,
searchEngine elasticsearch,
serviceDiscoveryType eureka,
testFrameworks [protractor]
}
entities Blog, Post, Tag, Product
}
application {
config {
baseName blog,
packageName com.okta.developer.blog,
applicationType microservice,
authenticationType oauth2,
databaseType couchbase,
devDatabaseType couchbase,
prodDatabaseType couchbase,
enableHibernateCache false,
reactive true,
searchEngine elasticsearch,
serverPort 8081,
serviceDiscoveryType eureka
}
entities Blog, Post, Tag
}
application {
config {
baseName store,
packageName com.okta.developer.store,
applicationType microservice,
authenticationType oauth2,
databaseType mongodb,
devDatabaseType mongodb,
prodDatabaseType mongodb,
enableHibernateCache false,
reactive true
searchEngine elasticsearch,
serverPort 8082,
serviceDiscoveryType eureka
}
entities Product
}
entity Blog {
name String required minlength(3),
handle String required minlength(2)
}
entity Post {
title String required,
content TextBlob required,
date Instant required
}
entity Tag {
name String required minlength(2)
}
entity Product {
title String required,
price BigDecimal required min(0),
image ImageBlob
}
relationship ManyToOne {
Blog{user(login)} to User,
Post{blog(name)} to Blog
}
relationship ManyToMany {
Post{tag(name)} to Tag{post}
}
paginate Post, Tag with infinite-scroll
paginate Product with pagination
microservice Product with store
microservice Blog, Post, Tag with blog
When I try to run the blog microservice, it fails:
2020-04-21 10:31:47.247 WARN 36895 --- [ restartedMain] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'blogResource' defined in file [/Users/mraible/reactive/blog/target/classes/com/okta/developer/blog/web/rest/BlogResource.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.okta.developer.blog.repository.BlogRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-04-21 10:31:47.499 ERROR 36895 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.okta.developer.blog.web.rest.BlogResource required a bean of type 'com.okta.developer.blog.repository.BlogRepository' that could not be found.
Action:
Consider defining a bean of type 'com.okta.developer.blog.repository.BlogRepository' in your configuration.
You should be able to use Couchbase in a reactive microservice.
See JDL above.
master branch as of 10:33AM MDT on Tue, 21 April, 2020
@mraible : Are you using some special branch? When I generate the project using the given JDL, I see the following in the logs. :thinking:
Found the .jhipster/Blog.json configuration file, entity can be automatically generated!
events.js:187
throw er; // Unhandled 'error' event
^
Error: The entity generator doesn't support reactive apps with databases of type neo4j at the moment
at Environment.error (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/yeoman-environment/lib/environment.js:284:40)
at EntityGenerator.error (/home/sudharaka/IdeaProjects/generator-jhipster/generators/generator-base.js:1551:18)
at EntityGenerator.validateReactiveCompatibility (/home/sudharaka/IdeaProjects/generator-jhipster/generators/entity/index.js:240:26)
at Object.<anonymous> (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:751:25)
at /home/sudharaka/IdeaProjects/generator-jhipster/node_modules/run-async/index.js:25:25
at new Promise (<anonymous>)
at /home/sudharaka/IdeaProjects/generator-jhipster/node_modules/run-async/index.js:24:19
at runLoop.add.once.once (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:752:11)
at processImmediate (internal/timers.js:439:21)
Emitted 'error' event on EntityGenerator instance at:
at Immediate.<anonymous> (/home/sudharaka/IdeaProjects/generator-jhipster/node_modules/yeoman-generator/lib/index.js:791:20)
at processImmediate (internal/timers.js:439:21)
@SudharakaP Yes, I'm using mraible:reactive-neo4j from https://github.com/jhipster/generator-jhipster/pull/11612.
I guess it might be the same problem with neo4j and elasticsearch. Can you try without elastic? Gerrit checked and all repository beans are tried to be created with the elastic repository bean. Will keep you updated if I have some news.
@mraible Just for your information it seems not to be fixed by the same workaround for elastic & neo. But nevertheless it seems like a problem with multiple spring data modules too.
Removing elasticsearch makes the service start. Trying to find a workaround.
Okay, I need some couchabse expertise. When I change e.g. BlogRepository from ReactiveCouchbaseSortingRepository to ReactiveN1qlCouchbaseRepository it also works with Elasticsearch. The custom repository is also defined as base class in DatabaseConfiguration and extends the default ReactiveCouchbaseSortingRepository so the change seems save to me, but I don't know why we have a custom repository.
EDIT: And now I see why the ReactiveN1qlCouchbaseRepository move works.
@EnableReactiveCouchbaseRepositories(
repositoryBaseClass = CustomReactiveN1qlCouchbaseRepository.class,
basePackages = "com.okta.developer.blog.repository",
includeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = ReactiveN1qlCouchbaseRepository.class))
So it looks like oversight. I can provide a PR for that. Either extending the filter or making all entity repositories extend ReactiveN1qlCouchbaseRepository which I would prefer, because we can remove the findAll method from each entity repository as it is already part of the ReactiveN1qlCouchbaseRepository base repository.