Sanbrien
Sanbrien

Reputation: 1

My jHipster microservice set up won't run

I've been trying out jHipster for the past few days and somehow I can't get a good application up-and-running in a dev environment. Individual components work but making it all work together is a nightmare.

The repositories I've created can be found here.

I'm lost and I don't know how to proceed. What I want is to create an API Gateway project + several microservices apps as separate projects in GitLab. Then I would like to run the app(s) locally to see if it works (I'm still learning) and if I can indeed access the API.

Nowhere in the API is documented how I can generate a valid JWT token to run tests against the API with curl or a REST client.

Some help is greatly appreciated here!

Steps to reproduce

  1. I've used JDL Studio to create an application configuration. This configuration is stored in Git as blueImpactEngineApp.jh
  2. Once I got the config, I used the command jhipster import-jdl blueImpactEngineApp.jh to generate the projects.
  3. Then I created a docker-compose file with jhipster docker-compose.
  4. Lastly, based on a tip from an online resource, I created a parent pom.xml in the deployments project with the API Gateway and the microservice app as sub-modules.
  5. With that parent pom.xml, I then created Docker images with the command mvn -Pdev com.google.cloud.tools:jib-maven-plugin:dockerBuild -Djib-maven-plugin.architecture=arm64. I had to deliberately add the -Pdev flag to ensure it uses the dev profile.
  6. Before running docker-compose, I made a few changes to the generated docker-compose file in a docker-compose-dev.yml file. I modified it to use h2Disk as the database and use a fixed database from that I stored in the project. I also added a mount point to mount the available database into the docker container.
  7. Once ready, I tried to run the application with docker-compose -f docker-compose/docker-compose-dev.yml up. This starts all the services correctly but the API Gateway is lacking a UI.
  8. Consul runs fine and I can indeed see both the api gateway as well as the microservice app registered.
  9. Even without the UI, I tried to access the service API via http://localhost:8800/services/project/api/projects. This returns a 401 so that seems to work. But I have no clue on how to get a valid JWT token to test the API.
  10. Then I tried to start the API Gateway directly from the project with mvnw but that fails to start since it wants to have the postgresql driver, even though it started the dev profile (I've selected Postgres as prod db and h2Disk as dev db).

Expected behavior

I would expect jHipster to provide me with a working system, after following documentation and online training resources but I haven't gotten anything that works.

{
  "type" : "https://www.jhipster.tech/problem/problem-with-message",
  "title" : "Not Found",
  "status" : 404,
  "detail" : "404 NOT_FOUND \"No static resource index.html.\"",
  "instance" : "/index.html",
  "message" : "error.http.404",
  "path" : "http://localhost:8800/index.html"
}

docker-compose.yml

services:
  blueimpactengine:
    image: blueimpactengine
    environment:
      - _JAVA_OPTIONS=-Xmx512m -Xms256m
      - SPRING_PROFILES_ACTIVE=dev,api-docs
      - MANAGEMENT_PROMETHEUS_METRICS_EXPORT_ENABLED=true
      - SPRING_CLOUD_CONSUL_HOST=consul
      - SPRING_CLOUD_CONSUL_PORT=8500
    ports:
      - 8800:8800
    volumes:
      - ./h2db/dev/blueimpactengine:/target/h2db
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost:8800/management/health
      interval: 5s
      timeout: 5s
      retries: 40

  project:
    image: project
    environment:
      - _JAVA_OPTIONS=-Xmx512m -Xms256m
      - SPRING_PROFILES_ACTIVE=dev,api-docs
      - MANAGEMENT_PROMETHEUS_METRICS_EXPORT_ENABLED=true
      - SPRING_CLOUD_CONSUL_HOST=consul
      - SPRING_CLOUD_CONSUL_PORT=8500
    volumes:
      - ./h2db/dev/project:/target/h2db
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost:8801/management/health
      interval: 5s
      timeout: 5s
      retries: 40

  consul:
    image: docker.io/bitnami/consul:1.20.2
    ports:
      - 8300:8300
      - 8500:8500
      - 8600:8600
    command: consul agent -dev -ui -client 0.0.0.0 -log-level=INFO
  consul-config-loader:
    image: jhipster/consul-config-loader:v0.4.1
    volumes:
      - ./central-server-config:/config
    environment:
      - INIT_SLEEP_SECONDS=5
      - CONSUL_URL=consul
      - CONSUL_PORT=8500

Upvotes: 0

Views: 13

Answers (0)

Related Questions