javamavenneo4jnosqlhibernate-ogm

Hibernate OGM with Neo4j - Application conncetion to server failed


I'am trying to use hibernate ogm to connect to neo4j server that i am running using docker on my local machine.

When a try to connect i got the message:

Exception in thread "main" javax.persistence.PersistenceException: Unable to build entity manager factory
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:66)
    at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:59)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at base.service.NoRelationshipTestsService.<init>(NoRelationshipTestsService.java:14)
    at base.Main.main(Main.java:13)
Caused by: org.hibernate.service.spi.ServiceException: OGM000071: Unable to start datastore provider
    at org.hibernate.ogm.datastore.neo4j.remote.bolt.impl.BoltNeo4jDatastoreProvider.start(BoltNeo4jDatastoreProvider.java:64)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.startService(AbstractServiceRegistryImpl.java:332)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:240)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:51)
    at org.hibernate.ogm.dialect.impl.GridDialectInitiator.initiateService(GridDialectInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator$OgmDialectFactory.<init>(OgmDialectFactoryInitiator.java:44)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:31)
    at org.hibernate.ogm.dialect.impl.OgmDialectFactoryInitiator.initiateService(OgmDialectFactoryInitiator.java:25)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:50)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
    at org.hibernate.ogm.service.impl.OgmJdbcServicesInitiator$OgmJdbcServicesImpl.configure(OgmJdbcServicesInitiator.java:51)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:848)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:875)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
    ... 5 more
Caused by: org.hibernate.HibernateException: OGM001419: Connection failed on bolt://localhost:7687/neo4j, error code N/A SSL Connection terminated while receiving data. This can happen due to network instabilities, or due to restarts of the database.
    at org.hibernate.ogm.datastore.neo4j.remote.bolt.impl.BoltNeo4jClient.validateConnection(BoltNeo4jClient.java:51)
    at org.hibernate.ogm.datastore.neo4j.remote.bolt.impl.BoltNeo4jDatastoreProvider.validateConnection(BoltNeo4jDatastoreProvider.java:71)
    at org.hibernate.ogm.datastore.neo4j.remote.bolt.impl.BoltNeo4jDatastoreProvider.start(BoltNeo4jDatastoreProvider.java:58)
    ... 37 more

Process finished with exit code 1

If a try to connect to the server using the same authetication and url data using neo4j desktop i have success.

I really cant understand why this doesnt work.

The full code is in this link on github: https://github.com/AndreLuis117/ondm-frameworks-experiment/tree/master/hibernateOGM/neo4j_hibernateOGM

In case someone want to look the dependecies.

The script that i have use do create the docker container is:

docker run `
--name testneo4j `
-p7474:7474 -p7687:7687 `
-d `
-v $HOME/neo4j/data:/data `
-v $HOME/neo4j/logs:/logs `
-v $HOME/neo4j/import:/var/lib/neo4j/import `
-v $HOME/neo4j/plugins:/plugins `
--env NEO4J_AUTH=neo4j/test `
--env NEO4J_dbms_connector_https_advertised__address="localhost:7473" `
--env NEO4J_dbms_connector_http_advertised__address="localhost:7474" `
--env NEO4J_dbms_connector_bolt_advertised__address="localhost:7687" `
neo4j:latest

Can someone please help me? Has anyone here managed to implement hibernate ogm with neo4j using a remote server? Someone have a example of this implementation?


Solution

  • Hibernate OGM is only compatible with Neo4j 3.x at the time of writing.

    Neo4j 3.5 is a Long-Term Support version, so you should be able to start a 3.5.x Docker container and connect to it with your application.