{"record":{"id":"c4e4821061c3615b","repo":"OpenAPITools/openapi-generator","slug":"usejackson3-requires-serializationlibrary-jackson","errorCode":null,"errorMessage":"useJackson3 requires serializationLibrary=jackson","messagePattern":"useJackson3 requires serializationLibrary=jackson","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java","lineNumber":494,"sourceCode":"\n        boolean useSpringBoot4 = additionalProperties.containsKey(USE_SPRING_BOOT4)\n                && convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT4);\n        if (JVM_SPRING_RESTCLIENT.equals(getLibrary()) && useSpringBoot4 && !isUseJackson3()) {\n            setUseJackson3(true);\n            additionalProperties.put(USE_JACKSON_3, true);\n            applyJackson3Package();\n        }\n\n        if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {\n            setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));\n            additionalProperties.put(this.serializationLibrary.name(), true);\n        } else {\n            additionalProperties.put(this.serializationLibrary.name(), true);\n        }\n\n        if (isUseJackson3()) {\n            if (this.serializationLibrary != SERIALIZATION_LIBRARY_TYPE.jackson) {\n                throw new IllegalArgumentException(\"useJackson3 requires serializationLibrary=jackson\");\n            }\n            if (additionalProperties.containsKey(\"openApiNullable\")\n                    && Boolean.parseBoolean(additionalProperties.get(\"openApiNullable\").toString())) {\n                throw new IllegalArgumentException(\"openApiNullable cannot be set with useJackson3\");\n            }\n            if (!JVM_OKHTTP4.equals(getLibrary()) && !JVM_SPRING_RESTCLIENT.equals(getLibrary())) {\n                throw new IllegalArgumentException(\"useJackson3 is only supported for the jvm-okhttp4 and jvm-spring-restclient libraries at this time.\");\n            }\n            if (JVM_SPRING_RESTCLIENT.equals(getLibrary()) && !useSpringBoot4) {\n                throw new IllegalArgumentException(\"useJackson3 with jvm-spring-restclient requires useSpringBoot4=true.\");\n            }\n        }\n\n        if (additionalProperties.containsKey(MAP_FILE_BINARY_TO_BYTE_ARRAY)) {\n            setMapFileBinaryToByteArray(convertPropertyToBooleanAndWriteBack(MAP_FILE_BINARY_TO_BYTE_ARRAY));\n        }\n        additionalProperties.put(MAP_FILE_BINARY_TO_BYTE_ARRAY, mapFileBinaryToByteArray);\n        if (mapFileBinaryToByteArray) {","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java#L476-L512","documentation":"In processOpts, enabling useJackson3 requires serializationLibrary=jackson because the Jackson 3 templates (tools.jackson packages) only exist for the jackson stack. Thrown as IllegalArgumentException. Trap: with library=jvm-spring-restclient and useSpringBoot4=true, useJackson3 is force-enabled (KotlinClientCodegen.java:479-481), so leaving serializationLibrary at its default moshi — or explicitly choosing gson/kotlinx_serialization — trips this even if you never asked for Jackson 3.","triggerScenarios":"`-g kotlin -p useJackson3=true` without serializationLibrary=jackson (default moshi); `--library=jvm-spring-restclient -p useSpringBoot4=true,serializationLibrary=gson`; programmatic setUseJackson3(true) while moshi remains selected.","commonSituations":"Upgrading a Spring Boot 3→4 pipeline where the flag flips on automatically; combining options from different README examples; teams assuming useJackson3 is an independent toggle.","solutions":["Add `serializationLibrary=jackson` (exact) alongside `useJackson3=true`.","For jvm-spring-restclient + useSpringBoot4=true, remember useJackson3 turns itself on — pair it with serializationLibrary=jackson or stay on Boot 3.","If you need moshi/gson/kotlinx_serialization, keep useJackson3 off (Jackson 2) — that combination is simply unsupported."],"exampleFix":"# before\nopenapi-generator-cli generate -g kotlin --library=jvm-spring-restclient -i api.yaml -p useSpringBoot4=true\n# after\nopenapi-generator-cli generate -g kotlin --library=jvm-spring-restclient -i api.yaml -p useSpringBoot4=true,serializationLibrary=jackson","handlingStrategy":"validation","validationCode":"# shell: enforce the jackson3 ⇒ jackson pairing before running\nuse_j3=\"${USE_JACKSON_3:-false}\"\nsl=\"${SERIALIZATION_LIBRARY:-moshi}\"\nif [ \"$use_j3\" = \"true\" ] && [ \"$sl\" != \"jackson\" ]; then\n  echo \"useJackson3=true requires serializationLibrary=jackson (currently: $sl)\" >&2; exit 2\nfi\n# also covers the spring-restclient auto-enable:\n[ \"$LIBRARY\" = \"jvm-spring-restclient\" ] && [ \"$USE_SPRING_BOOT4\" = \"true\" ] && sl=\"jackson\"","typeGuard":null,"tryCatchPattern":"try {\n    DefaultGenerator().opts(clientOptInput).generate()\n} catch (e: IllegalArgumentException) {\n    throw IllegalStateException(\"Incompatible kotlin generator options: ${e.message}\", e) // do not retry\n}","preventionTips":["Always pass serializationLibrary=jackson together with useJackson3=true.","Know the auto-enable: jvm-spring-restclient + useSpringBoot4 turns useJackson3 on implicitly.","Keep a compatibility matrix for kotlin library × serializationLibrary × boot flag in your build docs."],"tags":["openapi-generator","kotlin","jackson","serialization","configuration"],"backgroundTag":"incompatible-generator-options","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}