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

[v7.9.3] App with Elasticsearch doesn't work out-of-the-box with Heroku #20315

Closed mraible closed 2 months ago

mraible commented 1 year ago
Overview of the issue

I'm updating 21-Points Health as part of the JHipster Mini-Book. When I deploy to Heroku with Jenkins, it fails to work.

The generated deployment task is as follows:

stage('deployment') {
    sh "./gradlew deployHeroku --no-daemon"
}

I started commenting on the old issue, but realized it's probably better to create a new one.

With JHipster v7.9.3, the workaround of downgrading Elasticsearch for Heroku only works with git push and fails to work when you try to use Elasticsearch:

2022-11-08T05:17:22.489474+00:00 app[web.1]: 2022-11-08T05:17:22.488Z ERROR 4 --- [  XNIO-1 task-3] o.z.problem.spring.common.AdviceTraits   : Internal Server Error
2022-11-08T05:17:22.489493+00:00 app[web.1]:
2022-11-08T05:17:22.489494+00:00 app[web.1]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchFieldError: INDEX_CONTENT_TYPE
2022-11-08T05:17:22.489496+00:00 app[web.1]: at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1085)
2022-11-08T05:17:22.489496+00:00 app[web.1]: at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
Motivation for or Use Case

I'd like to update the JHipster Mini-Book to v7 and this is a blocker.

Reproduce the error

Create an app using the following .yo-rc.json, deploy it to Heroku, and try to register a new user.

{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "TwentyOnePoints",
    "blueprints": [],
    "buildTool": "gradle",
    "cacheProvider": "ehcache",
    "clientFramework": "angularX",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1662997089611,
    "cypressAudit": false,
    "cypressCoverage": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 4200,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entities": ["Points", "Weight", "BloodPressure", "Preferences"],
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.3",
    "languages": ["en", "fr"],
    "lastLiquibaseTimestamp": 1667866821000,
    "messageBroker": false,
    "microfrontend": false,
    "microfrontends": [],
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "org.jhipster.health",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": "elasticsearch",
    "serverPort": "8080",
    "serverSideOptions": ["searchEngine:elasticsearch"],
    "serviceDiscoveryType": "no",
    "skipCheckLengthOfIdentifier": false,
    "skipClient": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": ["cypress"],
    "websocket": false,
    "withAdminUi": true
  }
}

Or, clone this repo and try to deploy it to Heroku.

Related issues
Suggest a Fix

I think there's a few options:

Personally, using the ES add-on seems like the best practice, but 67/month seems pricey for a sample app. I already pay $25/month to keep it on all the time. I'd like to document the best way to do things in the mini-book, if possible. There's a good chance this predicament and solution will be part of the book.

Deploying a Docker container to Heroku seems like an easy workaround. Here's some helpful links:

JHipster Version
twenty-one-points@0.0.1-SNAPSHOT /Users/mraible/dev/21-points
└── generator-jhipster@7.9.3
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "applicationType": "monolith",
  "authenticationType": "jwt",
  "baseName": "TwentyOnePoints",
  "blueprints": [],
  "buildTool": "gradle",
  "cacheProvider": "ehcache",
  "clientFramework": "angularX",
  "clientPackageManager": "npm",
  "clientTheme": "none",
  "clientThemeVariant": "",
  "creationTimestamp": 1662997089611,
  "cypressAudit": false,
  "cypressCoverage": false,
  "databaseType": "sql",
  "devDatabaseType": "h2Disk",
  "devServerPort": 4200,
  "dtoSuffix": "DTO",
  "enableGradleEnterprise": false,
  "enableHibernateCache": true,
  "enableSwaggerCodegen": false,
  "enableTranslation": true,
  "entities": [
    "Points",
    "Weight",
    "BloodPressure",
    "Preferences"
  ],
  "entitySuffix": "",
  "herokuAppName": "health-by-pints",
  "herokuDeployType": "git",
  "herokuJavaVersion": "11",
  "jhiPrefix": "jhi",
  "jhipsterVersion": "7.9.3",
  "languages": [
    "en",
    "fr"
  ],
  "lastLiquibaseTimestamp": 1667866821000,
  "messageBroker": false,
  "microfrontend": false,
  "microfrontends": [],
  "nativeLanguage": "en",
  "otherModules": [],
  "packageName": "org.jhipster.health",
  "pages": [],
  "prodDatabaseType": "postgresql",
  "reactive": false,
  "searchEngine": "elasticsearch",
  "serverPort": "8080",
  "serverSideOptions": [
    "searchEngine:elasticsearch"
  ],
  "serviceDiscoveryType": "no",
  "skipCheckLengthOfIdentifier": false,
  "skipClient": false,
  "skipFakeData": false,
  "skipUserManagement": false,
  "testFrameworks": [
    "cypress"
  ],
  "websocket": false,
  "withAdminUi": true
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Points {
  date LocalDate required
  exercise Integer
  meals Integer
  alcohol Integer
  notes String maxlength(140)
}
entity Weight {
  timestamp ZonedDateTime required
  weight Double required
}
entity BloodPressure {
  timestamp ZonedDateTime required
  systolic Integer required
  diastolic Integer required
}
entity Preferences {
  weeklyGoal Integer required min(10) max(21)
  weightUnits Units required
}
enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}
relationship ManyToOne {
  Points{user(login)} to User
  Weight{user(login)} to User
  BloodPressure{user(login)} to User
}

paginate Points with pagination
paginate Weight, BloodPressure with infinite-scroll

Environment and Tools

openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8) OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode)

git version 2.33.0

node: v16.17.0 npm: 8.19.3

Docker version 20.10.20, build 9fdeb9c

atomfrede commented 1 year ago

Deploying ES docker should work. Not sure about it works well with the smalles dyno instances (and totally no idea about the storage part).

mraible commented 1 year ago

I didn't try creating ES in a Docker container. However, I did get things working with Elastic Cloud. I documented how to make your Heroku app work with Elastic Cloud in the JHipster Mini-Book and in https://github.com/jhipster/jhipster.github.io/pull/1247.

github-actions[bot] commented 9 months ago

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

xeraa commented 9 months ago

I think we'll still need this :)

atomfrede commented 8 months ago

Let's check if the docs for elastic cloud are still okay. If that works it seems like the best solution although it requires some manual steps.

mraible commented 8 months ago

The docs and the Elasticsearch part of the JHipster Mini-Book say you have to use an older version for Elasticsearch. We should verify that's still the case. It'd be nice if the latest version worked.

atomfrede commented 8 months ago

I suppose we can use the one we have for the generated docker(compose) file, which is 8.10.4 as of now.

github-actions[bot] commented 2 months ago

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