Skip to content

NoSuchFieldException: Property not found when declare private access modifier on getter method #174

Closed
@SinaiNIN

Description

@SinaiNIN

There is an error what throwing NoSuchFieldException when declare private access modifier on getter method.

Error

 WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customGraphqlExecutor' defined in file [E:\core\core\build\classes\java\main\com\mbanq\graphql\CustomGraphqlExecutor.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchemaFactoryBean' defined in class path resource [com/introproventures/graphql/jpa/query/autoconfigure/GraphQLSchemaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.introproventures.graphql.jpa.query.autoconfigure.GraphQLSchemaFactoryBean]: Factory method 'graphQLSchemaFactoryBean' threw exception; nested exception is java.lang.RuntimeException: java.lang.NoSuchFieldException: age
 INFO o.s.o.j.LocalContainerEntityManagerFactoryBean Closing JPA EntityManagerFactory for persistence unit 'jpa-pu' 
Aug 29, 2019 10:44:41 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service [Tomcat]

Example of Code

public class Student{

    @Temporal(TemporalType.DATE)
    @Column(name = "DOB")
    private Date DateOfBirth;

    @Column(name ="age")
     private Integer age;

     private Integer getAge(){
           return Period.between(LocalDate.now(), dob).getYears();
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions