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

Id must be assignable to Serializable error with 4.1.3 #366

Closed
ssherwood opened this issue Oct 5, 2016 · 7 comments
Closed

Id must be assignable to Serializable error with 4.1.3 #366

ssherwood opened this issue Oct 5, 2016 · 7 comments
Labels
status: needs-investigation An issue that has been triaged but needs further investigation

Comments

@ssherwood
Copy link

Per previous conversation about this issue started here: spring-projects/spring-boot#6709

When upgrading to Spring Boot 1.4.1 our projects started generating errors:

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

Reverting back to Boot 1.4.0 reverted to expected behavior. It appears this is some kind of regression introduced in 4.1.3 as that is the default version in 1.4.1.

A simple project with the error is here: https://github.com/ssherwood/demo-neo4j

@mangrish
Copy link
Contributor

mangrish commented Oct 6, 2016

Hi @ssherwood.

I will take a look soon. In the mean time can you try 4.2.0.BUILD-SNAPSHOT and see if your problem persists. You can see an example on how to use the snapshot with Spring Boot 1.4.1 here: https://github.com/neo4j-examples/sdn4-university/tree/4.2.x.

@mangrish mangrish added the status: needs-investigation An issue that has been triaged but needs further investigation label Oct 6, 2016
@ssherwood
Copy link
Author

@mangrish I'm trying to emulate your work but I'm getting a new error:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.example.DemoNeo4jApplication]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/data/neo4j/config/Neo4jConfiguration.class] cannot be opened because it does not exist

I'm not sure what might be at issue (it might be my environment since I'm working behind a proxy and have to jump through hoops to get at SNAPSHOTS). I'll commit my code to https://github.com/ssherwood/demo-neo4j and try from home to be sure.

@vince-bickers
Copy link

@ssherwood Did you manage to resolve this problem?

@ssherwood
Copy link
Author

@vince-bickers No. I've tried a lot of things so far and have not had any succees unless I revert entirely back to Spring Boot 1.4.0. I'm doing these builds at home now and am running inside IntelliJ with a clean repo, so I can rule out a lot of environmental causes.

For me, the Ingalls-BUILD-SNAPSHOT seems to be missing the Neo4jConfiguration class:

java.io.FileNotFoundException: class path resource [org/springframework/data/neo4j/config/Neo4jConfiguration.class] cannot be opened because it does not exist

I noticed that the sdn4-university provides its own Neo4jConfiguration class which seems to be defeating the purpose of using Spring Boot's autoconfig approach. I suspect this is why your examples are not experiencing the same problem.

When I switch to Hopper-SR4, the config class returns and I can actually start up the application but the serialization error returns:

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

Interestingly, the nodes actually get created in Neo4j but I can view them with the Spring Data Rest interfaces.

@tigrou83
Copy link

tigrou83 commented Nov 9, 2016

I have the same problem than ssherwood with spring boot 1.4.2.RELEASE and spring-data-neo4j 4.2.0-SNAPSHOT:

org.springframework.beans.factory.BeanDefinitionStoreException: **Failed to process import candidates for configuration class [com.nagra.ml.sp.cpm.core.CpmNeo4jConfiguration]**; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/data/neo4j/config/Neo4jConfiguration.class] cannot be opened because it does not exist
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:541)
...
**Caused by: java.io.FileNotFoundException: class path resource [org/springframework/data/neo4j/config/Neo4jConfiguration.class] cannot be opened because it does not exist**
    at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:50)
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98)
    at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:89)
    at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:76)
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93)
    at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:633)
    at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getSuperClass(ConfigurationClassParser.java:796)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:308)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:230)
    at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:329)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:247)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:230)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:532)
    ... 23 common frames omitted

@kbastani
Copy link

kbastani commented Nov 11, 2016

This issue looks to be resolved after this commit from @luanne 3c26a64

I ran into the same issue. The cause was due to a bug when checking whether or not an ID field was either an enum or a simple type. The bug was introduced with this commit: 37179a3. This was diagnosed by @xenoterracide in this comment: spring-projects/spring-boot#6709 (comment)

There is an issue at the moment when trying to use the 4.2.0.BUILD-SNAPSHOT with any Spring Boot release <= 1.4.3. The Spring Boot auto-configuration project is dependent on scanning for the Neo4jConfiguration class when spring-data-neo4j is found on the classpath of the application. Since the Neo4jConfiguration class was removed in the latest 4.2.0.BUILD-SNAPSHOT, the class loader for Spring Boot will not be able to find the Neo4jConfiguration file at the expected location org/springframework/data/neo4j/config/Neo4jConfiguration.java.

This bug will need to be fixed in the Spring Boot auto-configuration project.

Since I do not have the history on why Neo4jConfiguration was removed, I think it's best that @luanne or @mangrish raise this issue against https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java#L36

Spring Data Neo4j will continue to be broken for applications using Spring Data REST repositories until this is resolved. There is no workaround in the meantime.

/cc @philwebb @snicoll

@mangrish
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-investigation An issue that has been triaged but needs further investigation
Projects
None yet
Development

No branches or pull requests

5 participants