spring-projects/spring-framework · error · ConversionNotSupportedException
Failed to convert value of type '{}' to required type '{}'
Error message
Failed to convert value of type '{}' to required type '{}' What it means
ConversionNotSupportedException raised by TypeConverterSupport when the delegate throws ConverterNotFoundException or IllegalStateException (see error 186). It signals that the conversion could not even be attempted because no converter/strategy exists. Carries the source value and required type; propertyName may be null.
Source
Thrown at spring-beans/src/main/java/org/springframework/beans/TypeConverterSupport.java:79
}
@Override
public <T> @Nullable T convertIfNecessary(@Nullable Object value, @Nullable Class<T> requiredType,
@Nullable TypeDescriptor typeDescriptor) throws TypeMismatchException {
return convertIfNecessary(null, value, requiredType, typeDescriptor);
}
private <T> @Nullable T convertIfNecessary(@Nullable String propertyName, @Nullable Object value,
@Nullable Class<T> requiredType, @Nullable TypeDescriptor typeDescriptor) throws TypeMismatchException {
Assert.state(this.typeConverterDelegate != null, "No TypeConverterDelegate");
try {
return this.typeConverterDelegate.convertIfNecessary(
propertyName, null, value, requiredType, typeDescriptor);
}
catch (ConverterNotFoundException | IllegalStateException ex) {
throw new ConversionNotSupportedException(value, requiredType, ex);
}
catch (ConversionException | IllegalArgumentException ex) {
throw new TypeMismatchException(value, requiredType, ex);
}
}
}
View on GitHub (pinned to 69bf83ad71)
Solutions
- Register a Converter or PropertyEditor for the required type (same fixes as error 186).
- Correct the target property type in the bean to a convertible type.
- If the value is already correct, ensure ConversionService is actually wired into the BeanWrapper (setConversionService).
Example fix
// before
wrapper.setConversionService(null);
wrapper.setPropertyValue("when", "2023-01-01"); // target java.time.Instant, no converter
// after
DefaultConversionService cs = new DefaultConversionService();
cs.addConverter(String.class, Instant.class, Instant::parse);
wrapper.setConversionService(cs);
wrapper.setPropertyValue("when", "2023-01-01T00:00:00Z"); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check before converting
if (!conversionService.canConvert(TypeDescriptor.forObject(value), TypeDescriptor.valueOf(requiredType))) {
throw new IllegalStateException("unsupported conversion; register a converter");
} Try / catch
try {
T result = converter.convertIfNecessary(value, requiredType, descriptor);
} catch (ConversionNotSupportedException ex) {
// no converter exists — register one and retry, or fail with context
log.warn("No converter for {} -> {}", value.getClass(), requiredType, ex);
throw ex;
} Prevention
- Ensure ConversionService is set on the BeanWrapper before binding.
- Register Converters for all custom types at startup.
- Use canConvert() to fail fast in integration tests.
When it happens
Trigger: convertIfNecessary on a BeanWrapper / TypeConverterSupport for a (value, requiredType) pair with no registered Converter or PropertyEditor, so the delegate raises IllegalStateException and line 79 wraps it.
Common situations: @Value injection, @ConfigurationProperties binding, or manual BeanWrapper.setPropertyValue where the target type has no converter; Spring Boot relaxed binding encountering an unregistered custom type.
Related errors
- Cannot convert value of type '{}' to required type '{}'[ for
- Cannot convert value of type '{}' to required type '{}'[ for
- typeMismatch
- Nested property in path '{propertyName}' does not exist
- Failed properties: {propertyAccessExceptions}
AI-assisted analysis of spring-projects/spring-framework@69bf83ad71 (2026-08-09).
Data as JSON: /api/errors/9e915964b51c7f11.
Report an issue: GitHub.