-
Notifications
You must be signed in to change notification settings - Fork 40.5k
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
Comments
Have you got a link to the GitHub project? I guess it's one from a bug that you previously raised. |
whoops I thought I had pasted that when I wrote this, updated |
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
There are a couple of signs that things have gone wrong before they actually do:
Things start to go wrong in Neo4J's 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 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 @EntityScan({ "sample.data.neo4j", "BOOT-INF.classes.sample.data.neo4j" }) The first package gets the right URL back from the 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 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. |
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 |
@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? |
I'm kind of in favor of this 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 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. |
/cc @kbastani |
Had the same issue while running with jar package . Workaround with |
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:
If I revert back to 1.4.0, it works. |
@ssherwood |
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) |
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. |
@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. |
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") |
@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):
I've posted my repo: https://github.com/ssherwood/demo-neo4j |
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. |
@sshcherbakov so that looks like not exactly what we meant, try this
that's from my platform which extends spring platform, if you need further code samples for maven, or a more complete context. |
@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 |
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
|
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
in the previous version |
found it 90% sure because it doesn't pass this if statement
perhaps @luanne could enlighten us |
You should continue this discussion in the Spring Data Neo4j tracker. |
See spring-projects/spring-data-neo4j#366 (comment) for the latest status of this issue. |
af4ca7c has taken care of this |
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.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
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 jarjava -jar target/jacksonconfig-1.0-SNAPSHOT.jar
Here's the stacktrace.
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).
The text was updated successfully, but these errors were encountered: