{"record":{"id":"81e3c0841e8a78b0","repo":"testcontainers/testcontainers-java","slug":"the-class-com-hivemq-extension-sdk-api-extensionmain-was-not","errorCode":null,"errorMessage":"The class 'com.hivemq.extension.sdk.api.ExtensionMain' was not found in the classpath.","messagePattern":"The class 'com\\.hivemq\\.extension\\.sdk\\.api\\.ExtensionMain' was not found in the classpath\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java","lineNumber":312,"sourceCode":"         * This class MUST implement com.hivemq.extension.sdk.api.ExtensionMain.\n         *\n         * @param mainClass the main class\n         * @return the {@link Builder}\n         * @throws IllegalArgumentException if the provides class does not implement com.hivemq.extension.sdk.api.ExtensionMain}\n         * @throws IllegalStateException if com.hivemq.extension.sdk.api.ExtensionMain is not found in the classpath\n         */\n        public @NotNull Builder mainClass(final @NotNull Class<?> mainClass) {\n            try {\n                final Class<?> extensionMain = Class.forName(EXTENSION_MAIN_CLASS_NAME);\n                if (!extensionMain.isAssignableFrom(mainClass)) {\n                    throw new IllegalArgumentException(\n                        \"The provided class does not implement '\" + EXTENSION_MAIN_CLASS_NAME + \"'\"\n                    );\n                }\n                this.mainClass = mainClass;\n                return this;\n            } catch (final ClassNotFoundException e) {\n                throw new IllegalStateException(\n                    \"The class '\" + EXTENSION_MAIN_CLASS_NAME + \"' was not found in the classpath.\"\n                );\n            }\n        }\n\n        /**\n         * Adds an additional class to the .jar file of the {@link HiveMQExtension}.\n         *\n         * @param clazz the additional class\n         * @return the {@link Builder}\n         */\n        public @NotNull Builder addAdditionalClass(final @NotNull Class<?> clazz) {\n            this.additionalClasses.add(clazz);\n            return this;\n        }\n    }\n}\n","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java#L294-L330","documentation":"Builder.mainClass(Class) attempts to load com.hivemq.extension.sdk.api.ExtensionMain from the classpath; if the HiveMQ extension SDK API is not a dependency, a ClassNotFoundException is converted to this IllegalStateException, because extension validation is impossible without the SDK interface.","triggerScenarios":"Calling mainClass(...) while the hivemq-extension-sdk-api artifact is absent from the compile/test classpath.","commonSituations":"Adding the testcontainers hivemq module without adding the HiveMQ extension SDK dependency; scope misconfiguration (sdk only in another module); version change that removed a transitive sdk dependency.","solutions":["Add com.hivemq:hivemq-extension-sdk-api as a compile/test dependency","Check dependency scope so the SDK is on the classpath where the builder is used","Run mvn dependency:tree / gradle dependencies to confirm the SDK artifact resolves"],"exampleFix":"// before\n// no sdk dependency; builder.mainClass(...) throws IllegalStateException\n// after (Maven)\n<dependency><groupId>com.hivemq</groupId><artifactId>hivemq-extension-sdk-api</artifactId><version>4.x</version><scope>test</scope></dependency>","handlingStrategy":"try-catch","validationCode":"try { Class.forName(\"com.hivemq.extension.sdk.api.ExtensionMain\"); } catch (ClassNotFoundException e) { throw new IllegalStateException(\"Add hivemq-extension-sdk-api dependency\"); }","typeGuard":null,"tryCatchPattern":"try { builder.mainClass(MyExt.class); } catch (IllegalStateException e) { if (e.getMessage().contains(\"not found in the classpath\")) { /* add/fix hivemq-extension-sdk-api dependency */ } throw e; }","preventionTips":["Declare hivemq-extension-sdk-api explicitly next to the testcontainers hivemq module","Check the module's dependency tree in CI"],"tags":["hivemq","classpath","missing-dependency"],"backgroundTag":"class-not-found","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}