quarkusio/quarkus · error · IllegalArgumentException
The <clazz.getSimpleName()> class [<instanceClass>] could no
Error message
The <clazz.getSimpleName()> class [<instanceClass>] could not be instantiated!
What it means
After resolving the configured setting value to a Class, loadSettingInstance instantiates it via its no-arg constructor. If the class is abstract/an interface, lacks a public no-arg constructor, its constructor throws, or instantiation is otherwise illegal, the builder wraps the reflective exception in this IllegalArgumentException.
Source
Thrown at extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java:705
instanceClass = classLoaderService.classForName(settingStringValue);
} else {
try {
instanceClass = (Class<? extends T>) Class.forName(settingStringValue);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Can't load class: " + settingStringValue, e);
}
}
} else {
throw new IllegalArgumentException(
"The provided " + settingName + " setting value [" + settingValue + "] is not supported!");
}
if (instanceClass != null) {
try {
instance = instanceClass.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new IllegalArgumentException(
"The " + clazz.getSimpleName() + " class [" + instanceClass + "] could not be instantiated!",
e);
}
}
return instance;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Make the class concrete with a public no-argument constructor.
- Read the nested 'Caused by' (InstantiationException, NoSuchMethodException, InvocationTargetException) for the root cause.
- Move logic depending on CDI/services out of the constructor into integrate()/contribute() callbacks.
- Verify the class implements the expected interface (e.g. MetadataBuilderContributor).
Example fix
// before
public abstract class MyContributor implements MetadataBuilderContributor { ... }
// after
public class MyContributor implements MetadataBuilderContributor {
public MyContributor() { }
@Override public void contribute(MetadataBuilder mb) { ... }
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-instantiate to catch problems before boot
Object c = Class.forName("com.example.MyContributor").getConstructor().newInstance();
if (!(c instanceof MetadataBuilderContributor)) throw new IllegalStateException("Wrong interface"); Try / catch
try {
bootPersistenceUnit();
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("could not be instantiated")) {
log.error("Contributor must be concrete with a public no-arg constructor", e.getCause());
}
} Prevention
- Make configured classes concrete, public, with public no-arg constructors
- Never do CDI/service lookups in constructors used at static-init
- Unit-test reflective instantiation of configured classes
- Confirm the class implements the expected interface
When it happens
Trigger: Configuring a contributor/naming-strategy class that is abstract, an interface, has only constructor arguments, or whose no-arg constructor throws at static-init time — reached through settings like metadata_builder_contributor or naming strategy settings.
Common situations: Pointing a strategy setting at an interface; contributor requiring DI; constructor failing because Quarkus beans/CDI aren't initialized during static init; shading/obfuscation removing default constructors.
Related errors
- Unable to instantiate integrator <integratorClass>
- Unable to create instance of Logging Filter ''
- RuntimeException(e)
- The Hibernate ORM configuration in Quarkus does not support
- Datasource must be defined for persistence unit '%s'. Settin
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/b099cd3439eaffa2.
Report an issue: GitHub.