{"record":{"id":"d47e8c90d5179332","repo":"testcontainers/testcontainers-java","slug":"extension-path-could-not-be-mounted-it-does-not-exist","errorCode":null,"errorMessage":"Extension '{path}' could not be mounted. It does not exist.","messagePattern":"Extension '(.+?)' could not be mounted\\. It does not exist\\.","errorType":"exception","errorClass":"ContainerLaunchException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java","lineNumber":246,"sourceCode":"        return self();\n    }\n\n    /**\n     * Puts the given extension folder into '/opt/hivemq/temp-extensions/{directory-name}' inside the container.\n     * It must at least contain a valid hivemq-extension.xml and a valid extension.jar in order to be executed.\n     * The directory-name is taken from the id defined in the hivemq-extension.xml.\n     * <p>\n     * Must be called before the container is started.\n     * <p>\n     * The contents of the '/opt/hivemq/temp-extensions/' directory are copied to '/opt/hivemq/extensions/' before the container is started.\n     *\n     * @param mountableExtension the extension folder on the host machine\n     * @return self\n     */\n    public @NotNull HiveMQContainer withExtension(final @NotNull MountableFile mountableExtension) {\n        final File extensionDir = new File(mountableExtension.getResolvedPath());\n        if (!extensionDir.exists()) {\n            throw new ContainerLaunchException(\n                \"Extension '\" + mountableExtension.getFilesystemPath() + \"' could not be mounted. It does not exist.\"\n            );\n        }\n        if (!extensionDir.isDirectory()) {\n            throw new ContainerLaunchException(\n                \"Extension '\" +\n                mountableExtension.getFilesystemPath() +\n                \"' could not be mounted. It is not a directory.\"\n            );\n        }\n        try {\n            final String extensionDirName = getExtensionDirectoryName(extensionDir);\n            final String containerPath = \"/opt/hivemq/temp-extensions/\" + extensionDirName;\n            withCopyFileToContainer(cloneWithFileMode(mountableExtension), containerPath);\n            LOGGER.info(\"Putting extension '{}' into '{}'\", extensionDirName, containerPath);\n        } catch (final Exception e) {\n            throw new ContainerLaunchException(e.getMessage() == null ? \"\" : e.getMessage(), e);\n        }","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java#L228-L264","documentation":"The MountableFile-based withExtension overload resolves the host path and validates it before mounting. If the resolved file/folder does not exist on disk, HiveMQContainer throws this ContainerLaunchException immediately rather than letting the container fail at copy time with a more obscure Docker error.","triggerScenarios":"Passing a MountableFile pointing to a host path that doesn't exist — e.g. forHostPath(\"target/hivemq-extension\") built before the Maven/Gradle build produced it, a deleted build output, or a typo'd relative path resolved against the wrong working directory.","commonSituations":"Running the test before the extension module was built (mvn test without mvn install of the extension); CI checkout skipping a build step; paths that only exist after a code-gen step.","solutions":["Build the extension before running the test (e.g. dependsOn the extension build task or run mvn install for the extension module).","Verify the path with new File(path).exists() — print getResolvedPath() to see where it actually points.","Use MountableFile.forClasspathResource(...) for resources packaged with the test so the path always exists."],"exampleFix":"// before\nwithExtension(MountableFile.forHostPath(\"target/my-extension\")); // not built yet\n\n// after\n// build first (e.g. mvn -pl my-extension install), then:\nFile dir = new File(\"target/my-extension\");\nif (!dir.exists()) throw new IllegalStateException(\"Run 'mvn install' first\");\nwithExtension(MountableFile.forHostPath(dir));","handlingStrategy":"validation","validationCode":"File dir = new File(mountableExtension.getResolvedPath());\nif (!dir.exists()) {\n    throw new IllegalStateException(\"Extension path missing (build it first): \" + dir.getAbsolutePath());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use MountableFile.forClasspathResource for packaged resources.","Ensure the extension build runs before tests (Gradle test.dependsOn buildExtension / Maven install).","Log getResolvedPath() when debugging path resolution."],"tags":["testcontainers","hivemq","extension","file-not-found"],"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"}