Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive Couchbase microservice fails to start #11611

Closed
1 task done
mraible opened this issue Apr 21, 2020 · 6 comments · Fixed by #11637
Closed
1 task done

Reactive Couchbase microservice fails to start #11611

mraible opened this issue Apr 21, 2020 · 6 comments · Fixed by #11637

Comments

@mraible
Copy link
Contributor

mraible commented Apr 21, 2020

Overview of the issue

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.
Motivation for or Use Case

You should be able to use Couchbase in a reactive microservice.

Reproduce the error

See JDL above.

Related issues
Suggest a Fix
JHipster Version(s)

master branch as of 10:33AM MDT on Tue, 21 April, 2020

Browsers and Operating System
  • Checking this box is mandatory (this is just to show you read everything)
@SudharakaP
Copy link
Member

@mraible : Are you using some special branch? When I generate the project using the given JDL, I see the following in the logs. 🤔

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)

@mraible
Copy link
Contributor Author

mraible commented Apr 23, 2020

@SudharakaP Yes, I'm using mraible:reactive-neo4j from #11612.

@atomfrede
Copy link
Member

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.

@atomfrede atomfrede added the theme: reactive ⚛️ Spring WebFlux label Apr 24, 2020
@atomfrede
Copy link
Member

@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.

@atomfrede
Copy link
Member

Removing elasticsearch makes the service start. Trying to find a workaround.

@atomfrede
Copy link
Member

atomfrede commented Apr 25, 2020

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.

atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Apr 25, 2020
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Apr 25, 2020
atomfrede added a commit to atomfrede/generator-jhipster that referenced this issue Apr 26, 2020
atomfrede added a commit that referenced this issue Apr 27, 2020
* use correct couchabse reactive repository base class

closes #11611

* remove obsolete import

* Enable couchbase entities in webflux tests

* add missing commons codec dependency for couchbase

* clean build.gradle and pom.xml from doubled codec dependency

* fix delete of entities

Co-authored-by: Matt Raible <matt.raible@okta.com>
@pascalgrimaud pascalgrimaud added this to the 6.9.0 milestone May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants