skip to Main Content

Encountering this exception while updating Spring Boot and Java versions on multi module project . Here are the details

Previously:

JAVA: 1.8
gradle : 5.6.2-all
springboot : 2.1.1

Current

JAVA: 21
gradle : 8.9
springboot : 3.3.2

Here is the dir structure and build.gradle files

tg-service
---tg-api
  ---build.gradle
---tg-common
  ---build.gradle
---tg-data-access
  ---build.gradle
---build.gradle
---wrapper
----gradle-wrapper.property

here is dependancies

1.build.gradle(tg-api)

plugins {
id 'org.springframework.boot' version '3.3.2'
id 'io.spring.dependency-management' version '1.1.4'
id("org.flywaydb.flyway") version "10.17.3"
}
version = '1.0.0-SNAPSHOT'
group = 'com.map.tg.api'
description = "map tg"
bootJar {
enabled = false
}
dependencies {
implementation project(":tg-common")
implementation project(":tg-data-access")
}

2.build.gradle(tg-common)

plugins {     
    id 'org.springframework.boot' version '3.3.2'     
    id 'io.spring.dependency-management' version '1.1.4' 
  } 
version = '1.0.0-SNAPSHOT' 
group = 'com.map.tg.common' 
description = "map tg"

  1. build.gradle(tg-data-access)
plugins {     
    id 'org.springframework.boot' version '3.3.2'     
    id 'io.spring.dependency-management' version '1.1.4' 
} 
version = '1.0.0-SNAPSHOT' 
group = 'com.map.tg.data-access' 
description = "map tg"
  1. build.gradle (parent)
subprojects {
   repositories {
       mavenCentral()
          maven {
             url = "http://devopsartifact.jio.com/artifactory/mvn_all"
             allowInsecureProtocol = true
            }

      }
       apply plugin: "java"
       apply plugin: "jacoco"
   
    java {
        sourceCompatibility = '21'
    }
    test {
        useJUnitPlatform()
        finalizedBy jacocoTestReport
    }
    jacocoTestReport {
        dependsOn test
        reports {
            xml.required = true
        }
    }
    build.dependsOn jacocoTestReport
    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }
    ext {
        springBootVersion = '3.3.2'
        junitVersion = '5.10.0'
        jcpCacheLib = '0.0.2'
        springCloudVersion = '4.1.1'
        swaggerVersion = "3.0.0"
        lombokVersion = "1.18.4"
        jsonVersion = "20230618"
        jakartaValidationVersion = "2.0.1.Final"
        hibernateValidatorVersion = "8.0.1.Final"
        hikariVersion = "3.3.1"
        commonBeanUtilVersion = "1.9.4"
        apacheLang3Version = "3.8.1"
        jasyptVersion = "1.16"
        jacksonDataBindVersion = '2.15.2'
        apacheLang3Version = "3.8.1"
        hibernateEnvVersion = '5.6.15.Final'
    }
    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web:3.3.2'
        implementation 'org.springframework.boot:spring-boot-starter-data-jpa:3.3.2'
        implementation 'org.springframework.boot:spring-boot-starter-security:3.3.2'
        implementation 'org.springframework.boot:spring-boot-starter-actuator:3.3.2'
        implementation 'org.springframework.boot:spring-boot-starter-cache:3.3.2'
        implementation 'org.springframework.boot:spring-boot-starter-quartz:3.3.2'
    
        implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:4.1.2'
        implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:4.1.1'
        implementation 'org.springframework.cloud:spring-cloud-starter-config:4.1.1'
    
        implementation 'org.springframework.data:spring-data-redis:3.2.2'
        implementation 'org.springframework.kafka:spring-kafka:3.2.2'
    
        implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
    
        implementation 'org.hibernate:hibernate-core:6.3.2.Final'
        implementation 'org.hibernate:hibernate-validator:8.0.1.Final'
    
        implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
        implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1'
    
        implementation 'io.micrometer:micrometer-registry-prometheus:1.13.0'
        implementation 'io.micrometer:micrometer-core:1.13.0'
    
        implementation 'org.projectlombok:lombok'
        annotationProcessor 'org.projectlombok:lombok'
    
        implementation 'io.jsonwebtoken:jjwt:0.9.1'
        implementation 'com.google.code.gson:gson:2.10.1'
        implementation 'org.apache.commons:commons-lang3:3.13.0'
        implementation 'commons-beanutils:commons-beanutils:1.9.4'
        implementation 'org.json:json:20231013'
        implementation 'com.zaxxer:HikariCP:5.1.0'

//        implementation("gradle.plugin.com.boxfuse.client:flyway-release")
implementation 'org.flywaydb:flyway-core'
implementation 'io.lettuce:lettuce-core:6.3.2.RELEASE'
implementation 'org.apache.commons:commons-pool2:2.12.0'

        implementation 'org.slf4j:slf4j-api:2.0.15'
        implementation 'org.apache.logging.log4j:log4j-api:2.22.1'
        implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.22.1'
    
        implementation 'com.hazelcast:hazelcast-all:4.2.8'
        implementation 'org.aspectj:aspectjweaver:1.9.21'
        implementation 'com.github.ulisesbocchio:jasypt-spring-boot:3.0.5'
        implementation 'org.jasypt:jasypt:1.9.3'
        implementation 'org.codehaus.janino:janino:3.1.10'
        implementation 'org.apache.commons:commons-compress:1.25.0'
        implementation 'commons-codec:commons-codec:1.17.0'

//        runtimeOnly 'mysql:mysql-connector-java'
runtimeOnly 'org.postgresql:postgresql:42.6.0'

        testImplementation 'org.springframework.boot:spring-boot-starter-test:3.3.2'
        testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
        testImplementation 'org.mockito:mockito-junit-jupiter:5.10.0'
        testImplementation 'org.assertj:assertj-core:3.25.1'
        testImplementation 'com.h2database:h2:2.2.224'
    
       
        // https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
        implementation("io.springfox:springfox-swagger2:3.0.0")
        implementation("io.springfox:springfox-swagger-ui:3.0.0")
    
        testImplementation('org.junit.jupiter:junit-jupiter-params:5.2.0')
        testImplementation('org.junit.jupiter:junit-jupiter-engine:5.2.0')
        testImplementation('org.mockito:mockito-junit-jupiter:2.18.3')
    }

}

application.yml

server:   
  port: 8080   
  servlet.context-path: tgservice 
  spring:   
    application:     
         name: service-tg-app   
         profiles:     active: ${PROFILE:sit}`

application-sit.yml

spring:   
  cloud.refresh.enabled: false   
  datasource:     
    url: jdbc:postgresql://x.x.x.x:5432/tgservice_sit     
    username: tgservice     
    password: ********     
    driverClassName: org.postgresql.Driver   
    type: com.zaxxer.hikari.HikariDataSource   
    flyway:     
      url: jdbc:postgresql://x.x.x.x:5432/tgservice_sit     
      username: tgservice     
      password: ********     
      ignore-missing-migrations: true     
      baseline-on-migrate: true     
      enabled: true     
      locations: classpath:db/migration`

And Here is the full error log

`[ERROR] [o.s.boot.web.embedded.tomcat.TomcatStarter.onStartup(60)] - Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jwtRequestFilter': Unsatisfied dependency expressed through field 'jwtUserDetailsService': Error creating bean with name 'jwtUserService': Unsatisfied dependency expressed through field 'userRepository': Error creating bean with name 'userRepository' defined in com.ril.dataaccess.tag.repository.UserRepository defined in @EnableJpaRepositories declared on Application: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
[10-09-2024 00:09:45.357] [] [main] [ERROR] [org.springframework.boot.SpringApplication.reportFailure(859)] - Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:619)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1352)
at com.ril.service.tag.Application.main(Application.java:59)
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:147)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:107)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:516)
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:222)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:188)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162)
... 8 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtRequestFilter': Unsatisfied dependency expressed through field 'jwtUserDetailsService': Error creating bean with name 'jwtUserService': Unsatisfied dependency expressed through field 'userRepository': Error creating bean with name 'userRepository' defined in com.ril.dataaccess.tag.repository.UserRepository defined in @EnableJpaRepositories declared on Application: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:767)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:211)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:174)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:169)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:154)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:87)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:266)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:240)
at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:52)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4414)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:203)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:437)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:128)
... 13 common frames omitted

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtUserService': Unsatisfied dependency expressed through field 'userRepository': Error creating bean with name 'userRepository' defined in com.ril.dataaccess.tag.repository.UserRepository defined in @EnableJpaRepositories declared on Application: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:767)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:784)
... 55 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in com.ril.dataaccess.tag.repository.UserRepository defined in @EnableJpaRepositories declared on Application: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:377)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:135)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1705)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1454)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1443)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:784)
... 69 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaSharedEM_entityManagerFactory': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:377)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:135)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:682)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1355)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:365)
... 82 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Unable to obtain connection from database: FATAL: role "pradip.parkar" does not exist
-

SQL State  : 28000
Error Code : 0
Message    : FATAL: role "pradip.parkar" does not exist

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1806)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:337)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:365)
    ... 94 common frames omitted

Caused by: org.flywaydb.core.internal.exception.FlywaySqlException: Unable to obtain connection from database: FATAL: role "pradip.parkar" does not exist
-

SQL State  : 28000
Error Code : 0
Message    : FATAL: role "pradip.parkar" does not exist

    at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:60)
    at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:72)
    at org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:134)
    at org.flywaydb.core.Flyway.migrate(Flyway.java:147)
    at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1802)
    ... 103 common frames omitted

Caused by: org.postgresql.util.PSQLException: FATAL: role "pradip.parkar" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713)
at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2825)
at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:175)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:313)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:54)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:263)
at org.postgresql.Driver.makeConnection(Driver.java:443)
at org.postgresql.Driver.connect(Driver.java:297)
at org.springframework.jdbc.datasource.SimpleDriverDataSource.getConnectionFromDriver(SimpleDriverDataSource.java:144)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:169)
at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:48)
... 109 common frames omitted`

I attempted to resolve the issue by changing the version of the JPA dependency, but I still don’t understand which dependency is causing the error

2

Answers


  1. Chosen as BEST ANSWER

    After two days of thorough analysis, I discovered that the issue was caused by the dependency.

    implementation 'org.flywaydb:flyway-core'
    

    Once I removed this dependency, the project successfully built and started running.


  2. Error log indicates a Spring Boot application failing to start due to a series of interconnected issues.

    Problems analysis

    1. Root cause:

    The fundamental issue is a database connection problem:

    FATAL: role "pradip.parkar" does not exist
    
    SQL State  : 28000
    Error Code : 0
    Message    : FATAL: role "pradip.parkar" does not exist
    
    

    This error suggests that the application is trying to connect to a PostgreSQL database using a role/user named "pradip.parkar", but this role/user doesn’t exist in the database.

    2. Cascading effects:

    This database connection failure causes a chain reaction of errors:

    a. Flyway migration fails:

    The application uses Flyway for database migrations. Since it can’t connect to the database, the Flyway initialization fails.

    b. Entity Manager creation fails:

    Without a database connection, the application can’t create the Entity Manager, which is crucial for JPA (Java Persistence API) operations.

    c. Repository bean creation fails:

    The UserRepository bean can’t be created because it depends on the Entity Manager.

    d. Service bean creation fails:

    The JwtUserService bean fails to create because it depends on the UserRepository.

    e. Filter bean creation fails:

    The JwtRequestFilter bean fails to create because it depends on the JwtUserService.

    3. Final result:

    Due to these cascading failures, the embedded Tomcat server can’t start, and the entire Spring Boot application fails to launch.

    Suggestion:

    1. Check your database configuration (likely in application.properties or application.yml) to ensure you’re using the correct database username.

    2. Database username, is clearly specified without environment variable.

    3. Verify that the user "pradip.parkar" exists in your PostgreSQL database and has the necessary permissions.

    4. If the user doesn’t exist, either create it in the database or update your application’s configuration to use an existing, valid database user.

    Update: Clarify PostgreSQL role vs user

    Role

    • A role is a more general concept in PostgreSQL.
    • Roles can represent individual users or groups of users.
    • Roles can own database objects (like tables, functions, etc.).
    • Roles can have attributes that define their privileges.

    User

    • In PostgreSQL, a user is essentially a role with the LOGIN privilege.
    • Every user is a role, but not every role is a user.
    • Users are typically used for authentication purposes.

    Key Differences

    1. Login Capability:

      • Users (roles with LOGIN privilege) can connect to a database.
      • Roles without LOGIN privilege cannot connect directly.
    2. Inheritance:

      • Roles can be members of other roles, inheriting their privileges.
      • This allows for more flexible permission management.
    3. Usage:

      • Roles are often used for grouping privileges.
      • Users are typically used for individual database accounts.

    Creating Roles and Users

    • Create a role: CREATE ROLE role_name;
    • Create a user: CREATE USER user_name;
      (equivalent to CREATE ROLE user_name WITH LOGIN;)

    Best Practices

    • Use roles for managing permissions and group-level access.
    • Use users (roles with LOGIN) for individual database accounts.
    • Leverage role inheritance for easier privilege management.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search