I am using spring version 5.2.3.RELEASE running on JDK 8, but during runtime I am getting the below error

Caused by: java.lang.IllegalStateException: Failed to introspect Class ... ... Caused by: java.lang.NoClassDefFoundError: org/springframework/jdbc/support/JdbcTransactionManager

Even though I have declared the below in my build.gradle file implementation group: 'org.springframework', name: 'spring-jdbc', version: springframeworkVersion

Full build.gradle is below


    plugins {
        id 'java'
        id 'org.springframework.boot' version '2.7.5'
        id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    }
    
    group = 'org.temp'
    version = ''
    
    repositories {
    
        maven {
            url 'https://ost1v.enp.aramco.com.sa:8443/repository/maven-central'
            credentials {
                username mavenuser
                password mavenpassword
            }
        }
    
        maven {
            url 'https://ost1v.enp.aramco.com.sa:8443/repository/maven-jcenter'
            credentials {
                username mavenuser
                password mavenpassword
            }
        }
    
    
        maven {
            url 'https://ost1v.enp.aramco.com.sa:8443/repository/maven-releases'
            credentials {
                username mavenuser
                password mavenpassword
            }
        }
    
        maven {
            url 'https://ost1v.enp.aramco.com.sa:8443/repository/maven-jaspersoft-3rd-party-ce'
            credentials {
                username mavenuser
                password mavenpassword
            }
        }
    
    
    }
    
    
    ext {
    
        slf4jVersion = '1.7.25'
        logbackVersion = '1.3.0-alpha10'
    
        jacksonDatabindVersion = '2.11.1'  //2.10.1, change it to 2.12.6
    
        springframeworkVersion = '5.3.23'
        //springframeworkVersion = '5.2.3.RELEASE' - This was commented to fix the problem
        //springSecurityVersion = '5.3.8.RELEASE'
        springSecurityVersion = '5.3.3.RELEASE'
    
    
        mybatisVersion = '3.5.6'
        mybatisJsr310 = '1.0.2'
        mybatisSpringVersion = '1.3.2'
    
        oracleJdbcVersion = '19.3.0.0'
        oracleSpatialVersion = '12.1.0.2'
        oracleXdbVersion = '12.2.1.2'
    
        lombokVersion = '1.16.20'
    
    
        commonsCollectionsVersion = '4.1'
        commonsIOVersion = '2.7'
        commonsLangVersion = '3.7'
        commonsFileuploadVersion = '1.4'
        commonsHttpclientVersion = '4.5.10'
        commonsExecVersion = '1.3'
        commonsBeanutilsVersion = '1.9.4'
    
        junitVersion = '4.12'
        mockitoVersion = '2.16.0'
        powermockVersion = '1.7.3'
    
        jasyptVersion = '1.9.2'
        hamcrestVersion = '1.3'
    
        bouncyCastleVersion = '1.64'
        //tokenServiceVersion = '2.0'
        tokenServiceVersion = '1.6-SNAPSHOT'
    
        jsonPathVersion = '2.4.0'
    
        geotoolsVersion = '18.2'
    
        itextVersion = '2.1.7.js4'
    
        jasperReportsVersion = '6.12.2'
        batikVersion = '1.13'
        fopVersion = '2.2'
    
        javaxMail = '1.5.6'
        freeMarker = '2.3.28'
        subethamail = '3.1.7'
    
    }
    configurations {
        all {
            exclude group: 'junit', module: 'junit'
            exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
        }
    }
    
    dependencies {
        implementation 'org.springframework.boot:spring-boot-starter-web:2.5.5'
        implementation 'org.springframework.boot:spring-boot-starter-aop:2.5.5'
        implementation 'org.springframework.boot:spring-boot-starter-security:2.5.5'
        implementation group: 'org.springframework', name: 'spring-jdbc', version: springframeworkVersion
        implementation group:  'org.mybatis.spring.boot',name:'mybatis-spring-boot-starter',version:'2.2.2'
        implementation group: 'commons-beanutils', name: 'commons-beanutils', version: commonsBeanutilsVersion
        implementation group: 'org.apache.commons', name: 'commons-collections4', version: commonsCollectionsVersion
        implementation group: 'commons-io', name: 'commons-io', version: commonsIOVersion
        implementation group: 'org.apache.commons', name: 'commons-lang3', version: commonsLangVersion
        implementation group: 'commons-fileupload', name: 'commons-fileupload', version: commonsFileuploadVersion
        implementation group: 'org.apache.commons', name: 'commons-exec', version: commonsExecVersion
        implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: commonsHttpclientVersion
        implementation group: 'com.oracle.ojdbc', name: 'ojdbc8', version: oracleJdbcVersion
        implementation group: 'org.springframework.security', name: 'spring-security-config', version: springSecurityVersion
    
    
    
        // implementation group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
        // implementation group: 'ch.qos.logback', name: 'logback-core', version: logbackVersion
    
    
    
        // https://mvnrepository.com/artifact/org.mybatis/mybatis
        implementation group: 'org.mybatis', name: 'mybatis', version: '3.5.6'
        // https://mvnrepository.com/artifact/net.minidev/json-smart
        //implementation group: 'net.minidev', name: 'json-smart', version: '2.3'
    
    
        implementation group: 'org.mybatis', name: 'mybatis-spring', version: '2.0.0'
        implementation group: 'org.projectlombok', name: 'lombok', version: lombokVersion
        implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: bouncyCastleVersion
    
        implementation group: 'javax.mail', name: 'mail', version: '1.4.5'  // 1.4.5
    
        compileOnly  fileTree(dir: 'dependencies/documentum/Shared', include: '*.jar')
    
    
        testImplementation group: 'junit', name: 'junit', version: junitVersion
        testImplementation group: 'org.springframework', name: 'spring-test', version: springframeworkVersion
        testImplementation group: 'org.subethamail', name: 'subethasmtp', version: subethamail
    
        testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
        testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: hamcrestVersion
    
        testImplementation group: 'org.jasypt', name: 'jasypt', version: jasyptVersion
        testImplementation group: 'org.jasypt', name: 'jasypt-spring31', version: jasyptVersion
    
        //testImplementation group: 'org.springframework.security', name: 'spring-security-test', version: springSecurityVersion
        //implementation group: 'com.github.albfernandez', name: 'itext2', version: '2.1.9'
        implementation group: 'net.sf.jasperreports', name: 'jasperreports', version: '6.12.2'
        testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: jsonPathVersion
    
        //compile group: 'com.github.albfernandez', name: 'itext2', version: '2.1.9'
        //compile (group: 'net.sf.jasperreports', name: 'jasperreports', version: '6.7.1') {exclude group: 'com.lowagie', module: "itext"}
    
    
    }
    
    test {
        useJUnitPlatform()
    }

1

There are 1 best solutions below

0
akarahman On

There was a version mismatch, spring-jdbc was pointing to version 5.2.3.RELEASE, after changing its version to match with the rest of spring libraries which were of version 5.3.23, the problem was resolved.

Rest of the spring libraries of version 5.3.23 were automatically downloaded as sub dependencies of org.springframework.boot:spring-boot-starter-web:2.5.5. I was explicity downloading the spring-jdbc version and it was pointing to an older version.