Error creating bean with name 'jpaMappingContext': JPA metamodel must not be empty

221 views Asked by At

While migrating from spring batch 4 to 5 (actually spring boot 2.6.6 to 3.1.3 upgrade), i came across several issues which are posted here.

Now I am stuck at error - Error creating bean with name 'jpaMappingContext': JPA metamodel must not be empty. (I don't use any DB features like monitors/status tables etc of spring batch.)

The top few line of stacktrace are -

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Unsatisfied dependency expressed through method 'requestMappingHandlerAdapter' parameter 1: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception with message: Error creating bean with name 'jsonSchemaConverter' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Unsatisfied dependency expressed through method 'jsonSchemaConverter' parameter 0: Error creating bean with name 'persistentEntities' defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]: Failed to instantiate [org.springframework.data.mapping.context.PersistentEntities]: Factory method 'persistentEntities' threw exception with message: Error creating bean with name 'jpaMappingContext': JPA metamodel must not be empty
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:550) ~[spring-beans-6.0.11.jar:6.0.11]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332) ~[spring-beans-6.0.11.jar:6.0.11]

What does above error mean and how can i solve it. (It seems to be more of spring data jpa issue then spring batch issue).

I went through other SOF post for this error but nothing solved my problem. Any help will be greatly appreciated as this is a prod blocker for me.

edit 1 - build.gradle is as below -

plugins {
    id 'org.springframework.boot'
}

dependencies {
    implementation **couple of internal project.**

    annotationProcessor "org.projectlombok:lombok:${Version.LOMBOK}"
    compileOnly "org.projectlombok:lombok:${Version.LOMBOK}"

    configurations {
        all*.exclude module : 'spring-boot-starter-logging'
        all*.exclude module : 'logback-classic'
    }
    implementation "org.springframework.boot:spring-boot-starter-log4j2"

    implementation "ch.qos.logback:logback-classic:${Version.LOGBACK}"
    implementation "ch.qos.logback:logback-core:${Version.LOGBACK}"
    implementation "com.google.guava:guava:${Version.GOOGLE_GUAVA}"
    implementation "com.h2database:h2:2.2.224"
    implementation "com.microsoft.sqlserver:mssql-jdbc:${Version.MSSQL_SERVER}"
    implementation "de.siegmar:logback-gelf:${Version.LOGBACK_GELF}"
    implementation "org.springframework.boot:spring-boot-starter-batch"
    implementation "org.springframework.boot:spring-boot-starter-web"
    implementation "org.postgresql:postgresql:${Version.POSTGRESQL}"


    testImplementation project(":esl-store-metadata").sourceSets.main.output

    testImplementation "de.siegmar:logback-gelf:${Version.LOGBACK_GELF}"
    testImplementation "org.projectlombok:lombok:${Version.LOMBOK}"
    testImplementation "org.springframework.batch:spring-batch-test"
    testImplementation "org.springframework.cloud:spring-cloud-contract-wiremock:${Version.SPRING_CLOUD}"
    testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' }
}

And right, like suggested by @M.Deinum, spring data rest is coming from a dependent project which is using netflix graphql libs. enter image description here

0

There are 0 answers