1

I generated my first microservices with JHipster. For this I used the jdl file listed below. Now I want to start the services locally.

For this I execute the following commands:

docker-compose -f myApp\src\main\docker\jhipster-registry.yml up -d

cd myApp

mvnw

It seems that I am not considering something basic. Because I get the following error message:

:: JHipster ?  :: Running Spring Boot 2.5.5 ::
:: https://www.jhipster.tech ::

2021-10-25 18:05:34.817  INFO 13520 --- [           main] com.myapp.MyApp                          : No active profile set, falling back to default profiles: dev,api-docs
2021-10-25 18:05:38.855 DEBUG 13520 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:38.904 DEBUG 13520 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:38.951 DEBUG 13520 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:38.994 DEBUG 13520 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:39.024 DEBUG 13520 --- [           main] i.g.r.utils.RxJava2OnClasspathCondition  : RxJava2 related Aspect extensions are not activated, because RxJava2 is not on the classpath.
2021-10-25 18:05:41.654  WARN 13520 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration' defined in file [C:\Users\kleinoth\IdeaProjects\JHipster\microservicesTest\myApp\target\classes\com\myapp\config\SecurityConfiguration.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in file [C:\Users\kleinoth\IdeaProjects\JHipster\microservicesTest\myApp\target\classes\com\myapp\security\DomainUserDetailsService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.myapp.repository.UserRepository defined in @EnableR2dbcRepositories declared on DatabaseConfiguration: Cannot create inner bean '(inner bean)#7b7cf475' of type [org.springframework.data.repository.core.support.RepositoryFragmentsFactoryBean] while setting bean property 'repositoryFragments'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#7b7cf475': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepositoryInternalImplFragment': Cannot resolve reference to bean 'userRepositoryInternalImpl' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRepositoryInternalImpl' defined in file [C:\Users\kleinoth\IdeaProjects\JHipster\microservicesTest\myApp\target\classes\com\myapp\repository\UserRepositoryInternalImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'r2dbcDatabaseClient' defined in class path resource [org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryDependentConfiguration.class]: Unsatisfied dependency expressed through method 'r2dbcDatabaseClient' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'connectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/r2dbc/ConnectionFactoryConfigurations$Pool.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.r2dbc.pool.ConnectionPool]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.IllegalStateException: Unable to create a ConnectionFactory for 'ConnectionFactoryOptions{options={driver=h2, protocol=file, database=./target/h2db/db/myapp;DB_CLOSE_DELAY=-1, host=., user=myApp}}'. Available drivers: [ postgresql, pool ]
2021-10-25 18:05:41.763 ERROR 13520 --- [           main] o.s.boot.SpringApplication               : Application run failed

It seems that the gateway application cannot connect to the H2 database. Shouldn't at least the gateway application be running? Does anyone know what I'm missing?

The JDL file:

application {
  config {
    baseName myApp,
    applicationType gateway,
    packageName com.myapp,
    serverPort 8080,
    authenticationType jwt,
    prodDatabaseType postgresql,
    clientFramework angularX
  }
  entities *
}

application {
  config {
    baseName myApp1,
    applicationType microservice,
    packageName com.myapp,
    serverPort 8081,
    authenticationType jwt,
    prodDatabaseType postgresql,
  }
  entities A, B
}

application {
  config {
    baseName myApp2,
    applicationType microservice,
    packageName com.myapp,
    serverPort 8082,
    authenticationType jwt,
    prodDatabaseType postgresql,
  }
  entities C
}

entity A {
    name String
}

entity B {
    location String
}

entity C {

}

entity D {}

relationship OneToMany {
  A to B
}

Update: It only affects the gateway application. All microservices are running and recognized in the registry.

Dependencies in the pom.xml:

<dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.r2dbc</groupId>
            <artifactId>r2dbc-h2</artifactId>
            <scope>test</scope>
        </dependency>
Kleinstein11
  • 95
  • 2
  • 9
  • Seems like you're missing the h2 jdbc driver. Could you check your pom.xml for the dependency? "Unable to create a ConnectionFactory for 'ConnectionFactoryOptions{options={driver=h2, protocol=file, database=./target/h2db/db/myapp;DB_CLOSE_DELAY=-1, host=., user=myApp}}'. Available drivers: [ postgresql, pool ]" – jussi Oct 25 '21 at 21:12
  • yes. I updated it in the question. – Kleinstein11 Oct 26 '21 at 08:49
  • Remove the scope. This should fix it. – jussi Oct 30 '21 at 12:30

0 Answers0