generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Generating a New JHipster Project with a Cache Results in Cache Provider Not Being Generated

Open willywanka75 opened this issue 2 years ago • 3 comments

Overview of the issue

Generating a new JHipster project with any cache (eg. redis) results in "cacheProvider": "no", in .yo-rc.json and no generated code regarding cache.

Motivation for or Use Case

Prevents cache options from being generated.

Reproduce the error
> jhipster

? Which *type* of application would you like to create? Gateway application
? What is the base name of your application? temp
? As you are running in a microservice architecture, on which port would like your server to run? It should be unique to avoid port conflicts. 8090
? What is your default Java package name? com.domain.test
? Which service discovery server do you want to use? JHipster Registry (uses Eureka, provides Spring Cloud Config support and monitoring dashboards)
? Which *type* of authentication would you like to use? OAuth 2.0 / OIDC Authentication (stateful, works with Keycloak and Okta)
? Which *type* of database would you like to use? MongoDB
? Which cache do you want to use? (Spring cache abstraction) Redis (distributed cache)
? Would you like to use Maven or Gradle for building the backend? Gradle
? Which other technologies would you like to use? 
? Which *Framework* would you like to use for the client? Angular
? Do you want to generate the admin UI? Yes
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Slate
? Choose a Bootswatch variant navbar theme (https://bootswatch.com/)? Primary
? Would you like to enable internationalization support? No
? Please choose the native language of the application English
? Besides JUnit and Jest, which testing frameworks would you like to use? [DEPRECATED] Protractor, Gatling
? Would you like to install other generators from the JHipster Marketplace? No
Related issues

No

JHipster Version(s)

JHipster info:

INFO! Switching to JHipster installed locally in current project's node repository (node_modules)

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

Welcome to the JHipster Information Sub-Generator

##### **JHipster Version(s)**

[email protected] /home/user/Downloads/temp └── [email protected]



##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "gateway",
    "authenticationType": "oauth2",
    "baseName": "temp",
    "blueprints": [],
    "buildTool": "gradle",
    "cacheProvider": "no",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "slate",
    "clientThemeVariant": "primary",
    "creationTimestamp": 1655141844174,
    "databaseType": "mongodb",
    "devDatabaseType": "mongodb",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.8.1",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en", "fr"],
    "messageBroker": false,
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.domain.test",
    "pages": [],
    "prodDatabaseType": "mongodb",
    "reactive": true,
    "searchEngine": false,
    "serverPort": "8090",
    "serverSideOptions": [],
    "serviceDiscoveryType": "eureka",
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": true,
    "testFrameworks": ["protractor", "gatling"],
    "websocket": false,
    "withAdminUi": true
  }
}

</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>

</pre>
</details>


##### **Environment and Tools**

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
Eclipse OpenJ9 VM AdoptOpenJDK-11.0.11+9 (build openj9-0.26.0, JRE 11 Linux amd64-64-Bit Compressed References 20210421_975 (JIT enabled, AOT enabled)
OpenJ9   - b4cc246d9
OMR      - 162e6f729
JCL      - 7796c80419 based on jdk-11.0.11+9)

git version 2.25.1

node: v16.15.0

npm: 8.5.5

Docker version 20.10.10, build b485636

docker-compose version 1.29.2, build 5becea4c


No change to package.json was detected. No package manager install will be executed.

willywanka75 avatar Jun 13 '22 23:06 willywanka75

Based on the code in 'generators/server/prompts.js' - line#320, this.cacheProvider = this.jhipsterConfig.cacheProvider = !answers.reactive ? answers.cacheProvider : NO_CACHE_PROVIDER;

Caching is available only with non-reactive options. Moreover Gateway applications are reactive and so the cacheProvider is set to no in the .yo-rc.json file. Someone from jhipster to validate this comment.

If this is correct, maybe the cache related prompt can be skipped for gateway application type.

dwarakaprasad avatar Jun 14 '22 19:06 dwarakaprasad

If this is the case, then upgrading from JHipster 6 from a non-reactive gateway should remove the caching from the code because it currently causes an issue with Redis where Radisson can't serialize Mono.

willywanka75 avatar Jun 14 '22 20:06 willywanka75

Indeed the prompt is wrong I think. Regarding updating a non reactive gateway to a reactive one, I guess we should document it somewhere (not sure if we can just remove the generated caching classes). We missed to make that clear when 7.x was released this is a kind of breaking change

atomfrede avatar Aug 17 '22 10:08 atomfrede

Is there any plan to implement a caching solution for reactive Gateway or going back to having option to choose non-reactive? Looks like CacheFlux and CacheMono are being deprecated from reactor project due to "creating more problems than they solved" so looks like no easy solutions in short term other than no cache.

gnomeoday avatar Jul 25 '23 16:07 gnomeoday

This issue is stale because it has been open for too long without any activity. Due to the moving nature of jhipster generated application, bugs can become invalid. If this issue still applies please comment otherwise it will be closed in 7 days

github-actions[bot] avatar Jan 22 '24 00:01 github-actions[bot]