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

Not an instance of a persistable class [DATAGRAPH-891] #1452

Closed
spring-projects-issues opened this issue Jul 28, 2016 · 1 comment
Closed

Not an instance of a persistable class [DATAGRAPH-891] #1452

spring-projects-issues opened this issue Jul 28, 2016 · 1 comment
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jul 28, 2016

Sebastian Glahn opened DATAGRAPH-891 and commented

I have a Spring Boot project which uses Spring Data Neo4j. When I run the project from my IDE(Intellij) everything works fine. When I run the project from command line(java -jar ...) I get the message that my entity is not an instance of a persistable class.
I pass the basePackages to the SessionFactory:

@Bean
public SessionFactory getSessionFactory() {
    return new SessionFactory(getConfiguration(), basePackages);
}

And I have annotated the main class with:

@EnableNeo4jRepositories(basePackages = "org.sgh.persistence")

The info log shows the following:
When started from Intellij:

2016-07-20 15:58:30.435 INFO 67581 — [ main] o.s.d.neo4j.config.Neo4jConfiguration : Initialising Neo4jSession
2016-07-20 15:58:30.443 DEBUG 67581 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Classpath elements:
2016-07-20 15:58:30.443 DEBUG 67581 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : /Users/sebastianglahn/workspace/sandbox/spring-data-neo4j-example/build/classes/main/org/sgh/persistence
2016-07-20 15:58:30.447 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Processing: org.sgh.persistence.ExampleRepository -> java.lang.Object
2016-07-20 15:58:30.449 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Processing: org.sgh.persistence.TreeEntity -> java.lang.Object
2016-07-20 15:58:30.450 INFO 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Starting Post-processing phase
2016-07-20 15:58:30.450 INFO 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Building annotation class map
2016-07-20 15:58:30.450 INFO 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Building interface class map for 3 classes
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : - ExampleRepository implements 1 interfaces
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : - org.springframework.data.neo4j.repository.GraphRepository
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : - TreeEntity implements 0 interfaces
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : - Object implements 0 interfaces
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Post-processing: org.sgh.persistence.ExampleRepository
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : - No ClassInfo found for interface class: org.springframework.data.neo4j.repository.GraphRepository
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Post-processing: org.sgh.persistence.TreeEntity
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Checking for @Transient classes....
2016-07-20 15:58:30.450 DEBUG 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Registering converters and deregistering transient fields and methods....
2016-07-20 15:58:30.451 INFO 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Post-processing complete
2016-07-20 15:58:30.452 INFO 67581 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : 3 classes loaded in 11 milliseconds

When started from command line:

2016-07-21 09:11:46.441 INFO 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Starting Post-processing phase
2016-07-21 09:11:46.441 INFO 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Building annotation class map
2016-07-21 09:11:46.441 INFO 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Building interface class map for 0 classes
2016-07-21 09:11:46.441 DEBUG 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Checking for @Transient classes....
2016-07-21 09:11:46.441 DEBUG 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Registering converters and deregistering transient fields and methods....
2016-07-21 09:11:46.441 INFO 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : Post-processing complete
2016-07-21 09:11:46.441 INFO 67991 — [ main] o.neo4j.ogm.metadata.ClassFileProcessor : 0 classes loaded in 1829 milliseconds

Although the debug logs shows that the ClassPathScanner is scanning the correct classes:

2016-07-21 09:35:40.099 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning zipFile /private/tmp/spring-data-neo4j-demo/build/libs/spring-data-neo4j-example-0.0.1-SNAPSHOT.jar
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning class entry: BOOT-INF/classes/org/sgh/configuration/Neo4jConfig.class
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning class entry: BOOT-INF/classes/org/sgh/Controller/ExampleController.class
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning class entry: BOOT-INF/classes/org/sgh/persistence/ExampleRepository.class
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning class entry: BOOT-INF/classes/org/sgh/persistence/TreeEntity.class
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning class entry: BOOT-INF/classes/org/sgh/service/ExampleService.class
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning class entry: BOOT-INF/classes/org/sgh/SpringDataNeo4jExampleApplication.class
2016-07-21 09:35:40.101 DEBUG 68083 — [ main] org.neo4j.ogm.scanner.ClassPathScanner : Scanning zipped entry: BOOT-INF/lib/spring-test-4.3.1.RELEASE.jar

I have created a minimal demo project on Github to reproduce the problem: https://github.com/sglahn/spring-data-neo4j-demo
To reproduce the problem do the following: Build the jar:

./gradlew build

Execute the jar:

java -Dspring.config.location=build/resources/main/ -jar build/libs/spring-data-neo4j-example-0.0.1-SNAPSHOT.jar

Access the Controller in the browser:

http://localhost:8765/

The log shows:

org.sgh.persistence.TreeEntity is not an instance of a persistable class

When deployed as exploded jar the project runs fine.

Spring Boot version is 1.4.0.RC1


Affects: 4.0 GA, 4.1.1 (Hopper SR1), 4.1.2 (Hopper SR2)

1 votes, 3 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 5, 2016

Vince Bickers commented

This is actually fixed in the underlying OGM library dependency, and will be available in the next service release of Spring Data Neo4j.

In the meantime please see https://github.com/neo4j-examples/sdn4-university for details of a workaround.

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

No branches or pull requests

1 participant