{"record":{"id":"498880b9ed88385a","repo":"testcontainers/testcontainers-java","slug":"could-not-create-disabled-file-disabled-getabsolutepath-on","errorCode":null,"errorMessage":"Could not create DISABLED file '${disabled.getAbsolutePath()}' on host machine.","messagePattern":"Could not create DISABLED file '(.+?)' on host machine\\.","errorType":"exception","errorClass":"ContainerLaunchException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java","lineNumber":112,"sourceCode":"        final File extensionDir = new File(tempDir, hiveMQExtension.getId());\n        FileUtils.writeStringToFile(\n            new File(extensionDir, \"hivemq-extension.xml\"),\n            String.format(\n                VALID_EXTENSION_XML,\n                hiveMQExtension.getId(),\n                hiveMQExtension.getName(),\n                hiveMQExtension.getVersion(),\n                hiveMQExtension.getPriority(),\n                hiveMQExtension.getStartPriority()\n            ),\n            Charset.defaultCharset()\n        );\n\n        if (hiveMQExtension.isDisabledOnStartup()) {\n            final File disabled = new File(extensionDir, \"DISABLED\");\n            final boolean newFile = disabled.createNewFile();\n            if (!newFile) {\n                throw new ContainerLaunchException(\n                    \"Could not create DISABLED file '\" + disabled.getAbsolutePath() + \"' on host machine.\"\n                );\n            }\n        }\n\n        // Shadow Gradle plugin doesn't know how to handle ShrinkWrap's SPI definitions\n        // This workaround creates the mappings programmatically\n        // TODO write a custom Gradle Shadow transformer?\n        ExtensionLoader extensionLoader = ShrinkWrap.getDefaultDomain().getConfiguration().getExtensionLoader();\n        extensionLoader.addOverride(JavaArchive.class, JavaArchiveImpl.class);\n        extensionLoader.addOverride(ZipExporter.class, ZipExporterImpl.class);\n\n        final JavaArchive javaArchive = ShrinkWrap\n            .create(JavaArchive.class)\n            .addAsServiceProvider(EXTENSION_MAIN_CLASS_NAME, hiveMQExtension.getMainClass().getName());\n\n        putSubclassesIntoJar(hiveMQExtension.getId(), hiveMQExtension.getMainClass(), javaArchive);\n        for (final Class<?> additionalClass : hiveMQExtension.getAdditionalClasses()) {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java#L94-L130","documentation":"HiveMQExtension.createExtension builds the extension directory on the host. When the extension is marked disabledOnStartup, it must create a DISABLED marker file inside that directory; if File.createNewFile() returns false (file already existed or creation failed), a ContainerLaunchException is thrown.","triggerScenarios":"Calling HiveMQExtension.builder()...disabledOnStartup(true).build() and having the framework create the extension directory where a DISABLED file already exists (stale run leftovers) or the filesystem refuses the create (permissions, read-only dir).","commonSituations":"Reusing a persistent/temp directory across test runs where the previous DISABLED file was not cleaned; running tests as a user without write permission on the temp dir; parallel test executions sharing the same extension directory.","solutions":["Delete the stale extension directory (including DISABLED) before the test run.","Ensure the host directory is writable by the test process user.","Use a unique temp directory per test run to avoid collisions between parallel builds.","If reuse is intended, pre-create the DISABLED file yourself and avoid disabledOnStartup(true), or ignore the error."],"exampleFix":"// before\n// leftover /tmp/ext/DISABLED from previous run\nHiveMQExtension.builder().disabledOnStartup(true)...build();\n// after\nFileUtils.deleteDirectory(new File(\"/tmp/ext\"));\nHiveMQExtension.builder().disabledOnStartup(true)...build();","handlingStrategy":"validation","validationCode":"File extDir = new File(tempDir, \"my-extension\");\nif (extDir.exists()) FileUtils.deleteDirectory(extDir);\nif (!extDir.mkdirs()) throw new IllegalStateException(\"Cannot create extension dir: \" + extDir);","typeGuard":null,"tryCatchPattern":"try { HiveMQExtension ext = builder.disabledOnStartup(true).build(); } catch (ContainerLaunchException e) { log.error(\"DISABLED file issue: {}\", e.getMessage()); throw e; }","preventionTips":["Use a fresh, unique temp directory per test (e.g. Files.createTempDirectory with JUnit @TempDir).","Clean leftover extension directories between runs.","Run tests with a user that owns the temp directory."],"tags":["hivemq","file-creation","extension","stale-state"],"backgroundTag":"file-write-failed","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"}