0

I am in the process of migrating spring boot to version 3.5.6 (from 2.2.2). I am getting the following error while running the boot run for the main class

Error: Could not find or load main class com.myapp.Application Caused by: java.lang.NoClassDefFoundError: org/springframework/web/WebApplicationInitializer

This are my gradle dependencies

dependencies {
    compileOnly group: 'com.stripe', name: 'stripe-java', version: '7.26.0'

    // ** Code Gen **//
    compileOnly 'org.codehaus.groovy:groovy-all:2.3.11'
    compileOnly 'org.apache.velocity:velocity:1.7'
    compileOnly 'org.reflections:reflections:0.9.10'
    compileOnly 'commons-beanutils:commons-beanutils:1.9.1'
    // ** Code Gen **//

    //Video frame maker
    compileOnly group: 'org.bytedeco', name: 'javacv-platform', version: '1.3.3'
    compileOnly group: 'javax.jms', name: 'javax.jms-api', version: '2.0.1'

    //* Redis Cache **//
    compileOnly group: 'com.github.debop', name: 'hibernate-redis', version: '2.3.2'
    compileOnly group: 'de.ruedigermoeller', name: 'fst', version: '2.57'
    compileOnly group: 'org.ehcache', name: 'ehcache', version: '3.8.1'
    compileOnly group: 'org.hibernate', name: 'hibernate-jcache', version: '5.4.10.Final'

    //* Redis Cache **//
    compileOnly 'javax.mail:mail:1.4.1'
    compileOnly("org.springframework:spring-context-support:5.0.8.RELEASE")

    compileOnly group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'

    compileOnly ("org.springframework.boot:spring-boot-starter-log4j2:${springBootVersion}")
    compileOnly ("org.springframework.retry:spring-retry:1.2.4.RELEASE")


    // Connection Pool
    compileOnly group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '8.5.32'

    compileOnly group: 'commons-validator', name: 'commons-validator', version: '1.6'

    compileOnly 'org.springframework:springloaded:1.2.8.RELEASE'
    compileOnly("org.springframework:spring-messaging")
    compileOnly("org.springframework:spring-jms:5.0.8.RELEASE")
    compileOnly 'com.adobe.xmp:xmpcore:5.1.2'
    compileOnly    'com.drewnoakes:metadata-extractor:2.8.1'

    compileOnly("org.springframework.security.oauth:spring-security-oauth2:2.3.4.RELEASE")
    compileOnly group: 'org.springframework', name: 'spring-tx', version: '5.2.2.RELEASE'

    compileOnly("mysql:mysql-connector-java:8.0.18")

    compileOnly("com.google.guava:guava:17.0")
    compileOnly("commons-io:commons-io:2.4")
    compileOnly("org.apache.commons:commons-lang3:3.14.0")
    compileOnly("com.squareup.retrofit:retrofit:1.6.0")

    compileOnly("com.github.davidmarquis:fluent-interface-proxy:1.3.0")

    compileOnly "org.springdoc:springdoc-openapi-ui:1.8.0"
    compileOnly group: 'org.springdoc', name: 'springdoc-openapi-security', version: '1.8.0'
    compileOnly group: 'org.springdoc', name: 'springdoc-openapi-data-rest', version: '1.8.0'

    compileOnly group: 'org.springdoc', name: 'springdoc-openapi-webmvc-core', version: '1.8.0'
    compileOnly group: 'org.springdoc', name: 'springdoc-openapi-hateoas', version: '1.8.0'

    compileOnly "joda-time:joda-time:2.2"
    compileOnly "com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.2"

    testImplementation("junit:junit")

    compileOnly 'org.antlr:stringtemplate:4.0.2'

    compileOnly "info.cukes:cucumber-java:1.1.5"
    compileOnly "info.cukes:cucumber-junit:1.1.5"
    compileOnly "info.cukes:cucumber-spring:1.1.5"
    compileOnly "com.jayway.jsonpath:json-path:0.9.1"

    compileOnly("org.apache.activemq:activemq-broker:5.15.4")
    compileOnly group: 'org.apache.activemq', name: 'activemq-pool', version: '5.15.11'

    compileOnly("org.apache.camel:camel-jms:2.15.1")
    compileOnly("org.apache.camel:camel-spring-boot:2.15.1")
    compileOnly("org.apache.camel:camel-spring-javaconfig:2.15.1")
    compileOnly("org.apache.camel:camel-metrics:2.15.1")
    compileOnly("org.apache.camel:camel-jackson:2.15.1")
    compileOnly("org.apache.camel:camel-jpa:2.15.1")
    compileOnly("org.apache.camel:camel-mail:2.15.1")
    compileOnly("org.apache.camel:camel-stringtemplate:2.15.1")

    compileOnly "org.apache.velocity:velocity:1.7"

    // ObjectMapper
    compileOnly group: 'org.modelmapper', name: 'modelmapper', version: '0.7.6'

    compileOnly group: 'com.google.code.gson', name: 'gson', version: '2.8.5'

    //code gen
    compileOnly group: 'commons-cli', name: 'commons-cli', version: '1.4'

    compileOnly("com.amazonaws:aws-java-sdk:1.11.133")
    compileOnly("org.liquibase:liquibase-core:3.8.2")

    compileOnly "jakarta.persistence:jakarta.persistence-api:3.2.0"
    compileOnly 'javax.servlet:javax.servlet-api:4.0.1' // Use the appropriate version
    compileOnly 'jakarta.servlet:jakarta.servlet-api:6.1.0'

    // SPRING BOOT
    compileOnly("org.springframework.boot:spring-boot-starter-web:3.5.6")

    // SPRING FRAMEWORK
    compileOnly('org.springframework.social:spring-social-security:1.1.6.RELEASE')
    compileOnly 'org.springframework.social:spring-social-config:1.1.6.RELEASE'
    compileOnly 'org.springframework.social:spring-social-facebook:2.0.3.RELEASE'
    compileOnly 'org.springframework.data:spring-data-jpa:3.5.4'
    compileOnly 'org.springframework.data:spring-data-rest-core:4.5.4'
    compileOnly 'org.springframework.data:spring-data-rest-webmvc:4.5.4'
    compileOnly 'org.springframework:spring-web:6.2.11'

    // Query DSL
    compileOnly 'com.querydsl:querydsl-core:5.0.0'
    compileOnly 'com.querydsl:querydsl-apt:5.0.0:jakarta'
    annotationProcessor "jakarta.persistence:jakarta.persistence-api:3.1.0"
    
}

This is my application main class


@Configuration
@EnableAutoConfiguration
@ComponentScan
@EnableAsync
@EnableHypermediaSupport(type = {EnableHypermediaSupport.HypermediaType.HAL})

@SpringBootApplication(exclude = {
        GroovyTemplateAutoConfiguration.class})

public class Application extends SpringBootServletInitializer implements WebApplicationInitializer {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

JDK Version 21 Gradle Version 7.6.6 Spring Web Version 6.2.11

3
  • 1
    There is far too little information here. Add your pom file, the code. What version you are migrating from. etc. Generally these errors come from trying to outsmart the Spring Boot dependency management. Commented Sep 25 at 11:21
  • @M.Deinum found that it is working in docker but not in intellij v2025V2.2.. still looking for a solution Commented Sep 26 at 3:39
  • What I thought, over eager dependency management. You have a mixture of versions from Spring, Spring Boot in there. Don't. All the Spring Boot dependencies shouldn't have versions. Ditch the spring-jms and the version for Spring Retry. THe Spring TX is even another version. You are even mixing JakartaEE and JavaX dependencies which won't work. Spring Social isn't supported anymore (already about 15 years or so). So basically your dependencies are messy mix. FIx those. Commented Sep 29 at 5:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.