{"record":{"id":"6fc89ec4da87d8b0","repo":"testcontainers/testcontainers-java","slug":"extension-main-class-must-not-be-null","errorCode":null,"errorMessage":"extension main class must not be null","messagePattern":"extension main class must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java","lineNumber":211,"sourceCode":"        @NotNull\n        private final LinkedList<Class<?>> additionalClasses = new LinkedList<>();\n\n        /**\n         * Builds the {@link HiveMQExtension} with the provided values or default values.\n         * @return the HiveMQ Extension\n         */\n        public @NotNull HiveMQExtension build() {\n            if (id == null || id.isEmpty()) {\n                throw new IllegalArgumentException(\"extension id must not be null or empty\");\n            }\n            if (name == null || name.isEmpty()) {\n                throw new IllegalArgumentException(\"extension name must not be null or empty\");\n            }\n            if (version == null || version.isEmpty()) {\n                throw new IllegalArgumentException(\"extension version must not be null or empty\");\n            }\n            if (mainClass == null) {\n                throw new IllegalArgumentException(\"extension main class must not be null\");\n            }\n            return new HiveMQExtension(\n                id,\n                name,\n                version,\n                priority,\n                startPriority,\n                disabledOnStartup,\n                mainClass,\n                additionalClasses\n            );\n        }\n\n        /**\n         * Sets the identifier of the {@link HiveMQExtension}.\n         *\n         * @param id the identifier, must not be empty\n         * @return the {@link Builder}","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/hivemq/src/main/java/org/testcontainers/hivemq/HiveMQExtension.java#L193-L229","documentation":"HiveMQExtension.Builder.build() validates that mainClass was set; unlike the other fields it must only be non-null. The mainClass is the ExtensionMain implementation HiveMQ will instantiate inside the container.","triggerScenarios":"Calling build() without ever calling mainClass(...) on the builder.","commonSituations":"Forgetting to wire the extension's entry-point class; refactoring that removed the mainClass() call; building a shared test extension helper where mainClass is a parameter that was passed as null.","solutions":["Call .mainClass(MyExtensionMain.class) before build()","Ensure the class passed implements com.hivemq.extension.sdk.api.ExtensionMain","Check any builder helper/wrapper actually forwards the mainClass parameter"],"exampleFix":"// before\nbuilder.id(\"ext\").name(\"n\").version(\"1.0\").build();\n// after\nbuilder.id(\"ext\").name(\"n\").version(\"1.0\").mainClass(MyExtensionMain.class).build();","handlingStrategy":"validation","validationCode":"if (mainClass == null) throw new IllegalStateException(\"mainClass is required: pass your ExtensionMain implementation\");","typeGuard":"boolean validMain = mainClass != null && com.hivemq.extension.sdk.api.ExtensionMain.class.isAssignableFrom(mainClass);","tryCatchPattern":"try { builder.build(); } catch (IllegalArgumentException e) { /* report which required field is missing */ }","preventionTips":["Pass the entry-point class literal directly rather than via variables","Centralize extension construction in a test fixture"],"tags":["hivemq","builder-validation","null-argument"],"backgroundTag":"null-argument","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"}