Skip to content

ClassNotFoundException: org.springframework.web.servlet.resource.LiteWebJarsResourceResolver in Springdoc ​

Problem Statement ​

When upgrading springdoc-openapi from version 2.6.0 to 2.7.0 while using Spring Framework 6.1.x and Spring Boot 3.3.x, applications fail with a critical error:

text
ClassNotFoundException: org.springframework.web.servlet.resource.LiteWebJarsResourceResolver

This exception occurs during application startup and prevents the context from loading. The root cause is an incompatibility between framework versions and the springdoc library.

Understanding the Cause ​

The LiteWebJarsResourceResolver class was introduced in Spring Framework 6.2. springdoc 2.7.0 depends on this new class, but:

  • Spring Boot 3.3.x uses Spring Framework 6.1.x (which lacks this class)
  • Spring Boot 3.4.x uses Spring Framework 6.2.x (which contains this class)

The version compatibility matrix is as follows:

Spring FrameworkSpring BootSpringdoc
6.2.x3.4.x2.7.x+
6.1.x3.3.x2.6.x

Attempting to use springdoc 2.7.x with Spring Boot 3.3.x creates a dependency mismatch, resulting in the missing class exception.

Solutions ​

If you cannot upgrade Spring Boot, revert to the last compatible springdoc version.

Maven:

xml
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.6.0</version> <!-- Compatible with SB 3.3.x -->
</dependency>

Gradle:

groovy
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'

Option 2: Upgrade Spring Boot (Use with springdoc 2.7.x+) ​

To use springdoc 2.7.0+, upgrade your Spring Boot version to 3.4.x. First, update your Spring Boot parent POM:

Maven:

xml
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.4.0</version> <!-- Minimum required version -->
</parent>

Then update springdoc:

Maven:

xml
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.7.0</version>
</dependency>

Gradle:

groovy
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0'

Verification Steps

After making changes:

  1. Run mvn dependency:resolve (Maven) or gradle dependencies (Gradle) to ensure version consistency
  2. Confirm you don't have mixed versions in your dependency tree
  3. Test application startup with mvn spring-boot:run or gradle bootRun

Compatibility Guidance ​

Always consult the official springdoc compatibility matrix before upgrading. Key principles:

  1. Spring Boot dictates compatibility: Springdoc versions align with Spring Boot releases
  2. Patch versions are intercompatible: You can use springdoc 2.6.x with any Spring Boot 3.3.x version
  3. Verify transitive dependencies: Use mvn dependency:tree to check for conflicting libraries

Conclusion ​

The ClassNotFoundException for LiteWebJarsResourceResolver occurs due to version mismatches between springdoc and Spring Boot. The safest solution is matching springdoc versions to your Spring Boot release:

  • Spring Boot 3.3.x → springdoc 2.6.x
  • Spring Boot 3.4.x+ → springdoc 2.7.x+

For existing Spring Boot 3.3.x projects, downgrading springdoc to 2.6.x is the most efficient fix without requiring framework upgrades.