{"record":{"id":"8b389f41ec9b142b","repo":"FasterXML/jackson-databind","slug":"module-without-defined-name","errorCode":null,"errorMessage":"Module ({}) without defined name","messagePattern":"Module \\((.+?)\\) without defined name","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/cfg/MapperBuilder.java","lineNumber":1136,"sourceCode":"    }\n\n    private void _addDependency(JacksonModule module)\n    {\n        _verifyModuleMetadata(module);\n        final Object moduleId = module.getRegistrationId();\n        if (_modules.containsKey(moduleId)) {\n            return;\n        }\n        for (JacksonModule dep : module.getDependencies()) {\n            _addDependency(dep);\n        }\n        _modules.put(moduleId, module);\n    }\n\n    private void _verifyModuleMetadata(JacksonModule module)\n    {\n        if (module.getModuleName() == null) {\n            throw new IllegalArgumentException(\"Module (\"+module.getClass().getName()+\") without defined name\");\n        }\n        if (module.version() == null) {\n            throw new IllegalArgumentException(\"Module (\"+module.getClass().getName()+\") without defined version\");\n        }\n    }\n\n    public B addModules(JacksonModule... modules)\n    {\n        for (JacksonModule module : modules) {\n            addModule(module);\n        }\n        return _this();\n    }\n\n    public B addModules(Iterable<? extends JacksonModule> modules)\n    {\n        for (JacksonModule module : modules) {\n            addModule(module);","sourceCodeStart":1118,"sourceCodeEnd":1154,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/cfg/MapperBuilder.java#L1118-L1154","documentation":"MapperBuilder._verifyModuleMetadata() requires every JacksonModule being registered to report a non-null module name (and a non-null version). If a module's getModuleName() returns null, the builder throws IllegalArgumentException naming the module's class. This enforces that all registered modules are self-describing, which Jackson needs for module registry/deduplication and diagnostics.","triggerScenarios":"Registering a module whose getModuleName() returns null; a module built via SimpleModule without calling setName()/withName(); a module class whose constructor doesn't seed the name; a dynamically-proxied or mock module that returns null for getModuleName().","commonSituations":"Creating a SimpleModule with the no-arg constructor (which historically defaulted a name) after a version change that made the default null; a test double/mock module; a module copied from 2.x where name defaults differed; a programmatically-constructed module that forgot the builder's name step.","solutions":["Give the module a name: new SimpleModule(\"myModule\", PackageVersion.VERSION) or module.setModuleName(\"myModule\").","For a custom JacksonModule subclass, override getModuleName() to return a constant non-null string.","If building modules generically, always pass a name in the constructor/builder.","Add a test that asserts every module you publish returns a non-null name and version."],"exampleFix":"// before\nSimpleModule m = new SimpleModule(); // name may be null in 3.x\nmapperBuilder.addModule(m); // throws\n// after\nSimpleModule m = new SimpleModule(\"myModule\", Version.unknownVersion());\nmapperBuilder.addModule(m);","handlingStrategy":"validation","validationCode":"JacksonModule m = ...;\nif (m.getModuleName() == null) throw new IllegalArgumentException(\"module name null: \" + m.getClass());\nmapperBuilder.addModule(m);","typeGuard":"boolean moduleHasName(JacksonModule m) {\n    return m != null && m.getModuleName() != null && !m.getModuleName().isEmpty();\n}","tryCatchPattern":"try {\n    mapperBuilder.addModule(m);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"without defined name\")) {\n        // set a name and retry, or skip the module\n    }\n    throw e;\n}","preventionTips":["Always construct SimpleModule with a name: new SimpleModule(\"myModule\", Version.unknownVersion()).","Override getModuleName() in custom JacksonModule subclasses to return a constant.","Unit-test that every module you publish returns a non-null name and version.","For test doubles, subclass SimpleModule rather than mocking JacksonModule."],"tags":["module","mapper-builder","configuration","metadata"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}