{"record":{"id":"4d75b891038ddc89","repo":"testcontainers/testcontainers-java","slug":"could-not-parse-extension-id-from-fileabsolutepath","errorCode":null,"errorMessage":"Could not parse extension id from '{fileAbsolutePath}'","messagePattern":"Could not parse extension id from '(.+?)'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java","lineNumber":274,"sourceCode":"        }\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        }\n        return self();\n    }\n\n    private @NotNull String getExtensionDirectoryName(final @NotNull File extensionDirectory) throws IOException {\n        final File file = new File(extensionDirectory, \"hivemq-extension.xml\");\n        final String xml = FileUtils.readFileToString(file, StandardCharsets.UTF_8);\n        final Matcher matcher = EXTENSION_ID_PATTERN.matcher(xml);\n\n        if (!matcher.find()) {\n            throw new IllegalStateException(\"Could not parse extension id from '\" + file.getAbsolutePath() + \"'\");\n        }\n        return matcher.group(1);\n    }\n\n    /**\n     * Removes the specified prepackaged extension folders from '/opt/hivemq/extensions' before the container is started.\n     * <p>\n     * Must be called before the container is started.\n     *\n     * @param extensionIds the prepackaged extensions to remove\n     * @return self\n     */\n    public @NotNull HiveMQContainer withoutPrepackagedExtensions(final @NotNull String... extensionIds) {\n        Collections.addAll(prepackagedExtensionsToRemove, extensionIds);\n        return self();\n    }\n\n    /**","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQContainer.java#L256-L292","documentation":"getExtensionDirectoryName reads the hivemq-extension.xml descriptor inside an extension directory and extracts the extension id with the EXTENSION_ID_PATTERN regex. If the XML file exists but contains no recognizable <id> element, the library cannot determine the extension's identity and throws IllegalStateException. This is effectively a malformed or unexpected extension descriptor.","triggerScenarios":"Called from extensionDirName when a directory mounted/copied under /opt/hivemq/extensions contains a hivemq-extension.xml that does not match EXTENSION_ID_PATTERN (e.g. missing <id> tag, differently formatted XML, empty file, or a non-HiveMQ extension layout).","commonSituations":"Mounting a custom or hand-written extension folder into the container; a build tool (Gradle/Maven shadow packaging) producing an extension XML without the id element; HiveMQ SDK version change altering the descriptor schema; pointing at a directory that has an unrelated or placeholder hivemq-extension.xml.","solutions":["Open the hivemq-extension.xml in the offending extension directory and ensure it contains an <id>some-id</id> element.","Verify you are pointing at the actual extension directory (the one containing hivemq-extension.xml), not a parent or resource root.","Rebuild the extension with the HiveMQ SDK so the descriptor is generated correctly.","If prepackaged HiveMQ extensions are involved, ensure they were extracted fully and not partially copied."],"exampleFix":"// before\n// extensions dir contains hivemq-extension.xml without <id>\n// after\n<hivemq-extension>\n    <id>my-extension</id>\n    <name>My Extension</name>\n    <version>1.0.0</version>\n</hivemq-extension>","handlingStrategy":"validation","validationCode":"File xml = new File(extDir, \"hivemq-extension.xml\");\nString content = Files.readString(xml.toPath());\nif (!content.contains(\"<id>\")) throw new IllegalStateException(\"hivemq-extension.xml missing <id> in \" + extDir);","typeGuard":null,"tryCatchPattern":"try { container.enableExtension(id); } catch (IllegalStateException e) { /* inspect hivemq-extension.xml */ }","preventionTips":["Always generate the extension with the HiveMQ SDK so hivemq-extension.xml includes <id>.","Sanity-check mounted extension directories contain a well-formed descriptor before starting the container."],"tags":["hivemq","extension-descriptor","xml-parsing","testcontainers"],"backgroundTag":"invalid-identifier-format","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"}