Generator-jhipster: Infinispan with Keycloak and microservice build error

Created on 20 Feb 2018  ·  7Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

On newly generated microservice application, when choosing "infinispan" as cache provider along with "oauth2" authentication, the build command (./gradlew -Pprod bootRepackage) end up with an error about missing classes.


gradle error message

> Task :compileJava 
/Users/NonlyNerd/Documents/git/jhipster-api/src/main/java/fr/nonlynerd/jhipsterproject/config/CacheConfiguration.java:179: error: cannot find symbol
            registerPredefinedCache(fr.nonlynerd.jhipsterproject.repository.UserRepository.USERS_BY_LOGIN_CACHE, new JCache(
                                                                           ^
  symbol:   class UserRepository
  location: package fr.nonlynerd.jhipsterproject.repository
/Users/NonlyNerd/Documents/git/jhipster-api/src/main/java/fr/nonlynerd/jhipsterproject/config/CacheConfiguration.java:180: error: cannot find symbol
                cacheManager.getCache(fr.nonlynerd.jhipsterproject.repository.UserRepository.USERS_BY_LOGIN_CACHE).getAdvancedCache(), this,
                                                                             ^
  symbol:   class UserRepository
  location: package fr.nonlynerd.jhipsterproject.repository
/Users/NonlyNerd/Documents/git/jhipster-api/src/main/java/fr/nonlynerd/jhipsterproject/config/CacheConfiguration.java:182: error: cannot find symbol
            registerPredefinedCache(fr.nonlynerd.jhipsterproject.repository.UserRepository.USERS_BY_EMAIL_CACHE, new JCache(
                                                                           ^
  symbol:   class UserRepository
  location: package fr.nonlynerd.jhipsterproject.repository
/Users/NonlyNerd/Documents/git/jhipster-api/src/main/java/fr/nonlynerd/jhipsterproject/config/CacheConfiguration.java:183: error: cannot find symbol
                cacheManager.getCache(fr.nonlynerd.jhipsterproject.repository.UserRepository.USERS_BY_EMAIL_CACHE).getAdvancedCache(), this,
                                                                             ^
  symbol:   class UserRepository
  location: package fr.nonlynerd.jhipsterproject.repository
Note: /Users/NonlyNerd/Documents/git/jhipster-api/src/main/java/fr/nonlynerd/jhipsterproject/security/oauth2/SimpleAuthoritiesExtractor.java uses unchecked or unsafe operations
Note: Recompile with -Xlint:unchecked for details.
4 errors

Motivation for or Use Case

I want to use a fully open sourced distributed cache in a microservice architecture. Since Hazelcast isn't fully open source, and ehcache JHipster integration doesn't support distributed cache according to cache documentation, the only choice left to me through generator-jhipster is infinispan.

Reproduce the error

Install latest JHipster generator revision and answer questions as follow :

? Which *type* of application would you like to create? Microservice application
? What is the base name of your application? JHipsterMicroserviceAPI
? 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. 8081
? What is your default Java package name? fr.nonlynerd.jhipsterproject
? Which service discovery server do you want to use? Consul
? Which *type* of authentication would you like to use? OAuth 2.0 / OIDC Authentication (statefu
l, works with Keycloak and Okta)
? Which *type* of database would you like to use? No database
? Do you want to use the Spring cache abstraction? [BETA] Yes, with the Infinispan (hybrid cache
, for multiple nodes)
? Would you like to use Maven or Gradle for building the backend? Gradle
? Which other technologies would you like to use? 
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application English
? Please choose additional languages to install French
? Besides JUnit and Karma, which testing frameworks would you like to use? Gatling, Cucumber
? Would you like to install other generators from the JHipster Marketplace? No
Then run `./gradlew -Pprod bootRepackage` to raise the issue. ##### **Related issues** Linked to #6360 as incriminated change is made in PR #6361 ##### **Suggest a Fix** Commenting out some generated lines for infinispan in CacheConfiguration solve the issue. I think the linked condition is faulty in my case. https://github.com/jhipster/generator-jhipster/blob/4821f66fe7784c1c7d6da5118c1ed1791ee7fd73/generators/server/templates/src/main/java/package/config/_CacheConfiguration.java#L494 ##### **JHipster Version(s)**
[email protected] /Users/NonlyNerd/Documents/git/jhipster-api
└── [email protected] 

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "fr.nonlynerd.jhipsterproject",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.14.0",
    "baseName": "JhipsterMicroserviceAPI",
    "packageName": "fr.nonlynerd.jhipsterproject",
    "packageFolder": "fr/nonlynerd/jhipsterproject",
    "serverPort": "8081",
    "authenticationType": "oauth2",
    "cacheProvider": "infinispan",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "no",
    "devDatabaseType": "no",
    "prodDatabaseType": "no",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "consul",
    "buildTool": "gradle",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "enableTranslation": true,
    "applicationType": "microservice",
    "testFrameworks": [
      "gatling",
      "cucumber"
    ],
    "jhiPrefix": "jhi",
    "nativeLanguage": "en",
    "languages": [
      "en",
      "fr"
    ],
    "clientPackageManager": "yarn",
    "skipClient": true,
    "skipUserManagement": true
  }
}

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

None

Environment and Tools

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

git version 2.15.1

node: v9.3.0

npm: 5.5.1

yeoman: 2.0.0

yarn: 1.3.2

Docker version 18.02.0-ce, build fc4de44

docker-compose version 1.15.0, build e12f3b9

Browsers and Operating System

Google Chrome, macOS High Sierra (not relevant in this case)

  • [ x] Checking this box is mandatory (this is just to show you read everything)

Most helpful comment

LOL if your company won't let you fix a bug on a software they use!

All 7 comments

Thanks! It looks like you even found the solution -> would you like to do a PR?
I'll try to cherry-pick it in order to have the fix in the v4 branch too

I cannot guarantee that I can make a PR for copyrights issues. I'll check with my work and give you the answer here when I have it. If it's all ok for them, I'll make it when I have some spare time. Thanks for your awesome work !

LOL if your company won't let you fix a bug on a software they use!

We doesn't use this software in our company. It's all on my free time for my personal or school projects, in order to learn new things very fast (I first dive into JHipster without knowing Angular nor Spring) and bootstrap projects with best practices in my learning. Again, the JHipster community have done an awesome work and I'm thankful for that, but I have a very restrictive contract with my work on all code-related things.

And they said "ok", so I look about the PR this weekend.

Awesome!

ping @srinivasa-vasu

@deepu105 Noted, will look into it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edvjacek picture edvjacek  ·  3Comments

lsadehaan picture lsadehaan  ·  3Comments

dronavallisaikrishna picture dronavallisaikrishna  ·  3Comments

tomj0101 picture tomj0101  ·  3Comments

sdoxsee picture sdoxsee  ·  4Comments