testcontainers/testcontainers-java · error · ContainerLaunchException
HiveMQ config file ' ' does not exist.
Error message
HiveMQ config file '${mountableConfig.getFilesystemPath()}' does not exist. What it means
withHiveMQConfig(MountableFile) resolves the given config file path on the host and requires it to exist before copying it into the container as /opt/hivemq/conf/config.xml. If the resolved path does not exist, a ContainerLaunchException is thrown before container start.
Solutions
- Check that the config file path exists on the host before calling withHiveMQConfig.
- Use an absolute path (e.g. resolved from classpath: Paths.get(getClass().getResource(...).toURI())).
- Ensure the config.xml is included as a test resource and present in the CI environment.
- Fix relative-path resolution issues by anchoring to the project root.
Example fix
// before
container.withHiveMQConfig(MountableFile.forHostPath("config.xml")); // relative, missing
// after
Path cfg = Paths.get("src/test/resources/config.xml").toAbsolutePath();
container.withHiveMQConfig(MountableFile.forHostPath(cfg.toString())); Defensive patterns
Strategy: validation
Validate before calling
File cfg = Paths.get(configPath).toAbsolutePath().toFile();
if (!cfg.exists()) throw new IllegalStateException("HiveMQ config not found: " + cfg); Try / catch
try { container.withHiveMQConfig(MountableFile.forHostPath(cfg.getAbsolutePath())); } catch (ContainerLaunchException e) { log.error("Config missing: {}", e.getMessage()); throw e; } Prevention
- Store config.xml under src/test/resources and resolve via classpath to an absolute path.
- Verify the resource exists in a @BeforeAll setup step.
When it happens
Trigger: Calling container.withHiveMQConfig(MountableFile.forHostPath(...)) with a path that does not exist on the host machine.
Common situations: Config file generated by a previous build step that did not run; path typo; relative path resolved from a different working directory; test resources not copied in CI checkout.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Extension ' ' could not be mounted. It does not exist.
- License file ' ' does not exist.
- File ' ' does not exist.
- Unknown transport type
- Invalid value for dockerconfig.source
AI-assisted analysis of testcontainers/testcontainers-java@8e549514e3 (2026-09-12).
Data as JSON: /api/errors/3672bde031ae82bf.
Report an issue: GitHub.
Appendix: source
Thrown at modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java:342
}
final String containerPath = "/opt/hivemq/license/" + licenseFile.getName();
withCopyFileToContainer(cloneWithFileMode(mountableLicense), containerPath);
LOGGER.info("Putting license '{}' into '{}'.", licenseFile.getAbsolutePath(), containerPath);
return self();
}
/**
* Overwrites the HiveMQ configuration in '/opt/hivemq/conf/' inside the container.
* <p>
* Must be called before the container is started.
*
* @param mountableConfig the config file on the host machine
* @return self
*/
public @NotNull HiveMQContainer withHiveMQConfig(final @NotNull MountableFile mountableConfig) {
final File config = new File(mountableConfig.getResolvedPath());
if (!config.exists()) {
throw new ContainerLaunchException(
"HiveMQ config file '" + mountableConfig.getFilesystemPath() + "' does not exist."
);
}
final String containerPath = "/opt/hivemq/conf/config.xml";
withCopyFileToContainer(cloneWithFileMode(mountableConfig), containerPath);
LOGGER.info("Putting '{}' into '{}'.", config.getAbsolutePath(), containerPath);
return self();
}
/**
* Puts the given file into the root of the extension's home '/opt/hivemq/temp-extensions/{extensionId}/'.
* <p>
* Must be called before the container is started.
* <p>
* The contents of the '/opt/hivemq/temp-extensions/' directory are copied to '/opt/hivemq/extensions/' before the container is started.
*
* @param file the file on the host machine
* @param extensionId the extensionView on GitHub (pinned to 8e549514e3)