Skip to content

Conversation

@candrews
Copy link
Contributor

JdbcSessionAutoConfiguration is conditional on the DataSource bean which won't exist until after DataSourceAutoConfiguration; therefore, JdbcSessionAutoConfiguration must autoconfigure after DataSourceAutoConfiguration.

This change fixes the JdbcSessionAutoConfiguration failing to autoconfigure due there being no DataSource bean despite DataSourceAutoConfiguration creating a DataSource bean.

From the autoconfiguration report:

   JdbcSessionAutoConfiguration:
      Did not match:
         - @ConditionalOnBean (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans of type javax.sql.DataSource (OnBeanCondition)
      Matched:
         - @ConditionalOnClass found required classes 'org.springframework.session.Session', 'org.springframework.jdbc.core.JdbcTemplate', 'org.springframework.session.jdbc.JdbcIndexedSessionRepository' (OnClassCondition)
         - found 'session' scope (OnWebApplicationCondition)

...

   DataSourceAutoConfiguration matched:
      - @ConditionalOnClass found required classes 'javax.sql.DataSource', 'org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType' (OnClassCondition)
      - @ConditionalOnMissingBean (types: ?; SearchStrategy: all) did not find any beans (OnBeanCondition)

   DataSourceAutoConfiguration.PooledDataSourceConfiguration matched:
      - AnyNestedCondition 1 matched 1 did not; NestedCondition on DataSourceAutoConfiguration.PooledDataSourceCondition.PooledDataSourceAvailable PooledDataSource found supported DataSource; NestedCondition on DataSourceAutoConfiguration.PooledDataSourceCondition.ExplicitType @ConditionalOnProperty (spring.datasource.type) did not find property 'spring.datasource.type' (DataSourceAutoConfiguration.PooledDataSourceCondition)
      - @ConditionalOnMissingBean (types: javax.sql.DataSource,javax.sql.XADataSource; SearchStrategy: all) did not find any beans (OnBeanCondition)

   DataSourceAutoConfiguration.PooledDataSourceConfiguration#jdbcConnectionDetails matched:
      - @ConditionalOnMissingBean (types: org.springframework.boot.jdbc.autoconfigure.JdbcConnectionDetails; SearchStrategy: all) did not find any beans (OnBeanCondition)

   DataSourceConfiguration.Hikari matched:
      - @ConditionalOnClass found required class 'com.zaxxer.hikari.HikariDataSource' (OnClassCondition)
      - @ConditionalOnProperty (spring.datasource.type=com.zaxxer.hikari.HikariDataSource) matched (OnPropertyCondition)
      - @ConditionalOnMissingBean (types: javax.sql.DataSource; SearchStrategy: all) did not find any beans (OnBeanCondition)

JdbcSessionAutoConfiguration is conditional on the DataSource bean which won't exist until after DataSourceAutoConfiguration; therefore, JdbcSessionAutoConfiguration must autoconfigure after DataSourceAutoConfiguration.

Signed-off-by: Craig Andrews <candrews@integralblue.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 16, 2025
@wilkinsona
Copy link
Member

Thanks, @candrews. Can you please share some more information about the application in which this is failing? Boot smoke test for Spring Session JDBC isn't affected, I believe because, in the absence of any other ordering, the auto-configuration class order will be alphabetical. I'd like to understand what's changing that ordering in your situation in case there's another problem lurking somewhere.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Dec 16, 2025
@wilkinsona wilkinsona changed the title JdbcSessionAutoConfiguration after DataSourceAutoConfiguration JdbcSessionAutoConfiguration may not match when using the auto-configured DataSource Dec 16, 2025
@wilkinsona wilkinsona added type: regression A regression from a previous release and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Dec 16, 2025
@wilkinsona wilkinsona added this to the 4.0.x milestone Dec 16, 2025
@candrews
Copy link
Contributor Author

The application is large and complex with a number of AutoConfiguration classes. These AutoConfigurations have their own before/after configurations, so I suspect that is causing the implicit alphabetical ordering to change.

Is there something I could run to provide more information you need?

@wilkinsona
Copy link
Member

Thanks, @candrews. I don't think we need anything more. The alphabetical ordering is a last resort so as soon as you have other before/after ordering, as you do, it could change.

@wilkinsona wilkinsona modified the milestones: 4.0.x, 4.0.1 Dec 17, 2025
wilkinsona pushed a commit that referenced this pull request Dec 17, 2025
JdbcSessionAutoConfiguration is conditional on the DataSource bean
which won't exist until after DataSourceAutoConfiguration; therefore,
JdbcSessionAutoConfiguration must auto-configure after
DataSourceAutoConfiguration.

Signed-off-by: Craig Andrews <candrews@integralblue.com>

See gh-48552
@wilkinsona
Copy link
Member

Thanks again, @candrews. This'll be in tomorrow's 4.0.1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: regression A regression from a previous release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants