Skip to content

ClassNotFoundException when enabling DEBUG logging for org.springframework.ai #4249

@chenzibiao

Description

@chenzibiao

Bug Report: ClassNotFoundException when enabling DEBUG logging for org.springframework.ai
Spring AI version: 1.0.1
Spring Boot version: 3.5.5
Java version: 21

Description:
When setting the logging level to DEBUG for org.springframework.ai, the application fails to start due to a ClassNotFoundException.
However, using INFO level works without issues.
This behavior makes logging level affect runtime stability, which should not happen.

Steps to Reproduce:

  1. Create a Spring Boot project with Spring AI 1.0.1.
  2. Do not add the spring-security-oauth2-client dependency.
    3.Configure logging in application.properties:
    logging.level.org.springframework.ai=DEBUG
  3. Run the application.

Actual Behavior:
Application fails with:
java.lang.ClassNotFoundException: org.springframework.security.oauth2.client.ClientAuthorizationException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
...
at org.springframework.ai.model.tool.autoconfigure.ToolCallingAutoConfiguration.toolExecutionExceptionProcessor(ToolCallingAutoConfiguration.java:87)
...

Expected Behavior:
Enabling DEBUG logging should not trigger ClassNotFoundException.
If spring-security-oauth2-client is not present, Spring AI should gracefully skip OAuth2-related configuration.
Logging level should never change the runtime behavior of auto-configuration.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions