spring-guides / gs-accessing-data-neo4j

Accessing Data with Neo4j :: Learn how to persist objects and relationships in Neo4j's NoSQL data store.
http://spring.io/guides/gs/accessing-data-neo4j/
Apache License 2.0
29 stars 49 forks source link

Example fails with MetaData.entityType throwing NPE (hello.Person is not an instance of a persistable class) #19

Open czhifa opened 8 years ago

czhifa commented 8 years ago

java -jar target/gs-accessing-data-neo4j-0.1.0.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.0.RELEASE)

2016-08-30 23:33:01.259  INFO 41775 --- [           main] hello.Application                        : Starting Application v0.1.0 on CHEFRANK-M-5FEG with PID 41775 (/private/tmp/gs-accessing-data-neo4j/complete/target/gs-accessing-data-neo4j-0.1.0.jar started by frank in /private/tmp/gs-accessing-data-neo4j/complete)
2016-08-30 23:33:01.264  INFO 41775 --- [           main] hello.Application                        : No active profile set, falling back to default profiles: default
2016-08-30 23:33:01.339  INFO 41775 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4459eb14: startup date [Tue Aug 30 23:33:01 CST 2016]; root of context hierarchy
2016-08-30 23:33:01.830  INFO 41775 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'persistenceExceptionTranslationPostProcessor' with a different definition: replacing [Root bean: class [org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=persistenceExceptionTranslationPostProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration; factoryMethodName=persistenceExceptionTranslationPostProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration.class]]
2016-08-30 23:33:02.120  INFO 41775 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.data.neo4j-org.springframework.boot.autoconfigure.data.neo4j.Neo4jProperties' of type [class org.springframework.boot.autoconfigure.data.neo4j.Neo4jProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-08-30 23:33:02.126  INFO 41775 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration' of type [class org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$$EnhancerBySpringCGLIB$$57cb4932] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-08-30 23:33:02.141  INFO 41775 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configuration' of type [class org.neo4j.ogm.config.Configuration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-08-30 23:33:02.147  INFO 41775 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration' of type [class org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration$$EnhancerBySpringCGLIB$$10bf5e2f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-08-30 23:33:02.148  INFO 41775 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising PersistenceExceptionTranslationPostProcessor
2016-08-30 23:33:03.490  INFO 41775 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Starting Post-processing phase
2016-08-30 23:33:03.490  INFO 41775 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Building annotation class map
2016-08-30 23:33:03.491  INFO 41775 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Building interface class map for 0 classes
2016-08-30 23:33:03.493  INFO 41775 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Post-processing complete
2016-08-30 23:33:03.493  INFO 41775 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : 0 classes loaded in 1209 milliseconds
2016-08-30 23:33:03.496  INFO 41775 --- [           main] o.s.d.neo4j.mapping.Neo4jMappingContext  : Neo4jMappingContext initialisation completed
2016-08-30 23:33:03.785  INFO 41775 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising Neo4jSession
2016-08-30 23:33:03.795  WARN 41775 --- [           main] org.neo4j.ogm.service.DriverService      : org.neo4j.ogm.driver.Driver: Provider org.neo4j.ogm.drivers.bolt.driver.BoltDriver not found, reason: null
2016-08-30 23:33:03.797  INFO 41775 --- [           main] org.neo4j.ogm.service.DriverService      : Using driver: org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver
2016-08-30 23:33:03.810  WARN 41775 --- [           main] o.n.o.d.embedded.driver.EmbeddedDriver   : Creating temporary file store: file:/var/folders/0n/tqr1v7m908xcn7b741zxb8gr0000gn/T/neo4j.db5992117362745361963/
2016-08-30 23:33:05.078  INFO 41775 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising PersistenceExceptionTranslator
2016-08-30 23:33:05.081  INFO 41775 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising PersistenceExceptionTranslationInterceptor
2016-08-30 23:33:05.084  INFO 41775 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising Neo4jTransactionManager
2016-08-30 23:33:05.131  INFO 41775 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-08-30 23:33:05.144  INFO 41775 --- [           main] hello.Application                        : Before linking up with Neo4j...
2016-08-30 23:33:05.150  INFO 41775 --- [           main] hello.Application                        :    Greg's teammates => []
2016-08-30 23:33:05.151  INFO 41775 --- [           main] hello.Application                        :    Roy's teammates => []
2016-08-30 23:33:05.151  INFO 41775 --- [           main] hello.Application                        :    Craig's teammates => []
2016-08-30 23:33:05.162  WARN 41775 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: hello.Person is not an instance of a persistable class
2016-08-30 23:33:05.162  WARN 41775 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: hello.Person is not an instance of a persistable class
2016-08-30 23:33:05.162  WARN 41775 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: hello.Person is not an instance of a persistable class
2016-08-30 23:33:05.166  INFO 41775 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Intercepted exception
2016-08-30 23:33:05.168  INFO 41775 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report enable debug logging (start with --debug)

2016-08-30 23:33:05.184 ERROR 41775 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:801) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:782) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:769) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    at hello.Application.main(Application.java:23) [classes!/:0.1.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_20]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_20]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_20]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_20]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [gs-accessing-data-neo4j-0.1.0.jar:0.1.0]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [gs-accessing-data-neo4j-0.1.0.jar:0.1.0]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [gs-accessing-data-neo4j-0.1.0.jar:0.1.0]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [gs-accessing-data-neo4j-0.1.0.jar:0.1.0]
Caused by: java.lang.NullPointerException: null
    at org.neo4j.ogm.MetaData.entityType(MetaData.java:280) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at org.neo4j.ogm.session.Neo4jSession.entityType(Neo4jSession.java:486) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at org.neo4j.ogm.session.delegates.LoadByTypeDelegate.loadAll(LoadByTypeDelegate.java:60) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at org.neo4j.ogm.session.delegates.LoadByTypeDelegate.loadAll(LoadByTypeDelegate.java:158) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at org.neo4j.ogm.session.Neo4jSession.loadAll(Neo4jSession.java:232) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_20]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_20]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_20]
    at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_20]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at com.sun.proxy.$Proxy39.loadAll(Unknown Source) ~[na:na]
    at org.springframework.data.neo4j.repository.query.derived.DerivedGraphRepositoryQuery.execute(DerivedGraphRepositoryQuery.java:65) ~[spring-data-neo4j-4.1.2.RELEASE.jar!/:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482) ~[spring-data-commons-1.12.2.RELEASE.jar!/:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) ~[spring-data-commons-1.12.2.RELEASE.jar!/:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) ~[spring-data-commons-1.12.2.RELEASE.jar!/:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280) ~[spring-tx-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
    at com.sun.proxy.$Proxy44.findByName(Unknown Source) ~[na:na]
    at hello.Application.lambda$demo$3(Application.java:44) [classes!/:0.1.0]
    at hello.Application$$Lambda$7/724125922.run(Unknown Source) ~[na:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) [spring-boot-1.4.0.RELEASE.jar!/:1.4.0.RELEASE]
    ... 14 common frames omitted
mp911de commented 8 years ago

That's a bug in neo4j, see https://github.com/spring-projects/spring-boot/issues/6709. There are a couple of workarounds. The easiest fix for now is starting that project in your IDE. Another one (not nice) is adding

@EntityScan({ "hello", "BOOT-INF.classes.hello" })

to hello.Application.

czhifa commented 8 years ago

Great! Many thanks for your so prompt response. šŸ‘ Will verify your guide ASAP.

czhifa commented 8 years ago

Excellent! It works as per your solution.

mp911de commented 8 years ago

Let's keep this one open until we have a durable solution.

zouma45 commented 7 years ago

i got the same Error, i think there is a visibility issue but i don't know exactly why there is a problem. for me, it works in a package, and doesn't work in another package. I don't know if this helps.