Skip to content
Advertisement

enabling Elasticsearch in JHipster results in UnsatisfiedDependencyException: Error creating bean with name ‘userService’

I’ve been trying to build an app with JHipster that can use some advanced filtering, in particular ElasticSearch. Why does it fail when I run it out of the box, without even editing the project ?

I am running the following software in Windows 10:

  • Java v15.0.2
  • node v14.17.4
  • NPM 6.14.14

Same happens in Ubuntu with:

  • Java v17.0.1
  • node v16.14.0
  • NPM 8.5.0

The problem I have is very easy to reproduce:

  1. Go to the online version https://start.jhipster.tech/generate-application
  2. Leave everything as it is, and mark the option “Search engine using Elasticsearch”
  3. Click on Download as ZIP file
  4. Unpack and run with ./mvnw

—> the build is compiled but it fails to launch because it can’t instantiate the bean ‘userService’

Full trace:

JavaScript

Advertisement

Answer

[java.util.concurrent.ExecutionException: java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]]; nested: ExecutionException[java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]];

If you look further in your stacktrace you can see that the application simply cannot connect to localhost:9200 which is the default address of an Elasticsearch local instance.

You firstly need to run elasticsearch on your machine in order for the application to work. You can do it quickly in docker https://docs.docker.com/get-docker/

Install docker, then type to download the image:

JavaScript

After you can launch the container with elasticsearch

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement