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

java.lang.ClassCastException: com.sun.proxy.$Proxy106 cannot be cast to org.neo4j.ogm.annotation.GeneratedValue #604

Open
shubham-pathak22 opened this issue Feb 13, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@shubham-pathak22
Copy link

commented Feb 13, 2019

Context

Recently upgraded application to springboot 2.0.8 release

Code Changes

  1. Updated the model classes with @Id @GeneratedValue wherever @GraphID was present.
  2. Added following dependency
<dependency>
            <groupId>io.github.lukehutch</groupId>
            <artifactId>fast-classpath-scanner</artifactId>
            <version>3.1.13</version>
   </dependency>

to fix issue #601

Issue

Following exception is thrown while starting the spring boot application

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy106 cannot be cast to org.neo4j.ogm.annotation.GeneratedValue at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583) ... 40 common frames omitted Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy106 cannot be cast to org.neo4j.ogm.annotation.GeneratedValue at org.neo4j.ogm.metadata.ClassInfo.isPrimaryIndexField(ClassInfo.java:897) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1620) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)

The above exception is intermittent. After a couple of restarts, the exception disappears.
Any ideas on how to fix this unstable behavior?

The config file looks like this

@org.springframework.context.annotation.Configuration
@EnableNeo4jRepositories(basePackages = "xx.xx")
@EnableTransactionManagement
public class xxConfig {

@Value("${neo4j.username}")
private String username;

@Value("${neo4j.password}")
private String password;

@Value("${neo4j.bolt.uri}")
private String uri;

@Bean
public SessionFactory sessionFactory() {
    return new SessionFactory(configuration(), "xx.xx.model");
}

@Bean
public org.neo4j.ogm.config.Configuration configuration() {
    return new Configuration.Builder()
            .credentials(username, password)
            .connectionLivenessCheckTimeout(0)
            .uri(uri)
            .build();
}

@Bean
public Neo4jTransactionManager transactionManager() throws Exception {
    return new Neo4jTransactionManager(sessionFactory());
}

Environment

  • OGM Version used: 3.1.6
  • Java Version used: 1.8
  • Neo4J Version used: 3.3.1
  • Bolt Driver Version used (if applicable): 3.1.6
  • Operating System and Version: Linux 4.9.43-17.38.amzn1.x86_64
  • Spring boot 2.0.8.RELEASE
  • spring-data-neo4j:jar :5.0.13.RELEASE
@meistermeier

This comment has been minimized.

Copy link
Collaborator

commented Feb 14, 2019

Could you provide an example project or at least a complete pom.xml that we could use to reproduce your problem? With the information you have given, it is not possible to create a reproducer. Also multiple restarts did not show any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.