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.53k stars 4.02k forks source link

cannot generate entity from v8.7.1 #27353

Closed chh315 closed 3 weeks ago

chh315 commented 1 month ago
Overview of the issue

cannot generate entity from v8.7.1

ERROR! An error occured while running jhipster:languages#writeClientTranslations ERROR! ERROR! Error rendering template /usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs to /workspaces/tipoca-visualization/src/main/webapp/i18n/ja/health.json: ReferenceError: /usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs:32 30| }, 31| "indicator": {

32| <% if (messageBrokerAny) { %> 33| "binders": "Message broker", 34| <% } %> 35| <% if (applicationTypeGateway || serviceDiscoveryAny) { %>

messageBrokerAny is not defined Error: Error rendering template /usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs to /workspaces/tipoca-visualization/src/main/webapp/i18n/ja/health.json: ReferenceError: /usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs:32 30| }, 31| "indicator": {

32| <% if (messageBrokerAny) { %> 33| "binders": "Message broker", 34| <% } %> 35| <% if (applicationTypeGateway || serviceDiscoveryAny) { %>

messageBrokerAny is not defined at renderTemplate (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/base-core/generator.js:886:23) at async Promise.all (index 13) at async LanguagesGenerator.writeFiles (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/base-core/generator.js:1009:23) at async Promise.all (index 0) at async LanguagesGenerator.writeClientTranslations (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/generator.js:236:17) at async LanguagesGenerator.executeTask (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/dist/actions/lifecycle.js:265:13) at async runLoop.add.once (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/yeoman-environment/dist/environment-base.js:395:17) { [cause]: ReferenceError: /usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs:32 30| }, 31| "indicator": {

32| <% if (messageBrokerAny) { %> 33| "binders": "Message broker", 34| <% } %> 35| <% if (applicationTypeGateway || serviceDiscoveryAny) { %>

messageBrokerAny is not defined at LanguagesGenerator.eval ("/usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs":13:8) at health.json (/usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/ejs/lib/ejs.js:703:17) at /usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/ejs/lib/ejs.js:260:40 at new Promise () at tryHandleCache (/usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/ejs/lib/ejs.js:258:14) at exports.renderFile (/usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/ejs/lib/ejs.js:491:10) at renderFile (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/mem-fs-editor/dist/util.js:65:16) at MemFsEditor.processFile (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/mem-fs-editor/dist/actions/copy-tpl-async.js:13:20) at MemFsEditor.applyProcessingFileFunc (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/mem-fs-editor/dist/actions/copy-async.js:11:54) at MemFsEditor._copySingleAsync (file:///usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/node_modules/mem-fs-editor/dist/actions/copy-async.js:79:52) { path: '/usr/local/share/nvm/versions/node/v20.17.0/lib/node_modules/generator-jhipster/dist/generators/languages/templates/src/main/webapp/i18n/ja/health.json.ejs' } }

Motivation for or Use Case

cannot generate entity

Reproduce the error

jhipster entity UtageUserData

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

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


Documentation for creating an application is at https://www.jhipster.tech/creating-an-app/

Application files will be generated in folder: /workspaces/tipoca-visualization


INFO! The entity UtageUserData is being created.

Generating field #1

? Do you want to add a field to your entity? Yes ? What is the name of your field? eventParticipationDate ? What is the type of your field? String ? Do you want to add validation rules to your field? No

================= UtageUserData ================= Fields eventParticipationDate (String)

Generating field #2

? Do you want to add a field to your entity? No

================= UtageUserData ================= Fields eventParticipationDate (String)

Generating relationships to other entities

? Do you want to add a relationship to another entity? No

================= UtageUserData ================= Fields eventParticipationDate (String)

? Do you want to use separate service class for your business logic? Yes, generate a separate service class ? Do you want to use a Data Transfer Object (DTO)? No, use the entity directly ? Do you want to add filtering? Dynamic filtering for the entities with JPA Static metamodel ? Is this entity read-only? Yes ? Do you want pagination and sorting on your entity? Yes, with pagination links and sorting headers

Related issues
Suggest a Fix
JHipster Version(s)

v8.7.1

JHipster configuration

jhipster info

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

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

Welcome to the JHipster Information Sub-Generator

visualization@0.0.1-SNAPSHOT /workspaces/tipoca-visualization
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "visualization",
    "buildTool": "gradle",
    "cacheProvider": "hazelcast",
    "clientFramework": "angular",
    "clientTestFrameworks": [],
    "clientTheme": "united",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1726964251231,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": true,
    "enableTranslation": false,
    "entities": [],
    "feignClient": null,
    "gradleEnterpriseHost": null,
    "jhipsterVersion": "8.7.1",
    "messageBroker": "kafka",
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "ja",
    "packageName": "com.nanoinfo.tipoca.visualization",
    "prodDatabaseType": "mysql",
    "reactive": true,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [
      "messageBroker:kafka",
      "enableSwaggerCodegen:true"
    ],
    "serviceDiscoveryType": false,
    "syncUserWithIdp": null,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}
Environment and Tools

openjdk version "17.0.7" 2023-04-18 LTS OpenJDK Runtime Environment Microsoft-7626293 (build 17.0.7+7-LTS) OpenJDK 64-Bit Server VM Microsoft-7626293 (build 17.0.7+7-LTS, mixed mode)

git version 2.41.0

node: v20.17.0 npm: 10.8.2

Docker version 27.0.3-1, build 7d4bcd863a4c863e650eed02a550dfeb98560b83

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Congratulations, JHipster execution is complete! If you find JHipster useful consider sponsoring the project https://www.jhipster.tech/sponsors/

Thanks for using JHipster!

Browsers and Operating System

MaxOS

enorabnl commented 3 weeks ago

Hi, I have the exactly same error and I could'nt create entity. Have you found a solution

rbaoueb commented 3 weeks ago

I have deleted this bloc in health.json.ejs file and it works fine

<% if (messageBrokerAny) { %> "binders": "Message broker", <% } %>

sbouchex commented 3 weeks ago

The fix may go to "config.ts" to set messageBroker, messageBrokerAny, messageBrokerKafka & messageBrokerPulsar... No ?

mshima commented 3 weeks ago

Workaround, add to project's .blueprint/bootstrap-application-base/index.mjs this:

import { pathToFileURL } from 'node:url';

export async function createGenerator(env) {
  const BaseApplicationGenerator = await env.requireGenerator('jhipster:base-application');
  return class extends BaseApplicationGenerator {
    constructor(args, options, features) {
      super(args, options, { ...features, sbsBlueprint: true });
    }

    get [BaseApplicationGenerator.DEFAULT]() {
      return {
        async loadApplicationKeys({ application }) {
          const jhipsterRoot = env.getPackagePath('jhipster');
          const { loadCommandConfigsKeysIntoTemplatesContext } = await import(pathToFileURL(`${jhipsterRoot}/dist/lib/command/load.js`));
          const { lookupCommandsConfigs } = await import(pathToFileURL(`${jhipsterRoot}/dist/lib/command/lookup-commands-configs.js`));
          loadCommandConfigsKeysIntoTemplatesContext({
            templatesContext: application,
            commandsConfigs: (await lookupCommandsConfigs()),
          });
        },
      };
    }
  };
};
sbouchex commented 3 weeks ago

does not work on Windows:

ERROR! An error occured while running @jhipster/jhipster-local:bootstrap-application-base#loadApplicationKeys ERROR! ERROR! Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:249:11) at defaultLoad (node:internal/modules/esm/load:130:3)

mshima commented 3 weeks ago

Updated with windows support.

sbouchex commented 3 weeks ago

same result (same stack)

mshima commented 3 weeks ago

The stack is not useful to discover the bug location.