[Solved] Can't open a session with Neo4j OGM

Hi,
I can't open a session with neo4j ogm, I can't figure why.
I'm following this :
https://neo4j.com/docs/ogm-manual/current/tutorial/
I got the following error :

15:35:15.265 [main] DEBUG org.neo4j.ogm.metadata.DomainInfo - Processing: com.test.domain.BaseNode -> java.lang.Object
15:35:15.268 [main] INFO org.neo4j.ogm.metadata.DomainInfo - Starting Post-processing phase
15:35:15.268 [main] INFO org.neo4j.ogm.metadata.DomainInfo - Building annotation class map
15:35:15.268 [main] INFO org.neo4j.ogm.metadata.DomainInfo - Building interface class map for 1 classes
15:35:15.268 [main] DEBUG org.neo4j.ogm.metadata.DomainInfo -  - BaseNode implements 0 interfaces
15:35:15.268 [main] DEBUG org.neo4j.ogm.metadata.DomainInfo - Post-processing: com.test.domain.BaseNode
15:35:15.268 [main] DEBUG org.neo4j.ogm.metadata.DomainInfo - Checking for @Transient classes....
15:35:15.268 [main] DEBUG org.neo4j.ogm.metadata.DomainInfo - Registering converters and deregistering transient fields and methods....
15:35:15.287 [main] INFO org.neo4j.ogm.metadata.DomainInfo - Post-processing complete
Exception in thread "main" java.lang.ExceptionInInitializerError
        at com.test.App.main(App.java:30)
Caused by: java.lang.UnsupportedOperationException
        at org.neo4j.ogm.driver.Driver.setTransactionManager(Driver.java:82)
        at org.neo4j.ogm.session.transaction.DefaultTransactionManager.<init>(DefaultTransactionManager.java:39)
        at org.neo4j.ogm.session.Neo4jSession.<init>(Neo4jSession.java:107)
        at org.neo4j.ogm.session.Neo4jSession.<init>(Neo4jSession.java:114)
        at org.neo4j.ogm.session.SessionFactory.openSession(SessionFactory.java:130)
        at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:84)
        at com.test.Neo4jSessionFactory.<clinit>(Neo4jSessionFactory.java:16)
        ... 1 more

main :

public class App {
  public static void main(String[] args) 
  {
    Session session = Neo4jSessionFactory.getInstance().getNeo4jSession();    
  }
}

Neo4jSessionFactory :

public class Neo4jSessionFactory {

  private static ClasspathConfigurationSource props = new ClasspathConfigurationSource("app.properties");
  private static Configuration configuration = new Configuration.Builder(props).build();

  private static SessionFactory sessionFactory = new SessionFactory(configuration
  , "com.test.domain");
  private static Neo4jSessionFactory factory = new Neo4jSessionFactory();

  public static Neo4jSessionFactory getInstance() {
    return factory;
  }

  private Neo4jSessionFactory() {
  }

  public Session getNeo4jSession() {
    return sessionFactory.openSession();
  }
}

BaseNode:

@NodeEntity
public class BaseNode{
  private String name;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }
}

app.properties :

URI=bolt://localhost
username=neo4j
password=neo4j

pom.xml:

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j-ogm-core</artifactId>
      <version>3.1.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j-ogm-bolt-driver</artifactId>
      <version>3.1.2</version>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

My neo4j databse is accessible on localhost 7474 and I double checked the password. Any help is welcomed.

Can you check your dependencies again? The exception you are seeing comes from a Neo4j-OGM version at least 3.1.8.
It has nothing to do with wrong credentials or similar but looks to me like a version mismatch between the neo4j-ogm-core and the neo4j-ogm-bolt-driver (and the neo4j-ogm-api that comes as a transitive dependency from the bolt-driver).

God I feel so stupid. I was indeed importing packages from another project where I use ogm version 3.1.13.
I lost my afternoon but you saved my evening...

1 Like