generator-jhipster: Reactive Microservices doesn't work in Docker Compose

Overview of the issue

There’s an error in the gateway on startup when using Docker Compose to run a reactive microservice architecture.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webFluxRequestHandlerProvider' defined in URL [jar:file:/app/libs/springfox-spring-webflux-3.0.0-SNAPSHOT.jar!/springfox/documentation/spring/web/plugins/WebFluxRequestHandlerProvider.class]: 
Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'webEndpointReactiveHandlerMapping' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping]: 
Factory method 'webEndpointReactiveHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'gatewayControllerEndpoint' defined in class path resource 
[org/springframework/cloud/gateway/config/GatewayAutoConfiguration$GatewayActuatorConfiguration.class]: 
Unsatisfied dependency expressed through method 'gatewayControllerEndpoint' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gatewayMetricFilter' defined in class path resource 
[org/springframework/cloud/gateway/config/GatewayMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'gatewayMetricFilter' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: 
No qualifying bean of type 'io.micrometer.core.instrument.MeterRegistry' available: expected 
single matching bean but found 2: prometheusMeterRegistry,consoleLoggingRegistry

2020-05-19 03:07:17.885 ERROR 1 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

***************************

APPLICATION FAILED TO START

Description:

Parameter 0 of method gatewayMetricFilter in org.springframework.cloud.gateway.config.GatewayMetricsAutoConfiguration required a single bean, but 2 were found:

- prometheusMeterRegistry: defined by method 'prometheusMeterRegistry' in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]

- consoleLoggingRegistry: defined by method 'consoleLoggingRegistry' in class path resource [io/github/jhipster/config/metric/JHipsterLoggingMetricsExportConfiguration.class]

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Motivation for or Use Case

I have a demo where I show how to create microservices with JHipster. I’m trying to adapt it to use reactive.

Reproduce the error
  1. Create apps by importing the following JDL:
application {
  config {
    baseName gateway,
    reactive true,
    packageName com.okta.developer.gateway,
    applicationType gateway,
    authenticationType oauth2,
    databaseType neo4j,
    devDatabaseType neo4j,
    prodDatabaseType neo4j,
    enableHibernateCache false,
    serviceDiscoveryType eureka,
    testFrameworks [protractor]
  }
  entities Blog, Post, Tag, Product
}

application {
  config {
    baseName blog,
    reactive true,
    packageName com.okta.developer.blog,
    applicationType microservice,
    authenticationType oauth2,
    databaseType couchbase,
    devDatabaseType couchbase,
    prodDatabaseType couchbase,
    enableHibernateCache false,
    serverPort 8081,
    serviceDiscoveryType eureka
  }
  entities Blog, Post, Tag
}

application {
  config {
    baseName store,
    reactive true,
    packageName com.okta.developer.store,
    applicationType microservice,
    authenticationType oauth2,
    databaseType mongodb,
    devDatabaseType mongodb,
    prodDatabaseType mongodb,
    enableHibernateCache false,
    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

deployment {
  deploymentType docker-compose
  appsFolders [gateway, blog, store]
  dockerRepositoryName "mraible"
  monitoring elk
  consoleOptions [zipkin]
}

Then, create Docker containers for each project.

./mvnw package -Pprod -DskipTests jib:dockerBuild

Finally, cd into the docker-compose directory and run docker-compose up.

JHipster Version(s)

6.9.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 47 (35 by maintainers)

Commits related to this issue

Most upvoted comments

Prometheus is enabled by default. See our documentation here https://www.jhipster.tech/monitoring/#configuring-metrics-forwarding

I have added explicitely a file for my app myapp.yml in cloud config server with the content

jhipster:
  metrics:
    logs: # Reports metrics in the logs
      enabled: false

And my application is running now, so your assumption was right, many thanks ! I just don’t understand when it is overrided ! Do you have a clue ? Do i have to add others parameters, i cannot say if i have to do the same for prometheus ? Once again many thanks for your help

@atomfrede In that case, ship it! 🚀

sounds good to me