We're updating the issue view to help you get more done. 

org.hibernate.ogm.datastore.neo4j.Neo4jDialect does not work with spring

Description

I get the following error which prevents the application to run

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 01:03:07.488 [main] INFO o.s.o.j.LocalContainerEntityManagerFactoryBean - Building JPA container EntityManagerFactory for persistence unit '60Capital-neo4j-ejbPU' .01:03:07.505 [main] INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [ name: 60Capital-neo4j-ejbPU ...] .01:03:07.584 [main] INFO org.hibernate.Version - HHH000412: Hibernate Core {5.0.9.Final} .01:03:07.586 [main] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found .01:03:07.587 [main] INFO org.hibernate.cfg.Environment - HHH000021: Bytecode provider name : javassist .01:03:07.640 [main] INFO o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.1.Final} .01:03:10.566 [main] WARN o.h.e.j.e.i.JdbcEnvironmentInitiator - HHH000342: Could not obtain connection to query metadata : Could not instantiate named strategy class [org.hibernate.ogm.datastore.neo4j.Neo4jDialect] .01:03:10.570 [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.dcubedev.config.Neo4jJpaPersistenceContext: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in com.dcubedev.config.Neo4jJpaPersistenceContext: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84) at com.dcubedev.neo4j_sdn.App.main(App.java:183) Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:244) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:208) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:217) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:189) 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:847) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874) at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ... 11 more Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Could not instantiate named strategy class [org.hibernate.ogm.datastore.neo4j.Neo4jDialect] at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:170) at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:126) at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:120) at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:74) at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:51) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) 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:234) ... 27 more Caused by: java.lang.InstantiationException: org.hibernate.ogm.datastore.neo4j.Neo4jDialect at java.lang.Class.newInstance(Unknown Source) at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:166) ... 35 more Caused by: java.lang.NoSuchMethodException: org.hibernate.ogm.datastore.neo4j.Neo4jDialect.<init>() at java.lang.Class.getConstructor0(Unknown Source) ... 37 more

Here is the code to create emf

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 private Properties hibProperties() { Properties properties = new Properties(); //properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, "org.hibernate.ogm.datastore.neo4j.HttpNeo4jDialect"); // new as of 5.1.0.final properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, "org.hibernate.ogm.datastore.neo4j.Neo4jDialect"); //properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT_NEO4J)); properties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL)); return properties; } @Bean public DataSource dataSource() { System.out.println("Neo4jJpaPersistenceContext::dataSource() Environment env: " + env); // capital60 // matalan // mysql:mysql-connector-java:jar DriverManagerDataSource dataSource = new DriverManagerDataSource("jdbc:neo4j:http://localhost:7474", "stephen", "demo2017"); dataSource.setDriverClassName("org.neo4j.jdbc.http.HttpDriver"); //dataSource.setUrl("jdbc:neo4j:http://localhost:7474"); //dataSource.setUsername("stephen"); //dataSource.setPassword("demo2017"); return dataSource; } @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { //String persistenceXmlLocation = "C:/workspace/dcube-groups/dcube-groups/src/main/resources/persistence.xml"; String persistenceXmlLocation = "persistence.xml"; String persistenceUnitName = "60Capital-neo4j-ejbPU"; System.out.println("Neo4jJpaPersistenceContext::entityManagerFactory() ... " ); System.out.println("Neo4jJpaPersistenceContext::entityManagerFactory() Environment env: " + env); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); System.out.println("Neo4jJpaPersistenceContext::entityManagerFactory() vendorAdapter: " + vendorAdapter); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); System.out.println("Neo4jJpaPersistenceContext::entityManagerFactory() LocalContainerEntityManagerFactoryBean factory: " + factory); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.dcubedev.domain.neo4j"); factory.setDataSource(dataSource()); factory.setPersistenceXmlLocation(persistenceXmlLocation); factory.setPersistenceUnitName(persistenceUnitName); factory.setJpaProperties(hibProperties()); System.out.println("Neo4jJpaPersistenceContext::entityManagerFactory() factory.getObject(): " + factory.getObject()); return factory; } @Bean public PlatformTransactionManager transactionManager() { JpaTransactionManager txManager = new JpaTransactionManager(); txManager.setEntityManagerFactory(entityManagerFactory().getObject()); //txManager.setEntityManagerFactory(entityManagerFactory()); return txManager; }

Here is persistence.xml

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 <persistence-unit name="60Capital-neo4j-ejbPU" transaction-type="RESOURCE_LOCAL"> <!-- Use the Hibernate OGM provider: configuration will be transparent --> <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="hibernate.ogm.datastore.provider" value="neo4j_http"/> <property name="hibernate.connection.driver_class" value="org.neo4j.jdbc.http.HttpDriver" /> <property name="hibernate.connection.url" value="jdbc:neo4j:http://localhost:7474" /> <property name="hibernate.ogm.datastore.host" value="localhost:7474" /> <property name="hibernate.ogm.datastore.username" value="neo4j" /> <property name="hibernate.ogm.datastore.password" value="demo2017" /> <property name="hibernate.ogm.neo4j.database_path" value="C:/neo4j/database/tutorial" /> <!-- http://docs.jboss.org/hibernate/core/4.0/javadocs/org/hibernate/service/jta/platform/internal/package-summary.html <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform" /> --> </properties> </persistence-unit>

Maven

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>4.3.6.RELEASE</spring.version> <mysql.version>5.1.40</mysql.version> <jackson-core-version>2.8.3</jackson-core-version> <release-train>Ingalls-RELEASE</release-train> <neo4j.version>3.1.1</neo4j.version> <logback.version>1.2.1</logback.version> <jcloverslf4j.version>1.7.23</jcloverslf4j.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-framework-bom</artifactId> <version>${spring.version}</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain</artifactId> <version>${release-train}</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.hibernate.ogm</groupId> <artifactId>hibernate-ogm-bom</artifactId> <version>5.1.4.Final</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- hibernate --> <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> <!-- Hibernate OGM hibernate-ogm-neo4j module; pulls in the OGM core module --> <dependency> <groupId>org.hibernate.ogm</groupId> <artifactId>hibernate-ogm-neo4j</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> </dependency> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-kernel</artifactId> <version>${neo4j.version}</version> </dependency> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-jdbc-http</artifactId> <version>3.0.1</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> --> <!-- standard APIs dependencies - provided in a Java EE container --> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.1-api</artifactId> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> </dependency>

Environment

Windows 10, Neo4j 3.1.1, hibernate-ogm-bom 5.1.4.Final

Status

Assignee

Davide D'Alto

Reporter

kwadwo boahen

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

5.1.0.Final

Priority

Major