jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.4k stars 4.02k forks source link

[Reopen] The default profile is ignored when run a application generated with Jhipster 8.6.0 #26603

Open edilsonmendes opened 1 month ago

edilsonmendes commented 1 month ago
Overview of the issue

The error reported in #26333 also occurs in JHipster 8.6.0. When I try to run it using the ./mvnw command or npm run backend:debug, it does not display the default profile in the JHipster banner but the @spring.profiles.active@ placeholder. Furthermore, the application fails to create the LoggingConfigurarion bean, as it is unable to inject the value of the server.port property, as shown in the message below.

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'server.port' in value "${server.port}"

Sometimes, it runs on first time or if the profile is informed (./mvnw -P dev), however, when changing any file in the backend it fails (same error) when performing the hot reload.

Motivation for or Use Case

The application should run without error using the default profile and shows the correct profile in the banner.

Reproduce the error

-Genarate a monolith JHipster 8.6.0 -Run the application with ./mvnw or npm run backend:debug -Change any backend file to force hot reload

Related issues

26333

25979

Suggest a Fix

N/A

JHipster Version(s)

The error ocurrs in v8.6.0, v8.5.0 and v8.4.0,

JHipster configuration

WARNING! Since JHipster v8, the jhipster command will not use the locally installed generator-jhipster. If you want to execute the locally installed generator-jhipster, run: npx jhipster

    ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
    ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
    ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝

██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║ ╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗ ╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝ https://www.jhipster.tech Welcome to JHipster v8.6.0

Welcome to the JHipster Information Sub-Generator

pure-v-860@0.0.1-SNAPSHOT /home/embj/git/tjpe/pure-v8.6.0
└── generator-jhipster@8.6.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "oauth2",
    "baseName": "pureV860",
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "angular",
    "clientTestFrameworks": [],
    "clientTheme": "none",
    "creationTimestamp": 1719429321098,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [],
    "feignClient": null,
    "jhipsterVersion": "8.6.0",
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "pt-br",
    "packageName": "com.mycompany.myapp",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [],
    "serviceDiscoveryType": false,
    "skipUserManagement": true,
    "syncUserWithIdp": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": false
  }
}
Environment and Tools

openjdk version "17.0.6" 2023-01-17 OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10) OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)

git version 2.25.1

node: v20.12.2 npm: 10.5.0

Docker version 24.0.1, build 6802122

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
@ChangelogDate("20240506143746")
entity SpaceEvent {
  id UUID
  name String required
  date LocalDate required
  description TextBlob required
  photo ImageBlob required
  type SpaceEventType required
}
@ChangelogDate("20240506143747")
entity Mission {
  id UUID
  name String required
  description String
}
@ChangelogDate("20240527105557")
entity Log {
  id UUID
  description String
}
enum SpaceEventType {
  LAUNCH,
  LANDING
}

relationship OneToOne {
  SpaceEvent{mission(name)} to Mission
}
relationship OneToMany {
  Mission{log} to Log{mission}
}

dto SpaceEvent, Mission, Log with mapstruct
paginate SpaceEvent, Mission, Log with pagination
service SpaceEvent, Mission, Log with serviceClass
search SpaceEvent, Mission, Log with no
filter SpaceEvent, Mission, Log

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
mraible commented 1 month ago

I tried to recreate the issue with jhipster jdl blog-oauth2. When I first start it with ./mvnw, it has the profile set correctly.

Screenshot 2024-07-03 at 09 57 07

If I change a Java class and re-compile it, it restarts and the dev profile is still there.

Screenshot 2024-07-03 at 09 58 44

I tried with your .yo-rc.json and JDL and experienced the same behavior. Here's the console after the restart by Spring DevTools.

Screenshot 2024-07-03 at 10 07 01

From jhipster info:

pure-v-860@0.0.1-SNAPSHOT /Users/mraible/Downloads/reopen
└── generator-jhipster@8.6.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "oauth2",
    "baseName": "pureV860",
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "angular",
    "clientTestFrameworks": [],
    "clientTheme": "none",
    "creationTimestamp": 1719429321098,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [
      "SpaceEvent",
      "Mission",
      "Log"
    ],
    "feignClient": null,
    "jhipsterVersion": "8.6.0",
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "pt-br",
    "packageName": "com.mycompany.myapp",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [],
    "serviceDiscoveryType": false,
    "skipUserManagement": true,
    "syncUserWithIdp": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": false
  }
}
Environment and Tools

openjdk version "22.0.1" 2024-04-16 OpenJDK Runtime Environment GraalVM CE 22.0.1+8.1 (build 22.0.1+8-jvmci-b01) OpenJDK 64-Bit Server VM GraalVM CE 22.0.1+8.1 (build 22.0.1+8-jvmci-b01, mixed mode, sharing)

git version 2.39.3 (Apple Git-146)

node: v20.15.0 npm: 10.7.0

Docker version 26.1.4, build 5650f9b

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
@ChangelogDate("20240506143746")
entity SpaceEvent {
  id UUID
  name String required
  date LocalDate required
  description TextBlob required
  photo ImageBlob required
  type SpaceEventType required
}
@ChangelogDate("20240506143747")
entity Mission {
  id UUID
  name String required
  description String
}
@ChangelogDate("20240527105557")
entity Log {
  id UUID
  description String
}

enum SpaceEventType {
  LAUNCH,
  LANDING
}

relationship OneToOne {
  SpaceEvent{mission(name)} to Mission
}
relationship OneToMany {
  Mission{log} to Log{mission}
}

dto SpaceEvent, Mission, Log with mapstruct
paginate SpaceEvent, Mission, Log with pagination
service SpaceEvent, Mission, Log with serviceClass
search SpaceEvent, Mission, Log with no
filter SpaceEvent, Mission, Log

mshima commented 1 month ago

Happened in a vscode rebuild with me. I wonder if it’s a IDE misbehavior.

edilsonmendes commented 1 month ago

Happened in a vscode rebuild with me. I wonder if it’s a IDE misbehavior.

Sure. I'm using vscode too. I tested with Intellij and the error does not occur.

Any idea for a workarond? I use wsl and vscode fits perfectly.

mshima commented 1 month ago

Any idea for a workarond? I use wsl and vscode fits perfectly.

No, probably duplicate the maven-resources-plugin configuration instead of rely on parent pom configuration.

dmarin2000 commented 1 month ago

Hi,

I found a similar issue generating a microservice (with Jhipster 8.6.0 running in a docker image), the application should use a h2 in memory database for dev profile. Launching the application with ./mvnw, it fails to inject the right configuration leading to an error. Generating an identical application using a Jhipster 8.5.0 docker image, and trying to start it with ./mvnw doesn't show problems, as can be seen in the adjacent images

startup runtime