spring-projects/spring-framework · error · IllegalStateException
Cannot convert value of type '{}' to required type '{}'[ for
Error message
Cannot convert value of type '{}' to required type '{}'[ for property '{}']: no matching editors or conversion strategy found What it means
IllegalStateException from TypeConverterDelegate when no PropertyEditor and no ConversionService path could convert the value to the required type. Unlike error 185, no editor participated (or none returned an incompatible value); Spring simply has no strategy for the conversion. Reached at line 270 after canConvert(...) returns false (or conversionService is null).
Source
Thrown at spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java:270
}
}
// Definitely doesn't match: throw IllegalArgumentException/IllegalStateException
StringBuilder msg = new StringBuilder();
msg.append("Cannot convert value of type '").append(ClassUtils.getDescriptiveType(newValue));
msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append('\'');
if (propertyName != null) {
msg.append(" for property '").append(propertyName).append('\'');
}
if (editor != null) {
msg.append(": PropertyEditor [").append(editor.getClass().getName()).append(
"] returned inappropriate value of type '").append(
ClassUtils.getDescriptiveType(convertedValue)).append('\'');
throw new IllegalArgumentException(msg.toString());
}
else {
msg.append(": no matching editors or conversion strategy found");
throw new IllegalStateException(msg.toString());
}
}
}
if (conversionAttemptEx != null) {
if (editor == null && !standardConversion && requiredType != null && Object.class != requiredType) {
throw conversionAttemptEx;
}
logger.debug("Original ConversionService attempt failed - ignored since " +
"PropertyEditor based conversion eventually succeeded", conversionAttemptEx);
}
return (T) convertedValue;
}
private Object attemptToConvertStringToEnum(Class<?> requiredType, String trimmedValue, Object currentConvertedValue) {
Object convertedValue = currentConvertedValue;
View on GitHub (pinned to 69bf83ad71)
Solutions
- Register a Converter<SourceType, TargetType> with the ConversionService (e.g. DefaultConversionService.addConverter).
- Register a PropertyEditor for the required type via registerCustomEditor.
- Make the source type convertible (e.g. add a String constructor or static valueOf) so a fallback editor can handle it.
- Bind to a primitive/wrapper and convert manually afterwards.
Example fix
// before — binding "2023-01-01" to a custom LocalDate holder with no converter
// -> 'no matching editors or conversion strategy found'
// after — register a converter
conversionService.addConverter(new Converter<String, LocalDate>() {
public LocalDate convert(String s) { return LocalDate.parse(s); }
}); Defensive patterns
Strategy: validation
Validate before calling
// Confirm a conversion path exists before binding
TypeDescriptor src = TypeDescriptor.forObject(value);
if (!conversionService.canConvert(src, TypeDescriptor.valueOf(requiredType))) {
throw new IllegalStateException("no converter " + value.getClass() + " -> " + requiredType);
} Type guard
static boolean canConvert(ConversionService cs, Object v, Class<?> t) {
return cs != null && cs.canConvert(TypeDescriptor.forObject(v), TypeDescriptor.valueOf(t));
} Prevention
- Register a Converter for every custom value type used in binding.
- Wire a DefaultConversionService into BeanWrapper / @ConfigurationProperties binding.
- Add a startup assertion listing convertible types for your domain.
When it happens
Trigger: Binding a property of type X from a String (or other value) when no PropertyEditor is registered for X and the configured ConversionService has no matching Converter. Common with custom value types, record components, or third-party types in @ConfigurationProperties / DataBinder.
Common situations: Using a custom type in a @ConfigurationProperties bean without registering a converter; binding to a java.time type before the default converters are active; removing the default editors via setDefaultEditorsActive(false).
Related errors
- Cannot convert value of type '{}' to required type '{}'[ for
- Failed to convert value of type '{}' to required type '{}'
- 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/8a4d0e315ab49743.
Report an issue: GitHub.