Skip to content

NoClassDefFoundError in StatementCreatorUtils (Spring JDBC 6.2.6) #34891

@mlrhymes

Description

@mlrhymes

Issue Summary
I encountered a java.lang.NoClassDefFoundError when using Spring JDBC 6.2.6. The issue appears to be caused by the initialization of org.springframework.jdbc.core.StatementCreatorUtils, specifically due to a missing or incompatible method SpringProperties.checkFlag(String) in spring-core.

Environment Details
Spring Framework Version: Spring JDBC 6.2.6
Spring Core Version: 6.2.6
Java Version: 21.06
Build Tool: Ant (No Maven or Gradle)
IDE: Eclipse
Operating System: Windows 11

Error Stack Trace:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.jdbc.core.StatementCreatorUtils
at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.cleanupParameters(PreparedStatementCreatorFactory.java:299)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:682)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:723)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:748)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:804)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:252)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:261)
Caused by: java.lang.ExceptionInInitializerError
at org.springframework.jdbc.core.StatementCreatorUtils.(StatementCreatorUtils.java:89)
at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.setValues(PreparedStatementCreatorFactory.java:287)
at org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.createPreparedStatement(PreparedStatementCreatorFactory.java:245)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:656)

Minimal Code Sample to Reproduce:

else if (mapper instanceof RowMapper) {
    RowMapper<T> rowMapper = (RowMapper<T>) mapper;
    ret = SpringDataSource.getInstance().getNamedParameterJdbcTemplate().queryForObject(query, values, rowMapper);
}

Steps to Reproduce
Set up a Spring JDBC 6.2.6-based application with NamedParameterJdbcTemplate.
Ensure the project is built with Ant (not Maven or Gradle).
Execute a query using NamedParameterJdbcTemplate.queryForObject().
Observe the NoClassDefFoundError when StatementCreatorUtils initializes.

Expected Behavior
StatementCreatorUtils should initialize successfully, and queries using NamedParameterJdbcTemplate.queryForObject() should execute without errors.

Observed Behavior
The application crashes due to ExceptionInInitializerError, specifically when calling SpringProperties.checkFlag(String). This suggests that SpringProperties may be missing or incompatible.

Troubleshooting Attempts
Verified classpath dependencies manually (spring-core.jar is present).
Rebuilt and cleaned the project.
Checked for conflicting versions of Spring.
Inspected spring-core.jar to confirm if SpringProperties.checkFlag(String) exists.

Request for Resolution
Could you confirm if this is a known issue with Spring JDBC 6.2.6? If so, is there a recommended fix or workaround? Should SpringProperties.checkFlag(String) be available in Spring Core for this version?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions