Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPA default entity scan fails on newly created project #388

Open
vcupelloni opened this issue Aug 24, 2024 · 1 comment
Open

JPA default entity scan fails on newly created project #388

vcupelloni opened this issue Aug 24, 2024 · 1 comment

Comments

@vcupelloni
Copy link

vcupelloni commented Aug 24, 2024

Overview of the issue

It seems that by creating a new microservice from scratch without entities and with User entity creation disabled, it cannot then be started due to an error in JPA's automatic entity scan.

image

Creating even a single entity with jhipster generator solves all the problems and the project can run.

Reproduce the error

Install JHipster and Micronaut blueprint, configure an application (in the screenshot I used microservice/postgresql/ehcache but itried several configuration with same results) , start the project after generation is completed.

image

Suggest a Fix

I am not aware of a parameter to disable JPA's autoscan, the only way I found to start the application is to comment out in the build.gradle file the dependency to io.micronaut.data:micronaut-data-hibernate-jpa

Is it feasible that this dependency will only be added if there is at least one entity?

Project configuration
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "microservice",
    "authenticationType": "jwt",
    "backendType": "micronaut",
    "baseName": "myprojectMicroservice",
    "blueprints": [
      {
        "name": "generator-jhipster-micronaut",
        "version": "3.4.1"
      }
    ],
    "buildTool": "gradle",
    "cacheProvider": "ehcache",
    "clientFramework": "no",
    "clientTestFrameworks": null,
    "clientTheme": null,
    "creationTimestamp": 1724496465308,
    "devDatabaseType": "h2Disk",
    "enableGradleEnterprise": false,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": [],
    "gradleEnterpriseHost": null,
    "jhipsterVersion": "8.5.0",
    "languages": [
      "it"
    ],
    "messageBroker": "no",
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "it",
    "packageName": "com.mycompany.myapp",
    "prodDatabaseType": "postgresql",
    "searchEngine": "no",
    "serverPort": 8081,
    "serverTestFrameworks": [],
    "serviceDiscoveryType": "consul",
    "skipClient": true,
    "syncUserWithIdp": null,
    "testFrameworks": [
      []
    ],
    "withAdminUi": null
  }
}
Environment and Tools

openjdk version "21.0.4" 2024-07-16
OpenJDK Runtime Environment (build 21.0.4+7)
OpenJDK 64-Bit Server VM (build 21.0.4+7, mixed mode, sharing)

git version 2.46.0

node: v18.19.1
npm: 10.2.4

Docker version 27.1.2, build d01f264bcc

  • [ X ] Checking this box is mandatory (this is just to show you read everything)
@vcupelloni
Copy link
Author

vcupelloni commented Aug 29, 2024

Does anyone know how I can inject the information about how many entities have been generated within the context so I can put a check in the build.gradle.ejs template?

The information is present in the yo-rc.json file but I don't know how to retrieve it cleanly.

Right now I am under the impression that the generator cannot be used out-of-the box or at least it generates broken code, am I wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant