generator-jhipster: App with Elasticsearch doesn't work out-of-the-box with Heroku
Overview of the issue
I’m adding this issue because I believe @jkutner did work recently to make it so Elasticsearch was automatically configured when you deploy an app to Heroku. I see the following on startup, so I’m guessing provisioning Elasticseach is working.
2018-06-19T14:16:28.440721+00:00 app[api]: Attach SEARCHBOX (@ref:searchbox-adjacent-53104) by user matt@raibledesigns.com
However, when my app starts up, it fails to connect to this instance, and all CRUD functionality is broken.
2018-06-19T14:24:38.262001+00:00 app[web.1]: 2018-06-19 14:24:38.261 ERROR 4 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{hR944JNITnub8FEFr6wLEQ}{localhost}{127.0.0.1:9300}]
2018-06-19T14:24:38.561165+00:00 app[web.1]: 2018-06-19 14:24:38.560 ERROR 4 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{hR944JNITnub8FEFr6wLEQ}{localhost}{127.0.0.1:9300}]
2018-06-19T14:24:39.424443+00:00 app[web.1]: 2018-06-19 14:24:39.424 ERROR 4 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{hR944JNITnub8FEFr6wLEQ}{localhost}{127.0.0.1:9300}]
2018-06-19T14:24:39.730791+00:00 app[web.1]: 2018-06-19 14:24:39.730 ERROR 4 --- [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{hR944JNITnub8FEFr6wLEQ}{localhost}{127.0.0.1:9300}]
2018-06-19T14:24:46.976031+00:00 app[web.1]: 2018-06-19 14:24:46.975 INFO 4 --- [ main] com.okta.developer.GalleryApp : Started GalleryApp in 44.913 seconds (JVM running for 46.471)
Motivation for or Use Case
I expected Elasticsearch to work on Heroku, without any configuration changes. Kinda like PostgreSQL does.
Reproduce the error
Create a v5 project with Elasticsearch and deploy it to Heroku.
JHipster Version(s)
gallery@0.0.0 /home/mraible/gallery
└── (empty)
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.okta.developer",
"nativeLanguage": "en"
},
"jhipsterVersion": "5.0.0-beta.3",
"applicationType": "monolith",
"baseName": "gallery",
"packageName": "com.okta.developer",
"packageFolder": "com/okta/developer",
"serverPort": "8080",
"authenticationType": "oauth2",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSwaggerCodegen": false,
"clientFramework": "react",
"useSass": false,
"clientPackageManager": "yarn",
"testFrameworks": [
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"fr"
],
"herokuDeployType": "git"
}
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Album (album) {
title String required,
description TextBlob,
created Instant
}
entity Photo (photo) {
title String required,
description TextBlob,
image ImageBlob required,
takenOn Instant,
uploadedOn Instant
}
entity Tag (tag) {
name String required minlength(2)
}
relationship ManyToOne {
Album{user(login)} to User,
Photo{album(title)} to Album
}
relationship ManyToMany {
Photo{tag(name)} to Tag{photo}
}
paginate Album with pagination
paginate Photo, Tag with infinite-scroll
Environment and Tools
java version “1.8.0_171” Java™ SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot™ 64-Bit Server VM (build 25.171-b11, mixed mode)
git version 2.17.0
node: v8.10.0
npm: 6.1.0
yarn: 1.6.0
Docker version 18.05.0-ce, build f150324
docker-compose version 1.13.0, build 1719ceb
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29 (24 by maintainers)
I can’t believe all this:
So if Spring Data Jest solves both of those issues, let’s use it. But I’m worried to add one more library, with probably a lot of dependencies. Besides, the project isn’t very popular (105 stars at the moment), and is not an official Spring Data project, so this means we might have trouble in the future if it’s not well maintained.
The following is what I find jHipster v <5 was using Elasticsearch v 2.x which had support for Elasticsearch in embedded mode (that’s the reason we didn’t need an instance of Elasticsearch running outside.) With jHipster v >= 5 the Elasticsearch has been upgraded to v 5.x (as a part of upgrade to spring-boot 2.x) which dropped embedded Elasticsearch, so it needs an instance running outside. Any jHipster app with elasticsearch when started with docker-compose didn’t have any impact as it was starting Elasticsearch in docker container and not relying on embedded elasticsearch.
Now, when it comes to the issue with Heroku deployment, the respective sub-generator points the app to a real postgres db instance in the case of postgres, which does not happen with elasticsearch which became a problem with jHipster v >= 5
I haven’t looked into the latest version of heroku sub-generator, But, I believe a lib like the following might be helpful in proving Elasticsearch which seems to have support for v 5.x https://github.com/allegro/embedded-elasticsearch
I’m working on a project with JHipster and Elasticsearch in macOS. In development mode, it went fine with version 4.14.4. Using the same profile, version 5.0.0 doesn’t work, it shows the same errors @mraible described.
I’ve installed a standalone Elasticsearch server (
brew install elasticsearch), edited /usr/local/etc/elasticsearch/elasticsearch.yml to changecluster.nametoelasticsearchand started the server withelasticsearch. After that the application launches in development mode without errors.Please let me know if there is anything else I can help with.
Version 5.0.1 shows the same behaviour.
@mraible I think that’s a good plan. There are a lot of environments where the Elasticsearch REST interface is required or preferred, so this would put JHipster is a better spot in general. Let me know if I can help.