Search code examples
dockerneo4jjhipstergraphenedb

Neo4J credentials not working for JHipster generated Spring Boot application


When I deployed my JHipster application to Heroku, and connected to a GrapheneDB Neo4J instance (version 3.5.17), the application fails to connect to the Neo4J instance. I tried to reproduce the error locally, thinking it had to do with a version mismatch, as locally the Docker version of Neo4J is 4.0.

However, I localized the error in presence/absence of credentials, with either version of Neo4J.

The working version has this docker-compose.yml file entry:

    environment:
      - NEO4J_AUTH=none

and this entry in the application.yml:

org:
  neo4j:
    driver:
      uri: bolt://localhost:7687

This version is able to connect. Once I introduce credentials, the entries look like this, docker-compose.yml:

    environment:
      - NEO4J_AUTH=myapplication/myapplication

and application.yml:

org:
  neo4j:
    driver:
      uri: bolt://localhost:7687
      authentication:
        username: myapplication
        password: myapplication

This version is unable to connect. What is the correct way to set credentials in Spring Boot as well as the neo4j docker image? Is there anything else I am missing?

Connecting to the GrapheneDB instance from my local machine gives the same error, so I suspect that the problem is in the driver configuration. Some search hits mention org.neo4j.driver.username instead of org.neo4j.driver.authentication.username but I tried both and the result is the same.


Solution

  • It turns out I was misled by the Neo4J documentation, which stated that encryption was on by default. All I needed to do was:

    org.neo4j.driver.config.encrypted=true

    or combined, in YAML:

    org:
      neo4j:
        driver:
          uri: bolt://localhost:7687
          authentication:
            username: myapplication
            password: myapplication
          config:
            encrypted: true
    

    For full configuration, see: https://neo4j.com/developer/driver-spring-boot-starter/