{"record":{"id":"4f572d9b5a2b06de","repo":"testcontainers/testcontainers-java","slug":"license-file-mountablelicense-getfilesystempath-does-not","errorCode":null,"errorMessage":"License file '${mountableLicense.getFilesystemPath()}' does not exist.","messagePattern":"License file '(.+?)' does not exist\\.","errorType":"exception","errorClass":"ContainerLaunchException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java","lineNumber":316,"sourceCode":"     */\n    public @NotNull HiveMQContainer withoutPrepackagedExtensions() {\n        removeAllPrepackagedExtensions = true;\n        return self();\n    }\n\n    /**\n     * Puts the given license into '/opt/hivemq/license/' inside the container.\n     * It must end with '.lic' or '.elic'.\n     * <p>\n     * Must be called before the container is started.\n     *\n     * @param mountableLicense the license file on the host machine\n     * @return self\n     */\n    public @NotNull HiveMQContainer withLicense(final @NotNull MountableFile mountableLicense) {\n        final File licenseFile = new File(mountableLicense.getResolvedPath());\n        if (!licenseFile.exists()) {\n            throw new ContainerLaunchException(\n                \"License file '\" + mountableLicense.getFilesystemPath() + \"' does not exist.\"\n            );\n        }\n        if (!licenseFile.getName().endsWith(\".lic\") && !licenseFile.getName().endsWith(\".elic\")) {\n            throw new ContainerLaunchException(\n                \"License file '\" + mountableLicense.getFilesystemPath() + \"' does not end wit '.lic' or '.elic'.\"\n            );\n        }\n        final String containerPath = \"/opt/hivemq/license/\" + licenseFile.getName();\n        withCopyFileToContainer(cloneWithFileMode(mountableLicense), containerPath);\n        LOGGER.info(\"Putting license '{}' into '{}'.\", licenseFile.getAbsolutePath(), containerPath);\n        return self();\n    }\n\n    /**\n     * Overwrites the HiveMQ configuration in '/opt/hivemq/conf/' inside the container.\n     * <p>\n     * Must be called before the container is started.","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java#L298-L334","documentation":"withLicense(MountableFile) resolves the license file path on the host and checks that it exists before mounting it into the HiveMQ container at /opt/hivemq/license. If the resolved path does not exist on the host filesystem, a ContainerLaunchException is thrown immediately, before the container starts.","triggerScenarios":"Calling container.withLicense(MountableFile.forHostPath(...)) with a path that does not exist on the host machine.","commonSituations":"Typo in the license file path; license file present in CI but not committed/mounted into the build environment; relative path resolved against a different working directory; license stored in a secret that was not mounted in the test environment.","solutions":["Verify the license file path exists on the host (new File(path).exists()) before calling withLicense.","Use an absolute path or Mountable.forHostFile with the correct path.","In CI, ensure the .lic/.elic license file is provisioned (secret mount, artifact download) before tests run.","Check the working directory that relative paths resolve against."],"exampleFix":"// before\ncontainer.withLicense(MountableFile.forHostPath(\"/opt/hivemq/license.lic\")); // file missing\n// after\nFile lic = new File(\"/opt/hivemq/license.lic\");\nif (!lic.exists()) throw new IllegalStateException(\"License missing: \" + lic);\ncontainer.withLicense(MountableFile.forHostPath(lic.getAbsolutePath()));","handlingStrategy":"validation","validationCode":"File lic = new File(licensePath);\nif (!lic.exists()) throw new IllegalStateException(\"License file not found: \" + lic.getAbsolutePath());","typeGuard":null,"tryCatchPattern":"try { container.withLicense(MountableFile.forHostPath(licensePath)); } catch (ContainerLaunchException e) { log.error(\"License missing: {}\", e.getMessage()); throw e; }","preventionTips":["Resolve license paths from classpath/test resources with absolute paths.","Provision the license as a CI secret/file before the test phase.","Fail fast with a precondition check in test setup."],"tags":["hivemq","license","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"}