Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neo4J fails to find entities in executable archives (BOOT-INF/classes and WEB-INF/classes) #6709

Closed
xenoterracide opened this issue Aug 21, 2016 · 24 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@xenoterracide
Copy link
Contributor

xenoterracide commented Aug 21, 2016

nothing to do with jackson but using that repo https://github.com/xenoterracide/jacksonconfig/tree/serializable again, this time branch serializable. In order for this problem to occur you have to connect to a standalone neo4j server.

docker run -it --rm -p 7474:7474 -p7687:7687  --name neo4j neo4j:3.0

should work, but ip address may vary, you'll have to go to http://dockerip:7474 and set the password, to the one I committed or whatever.

to start run the app in an IDE... and run the following http, just to prove that the app does work

curl -X POST -H "Content-Type: application/json" -d '{"name":"Hello Kitty"}' http://localhost:8080/myEntities -v                             slave-vi
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /myEntities HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.50.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 22
> 
* upload completely sent off: 22 out of 22 bytes
< HTTP/1.1 201 
< Location: http://localhost:8080/myEntities/10
< Content-Type: application/hal+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sun, 21 Aug 2016 07:37:03 GMT
< 
{
  "name" : "Hello Kitty",
  "new" : true,
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/myEntities/10"
    },
    "myEntity" : {
      "href" : "http://localhost:8080/myEntities/10"
    }
  }
* Connection #0 to host localhost left intact
}

you'll note it says 10 here, it looks like it is persisting the neo4j entites it's just blowing up before response.

Then package mvn clean && mvn package and start the jar java -jar target/jacksonconfig-1.0-SNAPSHOT.jar

curl -X POST -H "Content-Type: application/json" -d '{"name":"Hello Kitty"}' http://localhost:8080/myEntities -v                             slave-vi
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> POST /myEntities HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.50.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 22
> 
* upload completely sent off: 22 out of 22 bytes
< HTTP/1.1 500 
< Content-Type: application/hal+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sun, 21 Aug 2016 07:51:12 GMT
< Connection: close
< 
* Closing connection 0
{"cause":null,"message":"Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"}

Here's the stacktrace.

2016-08-21 02:51:12.478  WARN 24243 --- [nio-8080-exec-1] org.neo4j.ogm.session.Neo4jSession       : Thread 22: com.xenoterracide.MyEntity is not an instance of a persistable class
2016-08-21 02:51:12.491 ERROR 24243 --- [nio-8080-exec-1] o.s.d.r.w.RepositoryRestExceptionHandler : Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable

java.lang.IllegalArgumentException: Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable
        at org.springframework.util.Assert.isInstanceOf(Assert.java:346) ~[spring-core-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.data.rest.webmvc.support.RepositoryEntityLinks.linkToSingleResource(RepositoryEntityLinks.java:135) ~[spring-data-rest-webmvc-2.5.2.RELEASE.jar!/:na]
        at org.springframework.data.rest.core.support.DefaultSelfLinkProvider.createSelfLinkFor(DefaultSelfLinkProvider.java:70) ~[spring-data-rest-core-2.5.2.RELEASE.jar!/:na]
        at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:99) ~[spring-data-rest-webmvc-2.5.2.RELEASE.jar!/:na]
        at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:76) ~[spring-data-rest-webmvc-2.5.2.RELEASE.jar!/:na]
        at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toFullResource(PersistentEntityResourceAssembler.java:67) ~[spring-data-rest-webmvc-2.5.2.RELEASE.jar!/:na]
        at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:504) ~[spring-data-rest-webmvc-2.5.2.RELEASE.jar!/:na]
        at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:275) ~[spring-data-rest-webmvc-2.5.2.RELEASE.jar!/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.4.jar!/:8.5.4]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]

The issue is perplexing because it only happens when you've packaged the thing, and only with the http protocol (I Say only but I haven't enabled bolt yet).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 21, 2016
@philwebb
Copy link
Member

Have you got a link to the GitHub project? I guess it's one from a bug that you previously raised.

@xenoterracide
Copy link
Contributor Author

whoops I thought I had pasted that when I wrote this, updated

@wilkinsona wilkinsona self-assigned this Aug 21, 2016
@wilkinsona wilkinsona changed the title mvn plugin repackage goal changes behavior of app Neo4J fails to find entities in executable archives (BOOT-INF/classes and WEB-INF/classes) Aug 22, 2016
@wilkinsona
Copy link
Member

wilkinsona commented Aug 22, 2016

This problem can be reproduced more simply using our own Spring Data Neo4J sample. We've missed the problem thus far as our build doesn't test a packaged application (I've opened #6711 to address that).

Packaging and running spring-boot-sample-data-neo4j produces the following output:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::  (v1.4.1.BUILD-SNAPSHOT)

2016-08-22 09:07:41.627  INFO 93864 --- [           main] s.data.neo4j.SampleNeo4jApplication      : Starting SampleNeo4jApplication v1.4.1.BUILD-SNAPSHOT on aw-rmbp.home with PID 93864 (/Users/awilkinson/dev/spring/spring-boot/master/spring-boot-samples/spring-boot-sample-data-neo4j/target/spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar started by awilkinson in /Users/awilkinson/dev/spring/spring-boot/master/spring-boot-samples/spring-boot-sample-data-neo4j)
2016-08-22 09:07:41.631  INFO 93864 --- [           main] s.data.neo4j.SampleNeo4jApplication      : No active profile set, falling back to default profiles: default
2016-08-22 09:07:41.691  INFO 93864 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4ccabbaa: startup date [Mon Aug 22 09:07:41 BST 2016]; root of context hierarchy
2016-08-22 09:07:42.048  INFO 93864 --- [           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-22 09:07:42.247  INFO 93864 --- [           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-22 09:07:42.251  INFO 93864 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration' of type [class org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$$EnhancerBySpringCGLIB$$f526c23b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-08-22 09:07:42.265  INFO 93864 --- [           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-22 09:07:42.272  INFO 93864 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration' of type [class org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$SpringBootNeo4jConfiguration$$EnhancerBySpringCGLIB$$ae1ad738] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-08-22 09:07:42.272  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising PersistenceExceptionTranslationPostProcessor
2016-08-22 09:07:42.632  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Starting Post-processing phase
2016-08-22 09:07:42.632  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Building annotation class map
2016-08-22 09:07:42.632  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Building interface class map for 0 classes
2016-08-22 09:07:42.633  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Post-processing complete
2016-08-22 09:07:42.634  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : 0 classes loaded in 268 milliseconds
2016-08-22 09:07:42.637  INFO 93864 --- [           main] o.s.d.neo4j.mapping.Neo4jMappingContext  : Neo4jMappingContext initialisation completed
2016-08-22 09:07:42.809  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising Neo4jSession
2016-08-22 09:07:42.818  INFO 93864 --- [           main] org.neo4j.ogm.service.DriverService      : Using driver: org.neo4j.ogm.drivers.http.driver.HttpDriver
2016-08-22 09:07:42.833  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising PersistenceExceptionTranslator
2016-08-22 09:07:42.835  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising PersistenceExceptionTranslationInterceptor
2016-08-22 09:07:42.837  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Initialising Neo4jTransactionManager
2016-08-22 09:07:42.879  INFO 93864 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-08-22 09:07:42.894  WARN 93864 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: sample.data.neo4j.Customer is not a persistable class
2016-08-22 09:07:42.895  WARN 93864 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: sample.data.neo4j.Customer is not an instance of a persistable class
2016-08-22 09:07:42.895  WARN 93864 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: sample.data.neo4j.Customer is not an instance of a persistable class
Customers found with findAll():
-------------------------------
2016-08-22 09:07:42.899  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Intercepted exception
2016-08-22 09:07:42.900  INFO 93864 --- [           main] o.s.d.neo4j.config.Neo4jConfiguration    : Intercepted exception
2016-08-22 09:07:42.901  INFO 93864 --- [           main] utoConfigurationReportLoggingInitializer :

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


2016-08-22 09:07:42.912 ERROR 93864 --- [           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.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:782) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:769) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    at sample.data.neo4j.SampleNeo4jApplication.main(SampleNeo4jApplication.java:59) [classes!/:1.4.1.BUILD-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar:1.4.1.BUILD-SNAPSHOT]
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:113) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at org.neo4j.ogm.session.Neo4jSession.loadAll(Neo4jSession.java:157) ~[neo4j-ogm-core-2.0.4.jar!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at com.sun.proxy.$Proxy38.loadAll(Unknown Source) ~[na:na]
    at org.springframework.data.neo4j.template.Neo4jTemplate.loadAll(Neo4jTemplate.java:100) ~[spring-data-neo4j-4.1.3.BUILD-SNAPSHOT.jar!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at com.sun.proxy.$Proxy41.loadAll(Unknown Source) ~[na:na]
    at org.springframework.data.neo4j.repository.GraphRepositoryImpl.findAll(GraphRepositoryImpl.java:125) ~[spring-data-neo4j-4.1.3.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.data.neo4j.repository.GraphRepositoryImpl.findAll(GraphRepositoryImpl.java:120) ~[spring-data-neo4j-4.1.3.BUILD-SNAPSHOT.jar!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_74]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_74]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_74]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_74]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:503) ~[spring-data-commons-1.12.3.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:488) ~[spring-data-commons-1.12.3.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) ~[spring-data-commons-1.12.3.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) ~[spring-data-commons-1.12.3.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280) ~[spring-tx-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.3.BUILD-SNAPSHOT.jar!/:4.3.3.BUILD-SNAPSHOT]
    at com.sun.proxy.$Proxy43.findAll(Unknown Source) ~[na:na]
    at sample.data.neo4j.SampleNeo4jApplication.run(SampleNeo4jApplication.java:41) [classes!/:1.4.1.BUILD-SNAPSHOT]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
    ... 14 common frames omitted

2016-08-22 09:07:42.937  INFO 93864 --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4ccabbaa: startup date [Mon Aug 22 09:07:41 BST 2016]; root of context hierarchy
2016-08-22 09:07:42.938  INFO 93864 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2016-08-22 09:07:42.938  INFO 93864 --- [           main] o.n.ogm.drivers.http.driver.HttpDriver   : Shutting down Http driver org.neo4j.ogm.drivers.http.driver.HttpDriver@27a5f880

There are a couple of signs that things have gone wrong before they actually do:

2016-08-22 09:07:42.632  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Starting Post-processing phase
2016-08-22 09:07:42.632  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Building annotation class map
2016-08-22 09:07:42.632  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Building interface class map for 0 classes
2016-08-22 09:07:42.633  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : Post-processing complete
2016-08-22 09:07:42.634  INFO 93864 --- [           main] o.neo4j.ogm.metadata.ClassFileProcessor  : 0 classes loaded in 268 milliseconds
2016-08-22 09:07:42.637  INFO 93864 --- [           main] o.s.d.neo4j.mapping.Neo4jMappingContext  : Neo4jMappingContext initialisation completed
2016-08-22 09:07:42.894  WARN 93864 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: sample.data.neo4j.Customer is not a persistable class
2016-08-22 09:07:42.895  WARN 93864 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: sample.data.neo4j.Customer is not an instance of a persistable class
2016-08-22 09:07:42.895  WARN 93864 --- [           main] org.neo4j.ogm.session.Neo4jSession       : Thread 1: sample.data.neo4j.Customer is not an instance of a persistable class

Things start to go wrong in Neo4J's ClassUtils.getUniqueClasspathElements(List<String>) which assumes that a resource's URL can be mapped to a File. In the case of the sample as call is made to ClassLoader.getResources("sample/data/neo4j") producing the URL jar:file:/…/spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar!/BOOT-INF/classes!/sample/data/neo4j. Neo4J then resolves this to the spring-boot-sample-data-neo4j-1.4.1.BUILD-SNAPSHOT.jar file.

Neo4J now scans this entire jar file, including processing the contents of any nested archives that it finds within it. Whenever it encounters a class file entry it only processes it if it's path matches one of the packages that it is scanning. In the case of the sample, it's looking for entries with a path that starts with /sample/data/neo4j. The classes in /BOOT-INF/classes (or /WEB-INF/classes in the case of an executable war) don't match because Neo4J considers their paths to be /BOOT-INF/casses/sample/data/neo4j/… as it's ignored the fact that the /BOOT-INF/classes within the jar is the root of the classpath.

There are a couple of workarounds for the problem.

One is to package any entries that Neo4J needs to find in a nested jar. This will lead to Neo4J performing a lot of scanning (everything in the fat jar/war and its nested entries) but it'll find the entities as their location will be as expected relative to the root of the archive that contains them. The excess scanning can be avoiding by marking the nested archive as requiring unpacking at runtime.

Another workaround, and this is horrid, is to tell Neo4J to scan both the package that you want it to scan and that package prefixed with BOOT-INF.classes.. In the case of our sample that would be:

@EntityScan({ "sample.data.neo4j", "BOOT-INF.classes.sample.data.neo4j" })

The first package gets the right URL back from the ClassLoader. The second "package" then means that the path of the entry in the jar matches the path of the "package" that's being scanned.

I'm not sure that there's anything we can do to fix this in Spring Boot. Neo4j does provide a plug point but I don't think it helps. When it resolves a URL returned by the ClassLoader into a File, it does so using ResourceResolvers loaded via ServiceLoader.load. The default implementation handles jar and file URLs. To use this plug point, we'd need to implement one for jar URLs that automatically extracted the directory or nested jar identified by the URL to a temporary location on the file system. However, this would only work if we could guarantee that it would be loaded before Neo4j's default implementation and I don't think that's possible all of the time.

In short, I think we need to log an issue with Neo4j, and document the workaround of packaging entities in a nested archive and marking them for unpacking. We also need to figure out what to do with the sample as it's misleading at the moment.

@wilkinsona
Copy link
Member

I'm pretty sure that this problem isn't specific to Spring Boot. For example, it will also affect a war file deployed to Tomcat with unpackWars set to false.

@wilkinsona
Copy link
Member

@vince-bickers Is my analysis above accurate, or is there something that we could do in Boot to plug something in to Neo4j so that it can scan one of our executable archives?

@wilkinsona wilkinsona added type: bug A general bug for: team-attention An issue we'd like other members of the team to review and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 22, 2016
@xenoterracide
Copy link
Contributor Author

xenoterracide commented Aug 22, 2016

I'm kind of in favor of this @EntityScan({ "sample.data.neo4j", "BOOT-INF.classes.sample.data.neo4j" }) because it's less work on framework consumer, even if it's arguably slower.

If what I had to do with Spring Data Neo4j 4.0 is any indication, this classpath scanning is registered with a factory, so however the EntityScan is processed you could also process and add the additional classpath.

it may be slower for now but seems less error prone and less complicated for the user.

That said given the number of other problems with not doing package by layer currently... this is just another indication to do package my layer, and making that layer a module.... or could do both and allow the additional classpath scanning to to be disable via some configuration.

@philwebb
Copy link
Member

/cc @kbastani

@arvind-das
Copy link

Had the same issue while running with jar package . Workaround with
@EntityScan({ "com.kairos.domains", "BOOT-INF.classes.com.kairos.domains" }) works . A correct solution is needed. In development mode, everything just works fine .

@ssherwood
Copy link

The work around does not seem to work for me when upgrading to Spring Boot 1.4.1. In 1.4.1 I get the error:

{ cause: null, message: "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable" }

If I revert back to 1.4.0, it works.

@snicoll
Copy link
Member

snicoll commented Oct 4, 2016

@ssherwood 1.4.1 has a bug fix upgrade of Neo4j that leads to quite a lot of breakages. Can you test with 1.4.1, overriding the neo4j-ogm.version to 2.0.4? See also #7012

@aricooperman
Copy link

I am running the neo4j data rest guide (https://spring.io/guides/gs/accessing-neo4j-data-rest/) and I was running into this issue. I downgraded neo4j-ogm to 2.0.4 but no affect, I then downgraded boot to 1.4.0 (from 1.4.1) and the issue went away (no need for the EntityScan)

@aricooperman
Copy link

Follow up... I just listed my DB after I stopped getting the "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable" error repeatedly and every attempt actually save the entity so the error is happening after persisting.

@xenoterracide
Copy link
Contributor Author

@aricooperman hmm... the rest guide shouldn't produce this issue as this cause only exists if you have a nested jar... I've seen this error in other cases though, any chance you can share the code that you've written? I can also try checking that guide later (after work) just to be sure.

@aricooperman
Copy link

I did not update any of the code of the guide except to add the neo4j-ogm version override (ext['neo4j-ogm.version'] = '2.0.4'), which I have since removed and tested and found that this is not necessary (probably because Boot 1.4.0 already has this one choosen) and set the Spring Boot gradle plugin to 1.4.0-RELEASE -> classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")

@ssherwood
Copy link

ssherwood commented Oct 4, 2016

@snicoll I set it back to 2.0.4 (1.4.1 has it at 2.0.5) and am still seeing the same error.

I'm setting the version via Maven (and I'm not using embedded neo4j):

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-http-driver</artifactId>
        <version>2.0.4</version>
    </dependency>

I've posted my repo: https://github.com/ssherwood/demo-neo4j

@vince-bickers
Copy link

vince-bickers commented Oct 4, 2016

The sdn4-university project on Github attempts to maintain a working version of a Spring Boot/SDN project, using the latest releases of Spring Boot, Spring Data and where appropriate any snapshot releases of the Neo4j OGM.

Maven dependencies can go seriously screwy when a driver version is required that is different from the OGM version packaged with the Spring Boot starter for Neo4j. In these situations, it is not sufficient to simply use the new driver. You must also include all the other OGM dependencies as well.

The current version on the master branch of sdn4-university supports spring-boot packaged jar and wars. You do not need to specify additional classpath entries such as BOOT-INF/classes. The driver selection mechanism also works correctly, correcting the bug that was introduced in 2.0.5. The README contains additional instructions for creating a packaged jar/war. Because these fixes required changes to the OGM (2.1.0-SNAPSHOT), the project pom adds dependencies to all the OGM jars.

https://github.com/neo4j-examples/sdn4-university

@xenoterracide
Copy link
Contributor Author

xenoterracide commented Oct 4, 2016

@sshcherbakov so that looks like not exactly what we meant, try this

<properties>
    <neo4j-ogm.version>2.0.4</neo4j-ogm.version>
</properties>

that's from my platform which extends spring platform, if you need further code samples for maven, or a more complete context.
https://bitbucket.org/xenworks/platform/src/f0012bf85acd31b6724c5421521aa5170fbdc70d/pom.xml?fileviewer=file-view-default#pom.xml-31

@ssherwood
Copy link

@xenoterracide Not sure if you were trying to link to me or not.

I updated my project with the properties override for Maven as you described and still see the same error behavior with Boot 1.4.1 and neo4j-ogm 2.0.4 (rolling back to 1.4.0 works as expected): https://github.com/ssherwood/demo-neo4j

@xenoterracide
Copy link
Contributor Author

I dug into this a little bit, it's possible I'm not noticing this error because my app currently is only making use of custom controllers... firstly this is a terrible error message, the object being passed to this method is Book.

java.lang.IllegalArgumentException: Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable
    at org.springframework.util.Assert.isInstanceOf(Assert.java:346) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.data.rest.webmvc.support.RepositoryEntityLinks.linkToSingleResource(RepositoryEntityLinks.java:135) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
    at org.springframework.data.rest.core.support.DefaultSelfLinkProvider.createSelfLinkFor(DefaultSelfLinkProvider.java:70) ~[spring-data-rest-core-2.5.3.RELEASE.jar:na]
    at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:99) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
    at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:76) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
    at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toFullResource(PersistentEntityResourceAssembler.java:67) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
    at org.springframework.data.rest.webmvc.RepositoryEntityController.createAndReturn(RepositoryEntityController.java:504) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
    at org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(RepositoryEntityController.java:275) ~[spring-data-rest-webmvc-2.5.3.RELEASE.jar:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105) [spring-boot-actuator-1.4.1.RELEASE.jar:1.4.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:107) [spring-boot-actuator-1.4.1.RELEASE.jar:1.4.1.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.5.jar:8.5.5]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]

@xenoterracide
Copy link
Contributor Author

xenoterracide commented Oct 4, 2016

I think the issues is not in this block of code, but what it delegates to, because it returns null, thus failing to find the id, I've noticed that for the entity, which is a NodeEntity, that it has the id property set to null

       ...DefaultSelfLinkProvider...
    private Object getResourceId(Object instance) {

        Class<? extends Object> instanceType = instance.getClass();

        EntityLookup<Object> lookup = (EntityLookup<Object>) lookups.getPluginFor(instanceType);

        if (lookup != null) {
            return lookup.getResourceIdentifier(instance);
        }

        PersistentEntity<?, ?> entity = entities.getPersistentEntity(instanceType);

        if (entity == null) {
            throw new IllegalArgumentException(
                    String.format("Cannot create self link for %s! No persistent entity found!", instanceType));
        }

        return entity.getIdentifierAccessor(instance).getIdentifier();
    }

in the previous version entity.idProperty was set to this (Intellij representation) @org.neo4j.ogm.annotation.GraphId(name=) private java.lang.Long com.example.domain.Book.id

@xenoterracide
Copy link
Contributor Author

found it 90% sure because it doesn't pass this if statement Neo4jPersistentProperty line 77, @ssherwood what' you're seeing is a regression in Spring Data Neo4j, it's unrelated to this bug even though the same exception message is thrown.

https://github.com/spring-projects/spring-data-neo4j/blob/4.1.x/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/mapping/Neo4jPersistentProperty.java#L77

        if (!simpleTypeHolder.isSimpleType(Enum.class) || owner.getType().isEnum()) { //enums don't need an ID
            this.isIdProperty = resolveWhetherIdProperty(owningClassInfo, field);
        }

perhaps @luanne could enlighten us

@snicoll
Copy link
Member

snicoll commented Oct 5, 2016

You should continue this discussion in the Spring Data Neo4j tracker.

@kbastani
Copy link

See spring-projects/spring-data-neo4j#366 (comment) for the latest status of this issue.

@wilkinsona wilkinsona added this to the 1.5.0 M1 milestone Nov 15, 2016
@wilkinsona wilkinsona self-assigned this Nov 15, 2016
@wilkinsona
Copy link
Member

af4ca7c has taken care of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

10 participants