Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Spring Boot fails at startup with an error processing a condition on an auto-configuration

Errorjava.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration

Short answer

This message only says Spring Boot failed while evaluating an auto-configuration condition. The real reason is in the Caused by lines below it. In Gradle projects it is often a Java or Gradle version the Spring Boot release does not support, or hand-picked Spring library versions that do not match the Boot BOM.

  • Applies to Spring Boot 3.5, Spring Boot 4.x, Gradle 8.14, Gradle 9, Java 17, Java 21
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Do not stop at the first line. Print the whole stack trace and read the last Caused by line, which names the class or version that fails. Start the app with the debug switch to get the conditions report.

    ./gradlew bootRun --stacktrace
    java -jar build/libs/my-app.jar --debug
  2. 2Match what you see, then jump to its fix

    1. 1The last Caused by line names a class that fails to load, and your Java or Gradle is outside the support tableThe Java or Gradle version is not supported by this Spring Boot releaseFix
    2. 2The build file pins versions of Spring or other managed libraries by handSpring library versions do not match the Spring Boot BOMFix
    3. 3The app uses a JNDI name, or no spring.datasource.url at allA data source is configured, but not in the way the app expectsFix

What does the error look like?

  • java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration

Cause 1 of 3

The Java or Gradle version is not supported by this Spring Boot release

1Check

Each Spring Boot version lists the Java and Gradle versions it supports. Current releases need Java 17 or later and Gradle 8.14 or later (8.x) or 9.x. Compare with what your build runs.

java -version
./gradlew --version

2Fix

Run the build on a Java version in the supported range, or move to a Spring Boot release that supports the Java and Gradle you have. Update the wrapper if Gradle is the old part.

./gradlew wrapper --gradle-version 9.0.0

3Verify

Start the application again.

./gradlew bootRun

Confirmed by docs.spring.io

Did this fix it?

Cause 2 of 3

Spring library versions do not match the Spring Boot BOM

1Check

Spring Boot manages versions through its BOM, so starters need no version number. A version set by hand, or an ext property override, can pull a library that does not fit the Boot release.

./gradlew dependencies --configuration runtimeClasspath | grep -i spring

2Fix

Remove hand-written versions of managed libraries. If you must change one, use the documented property or resolution strategy, and remember that each Boot release is tested with its own set of versions.

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}

3Verify

Run the dependency report again; all Spring Boot libraries should share the release you chose.

./gradlew dependencies --configuration runtimeClasspath | grep -i spring-boot

Confirmed by docs.spring.io

Did this fix it?

Cause 3 of 3

A data source is configured, but not in the way the app expects

1Check

Without spring.datasource.url, Spring Boot tries to set up an embedded database. For a server-managed data source you use spring.datasource.jndi-name instead of url, username and password.

grep -rn "spring.datasource" src/main/resources/

2Fix

Set the URL (and credentials) for a normal database, or set the JNDI name for a server-managed one. If your app does not use a database at all, exclude the data source auto-configuration.

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class MyApplication { }

3Verify

Start the application and check the log for the next error, if any.

./gradlew bootRun

Confirmed by docs.spring.io

Did this fix it?

How do I stop it coming back?

  • Let the Spring Boot plugin and BOM choose versions of managed libraries.
  • Upgrade Spring Boot, Java and Gradle together, and read the system requirements page first.
  • Run the app with --debug after a dependency change to see the conditions report.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

Spring Boot will not start because port 8080 is already taken

Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

Spring Boot listens on 8080 unless told otherwise, and only one process can own a port.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.