{"record":{"id":"8ef62e3e7aa2a871","repo":"testcontainers/testcontainers-java","slug":"file-mountablefile-getfilesystempath-does-not-exist","errorCode":null,"errorMessage":"File '${mountableFile.getFilesystemPath()}' does not exist.","messagePattern":"File '(.+?)' does not exist\\.","errorType":"exception","errorClass":"ContainerLaunchException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java","lineNumber":413,"sourceCode":"     * <p>\n     * Must be called before the container is started.\n     *\n     * @param mountableFile    the file on the host machine\n     * @param pathInHomeFolder the path\n     * @return self\n     */\n    public @NotNull HiveMQContainer withFileInHomeFolder(\n        final @NotNull MountableFile mountableFile,\n        final @NotNull String pathInHomeFolder\n    ) {\n        final File file = new File(mountableFile.getResolvedPath());\n\n        if (pathInHomeFolder.trim().isEmpty()) {\n            throw new ContainerLaunchException(\"pathInHomeFolder must not be empty\");\n        }\n\n        if (!file.exists()) {\n            throw new ContainerLaunchException(\"File '\" + mountableFile.getFilesystemPath() + \"' does not exist.\");\n        }\n        final String containerPath = \"/opt/hivemq\" + PathUtil.prepareAppendPath(pathInHomeFolder);\n        withCopyFileToContainer(cloneWithFileMode(mountableFile), containerPath);\n        LOGGER.info(\"Putting file '{}' into container path '{}'.\", file.getAbsolutePath(), containerPath);\n        return self();\n    }\n\n    /**\n     * Disables the extension with the given name and extension directory name.\n     * This method blocks until the HiveMQ log for successful disabling is consumed or it times out after {timeOut}.\n     * Note: Disabling Extensions is a HiveMQ Enterprise feature, it will not work when using the HiveMQ Community Edition.\n     * <p>\n     * This can only be called once the container is started.\n     *\n     * @param extensionName      the name of the extension to disable\n     * @param extensionDirectory the name of the extension's directory\n     * @param timeout            the timeout\n     * @throws TimeoutException if the extension was not disabled within the configured timeout","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java#L395-L431","documentation":"withFileInHomeFolder resolves the MountableFile path on the host and requires the file to exist before copying it into /opt/hivemq + pathInHomeFolder in the container. A non-existent host file results in a ContainerLaunchException thrown before the container starts.","triggerScenarios":"Calling container.withFileInHomeFolder(MountableFile.forHostPath(missing), path) — directly or via withFileInExtensionHomeFolder — where the host file does not exist.","commonSituations":"File produced by a prior test/build step that failed or did not run; wrong resource path in CI; file deleted between resolution and call; classpath resource assumed to be a real file but packed inside a JAR.","solutions":["Verify the host file exists before the call and fail fast with a clear message.","Use an absolute path resolved from the classpath or project root.","In CI, ensure the file is generated/copied into the workspace before tests execute.","If the resource is inside a JAR, extract it to a temp file and mount that."],"exampleFix":"// before\ncontainer.withFileInHomeFolder(MountableFile.forHostPath(\"target/extra.xml\"), \"/extension/x/\");\n// after\nFile f = new File(\"target/extra.xml\");\nif (!f.exists()) throw new IllegalStateException(\"Missing: \" + f);\ncontainer.withFileInHomeFolder(MountableFile.forHostPath(f.getAbsolutePath()), \"/extension/x/\");","handlingStrategy":"validation","validationCode":"File f = new File(hostPath);\nif (!f.exists()) throw new IllegalStateException(\"Host file missing: \" + f.getAbsolutePath());\nif (pathInHomeFolder == null || pathInHomeFolder.isBlank()) throw new IllegalArgumentException(\"pathInHomeFolder required\");","typeGuard":null,"tryCatchPattern":"try { container.withFileInHomeFolder(mountable, path); } catch (ContainerLaunchException e) { log.error(\"Mount failed: {}\", e.getMessage()); throw e; }","preventionTips":["Extract classpath resources inside JARs to temp files before mounting.","Generate required files in a test setup step that fails loudly if skipped.","Use absolute paths anchored to the project root."],"tags":["hivemq","file-not-found","testcontainers"],"backgroundTag":"file-not-found","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}