testcontainers/testcontainers-java · error · IllegalArgumentException
extension name must not be null or empty
Error message
extension name must not be null or empty
What it means
HiveMQExtension.Builder.build() validates that the extension's name was set before constructing the HiveMQExtension. The builder accumulates id, name, version, mainClass, etc., and refuses to build an extension with a null or empty name, since HiveMQ requires extensions to be named.
Solutions
- Call .name("your-extension-name") on the builder before build()
- Validate the source config/map contains a non-empty name before building
- Add a unit test constructing the extension with all required fields
Example fix
// before
new HiveMQExtension.Builder().id("ext").version("1.0").mainClass(MyExt.class).build();
// after
new HiveMQExtension.Builder().id("ext").name("my-extension").version("1.0").mainClass(MyExt.class).build(); Defensive patterns
Strategy: validation
Validate before calling
if (name == null || name.isEmpty()) throw new IllegalStateException("Set builder.name() before build()"); Type guard
boolean hasName = builder != null && name != null && !name.isEmpty();
Prevention
- Always set id, name, version, mainClass together in one helper method
- Validate config maps for required extension fields before building
When it happens
Trigger: Calling HiveMQExtension.Builder.build() without calling name(...) first, or calling name(null)/name("").
Common situations: Programmatically constructing extensions where fields come from config files or maps and the 'name' key is missing or empty; copying a builder setup and dropping the name() call.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- extension main class must not be null
- extension version must not be null or empty
- Could not create DISABLED file
- Could not parse extension id from
- Extension disabling timed out after
AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12).
Data as JSON: /api/errors/eba1426529253e1d.
Report an issue: GitHub.
Appendix: source
Thrown at modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java:205
private boolean disabledOnStartup = false;
@Nullable
private Class<?> mainClass;
@NotNull
private final LinkedList<Class<?>> additionalClasses = new LinkedList<>();
/**
* Builds the {@link HiveMQExtension} with the provided values or default values.
* @return the HiveMQ Extension
*/
public @NotNull HiveMQExtension build() {
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("extension id must not be null or empty");
}
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("extension name must not be null or empty");
}
if (version == null || version.isEmpty()) {
throw new IllegalArgumentException("extension version must not be null or empty");
}
if (mainClass == null) {
throw new IllegalArgumentException("extension main class must not be null");
}
return new HiveMQExtension(
id,
name,
version,
priority,
startPriority,
disabledOnStartup,
mainClass,
additionalClasses
);
}View on GitHub (pinned to 8e549514e3)