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

Error generating monolith from jdl with WebFlux and relationship to User entity #17796

Closed terrytompkins closed 2 years ago

terrytompkins commented 2 years ago
Overview of the issue

Generate a monolith application with WebFlux enabled as an option while running jhipster in a new directory. This works without issue. Then attempt to generate entities and the associated CRUD admin pages from a JDL file which has one or more relationships (different cardinalities tried) with the special User entity. Running "jhipster jdl entity.jdl" will fail during generation of java source files. The error will be similar to this: "Error running generator entities: Error: Error parsing file src/main/java/com/acme/webfluxuserjdltest/repository/BlogRepositoryInternalImpl.java: undefined". The full text of the error is attached as hipster-jdl-error.txt

Related issues

I did not find a similar reported issue.

Suggest a Fix

I will take a look at the generator code, but I am not familiar with how this code works (yet).

JHipster Version(s)

7.6.0

JHipster configuration

jhipster info INFO! Using JHipster version installed locally in current project's node_modules Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
webflux-user-jdl-test@0.0.1-SNAPSHOT /Users/ttompkins/src/Java/JHipster/test/WebFlux/webfluxUserJdlTest
└── generator-jhipster@7.6.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationTyp
[jhipster-jdl-error.txt](https://github.com/jhipster/generator-jhipster/files/8011438/jhipster-jdl-error.txt)
e": "monolith",
    "authenticationType": "jwt",
    "baseName": "webfluxUserJdlTest",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "react",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1644184211685,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": ["Blog", "Post", "Tag", "Product"],
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.6.0",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "al", "ar-ly", "hy"],
    "lastLiquibaseTimestamp": 1644184415000,
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.acme.webfluxuserjdltest",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "no",
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
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}
}

Environment and Tools

openjdk version "11.0.11" 2021-04-20 LTS OpenJDK Runtime Environment Corretto-11.0.11.9.1 (build 11.0.11+9-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.11.9.1 (build 11.0.11+9-LTS, mixed mode)

git version 2.34.1

node: v16.13.2

npm: 8.1.2

Docker version 20.10.8, build 3967b7d

docker-compose version 1.29.2, build 5becea4c

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete!

Entity configuration(s) entityName.json files generated in the .jhipster directory

Here is the Blog.json file from the .jhipster directory (this entity contains a relationship to the User entity.

{
  "applications": "*",
  "changelogDate": "20220206215332",
  "dto": "no",
  "embedded": false,
  "entityTableName": "blog",
  "fields": [
    {
      "fieldName": "name",
      "fieldType": "String",
      "fieldValidateRules": ["required", "minlength"],
      "fieldValidateRulesMinlength": "3"
    },
    {
      "fieldName": "handle",
      "fieldType": "String",
      "fieldValidateRules": ["required", "minlength"],
      "fieldValidateRulesMinlength": "2"
    }
  ],
  "fluentMethods": true,
  "jpaMetamodelFiltering": false,
  "name": "Blog",
  "pagination": "no",
  "readOnly": false,
  "relationships": [
    {
      "otherEntityField": "login",
      "otherEntityName": "user",
      "otherEntityRelationshipName": "blog",
      "relationshipName": "user",
      "relationshipType": "many-to-one"
    }
  ],
  "service": "no"
}
Browsers and Operating System

Safari browser in use on an M1-based MacBook Pro 2020 with the latest operating system patches. Not browser-related the error occurs at the command line during jdl-driven entity code generation.

I do love jHipster, and I have and will continue donating the the collective - thank you! yo-rc.json.txt

terrytompkins commented 2 years ago

jhipster-jdl-error.txt content of error referenced above from running jhipster jdl entity.jdl

terrytompkins commented 2 years ago

I have narrowed the problem down to changes made to generator-jhipster between 7.3.0 and 7.3.1. The former version worked with my sample jdl, and the latter does not. I'll do a comparison between these generator versions to see if anything jumps out.

mraible commented 2 years ago

Have you had any luck figuring this out @TransWebT?

mshima commented 2 years ago

Looks like there is a bug at prettier-plugin-java. It’s failing to report the error location.

terrytompkins commented 2 years ago

@mraible - I was reviewing the relevant differences between 7.3.0 and 7.3.1 last week and then got busy with some day job work I had to catch up with. I'm planning on digging in again this weekend unless a fix jumps out at someone else. -terry

mshima commented 2 years ago

It's indeed a bug. The offending line is:

import .repository.rowmapper.UserRowMapper;

And prettier-plugin-java fails to identify the line. cc @clementdessoude