Skip to content

Spring 4.0.0-M1 breaks springdoc due to java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses #3048

@Algieba4

Description

@Algieba4

Describe the bug

When upgrading from Spring 3.5.4 to Spring 4.0.0-M1 (yes, I know I'm very early in this migration effort), my program will build and pass tests though I get the following stacktrace when trying to run my application.

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-08-01T17:22:40.146-05:00 ERROR 36992 --- [           main] [                                                 ] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springdoc.core.configuration.SpringDocKotlinConfiguration': Unexpected exception during bean creation
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:333) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:371) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1207) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1173) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1109) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:978) ~[spring-context-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:618) ~[spring-context-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-web-server-4.0.0-M1.jar:4.0.0-M1]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-4.0.0-M1.jar:4.0.0-M1]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[spring-boot-4.0.0-M1.jar:4.0.0-M1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-4.0.0-M1.jar:4.0.0-M1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1344) ~[spring-boot-4.0.0-M1.jar:4.0.0-M1]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1333) ~[spring-boot-4.0.0-M1.jar:4.0.0-M1]
	at com.example.MyExample.main(McsSps.java:10) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses
	at org.springframework.beans.BeanUtils$KotlinDelegate.findPrimaryConstructor(BeanUtils.java:878) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.BeanUtils.findPrimaryConstructor(BeanUtils.java:283) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1322) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1219) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[spring-beans-7.0.0-M7.jar:7.0.0-M7]
	... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: kotlin.reflect.full.KClasses
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580) ~[na:na]
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:490) ~[na:na]
	... 23 common frames omitted

When I disable springdoc.api-docs (springdoc.api-docs.enabled=false), I'm able to run my application in Spring 4.x. I didn't have to disable springdoc.swagger-ui

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using:
    4.0.0-M1

  • What modules and versions of springdoc-openapi are you using?

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.8.9</version>
    </dependency>
...
    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
      <version>1.8.0</version>
    </dependency>
  • Provide with a sample code (HelloController) or Test that reproduces the problem
    Issue appears when code is executing though below is my configuration and example (not my actual) controller
@Configuration
public class SwaggerConfig {
    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
            .info(new Info()
                .title("application")
                .version("1.0")
                .description("API documentation the accessing my applications endpoints"));
    }
}
@Slf4j
@CrossOrigin
@RestController
@RequestMapping(path = "/v1/controller")
@Tag(name = "My Controller", description = "Endpoints for executing my controller")
public class MyController {
    private final MyService myService;

    public MyController(MyService myService) {
        this.myService = myService;
    }

    @Operation(summary = "Gets information for a given date range",
            description = "Gets a count of all information for a given date range")
    @GetMapping(path = "/counts/{date}")
    public String getMyCounts(
            @Parameter(description = "Start date in yyyy-MM-dd format")
            @PathVariable("date") String date,
        return myService.getMyCounts(date);
    }
}

Expected behavior
I am expecting my code to compile and run successfully when using springdoc on Spring 4.x

Screenshots
N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions