hibernate/hibernate-orm · error · InstantiationException
Could not instantiate type
Error message
Could not instantiate type
What it means
Error "Could not instantiate type" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/internal/TypeBeanInstanceProducer.java:42
public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBootstrapContext {
private final ConfigurationService configurationService;
private final ServiceRegistry serviceRegistry;
public TypeBeanInstanceProducer(ConfigurationService configurationService, ServiceRegistry serviceRegistry) {
this.configurationService = configurationService;
this.serviceRegistry = serviceRegistry;
}
@Override
public <B> B produceBeanInstance(Class<B> beanType) {
final var bootstrapContextAwareConstructor =
getConstructorOrNull( beanType, TypeBootstrapContext.class );
if ( bootstrapContextAwareConstructor != null ) {
try {
return bootstrapContextAwareConstructor.newInstance( this );
}
catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate type", beanType, e );
}
}
else {
final var constructor = getConstructorOrNull( beanType );
if ( constructor != null ) {
try {
return constructor.newInstance();
}
catch ( Exception e ) {
throw new InstantiationException( "Could not instantiate type", beanType, e );
}
}
else {
throw new InstantiationException( "No appropriate constructor for type", beanType );
}
}
}
View on GitHub (pinned to fad1729dce)
Solutions
- Check the causal exception: the type class failed to instantiate, typically due to a missing no-arg constructor or a constructor throwing.
- Ensure the custom type class is public, non-abstract, and has an accessible constructor.
- Verify the correct class name is registered for the TypeDefinition.
When it happens
Trigger: CDI-style bean creation of a custom Hibernate type fails.
Common situations: A custom UserType/AttributeConverter bean that cannot be instantiated, lacking an injectable or no-arg constructor.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/b5b69042ac6f17f0.
Report an issue: GitHub.