{"record":{"id":"dc7d42c1c60d9b6b","repo":"OpenAPITools/openapi-generator","slug":"usejackson3-is-only-supported-for-the-native-a","errorCode":null,"errorMessage":"useJackson3 is only supported for the 'native', 'apache-httpclient', 'jersey3', 'restclient', 'resttemplate', and 'webclient' libraries. The Spring libraries also require useSpringBoot4=true.","messagePattern":"useJackson3 is only supported for the 'native', 'apache-httpclient', 'jersey3', 'restclient', 'resttemplate', and 'webclient' libraries\\. The Spring libraries also require useSpringBoot4=true\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java","lineNumber":411,"sourceCode":"        final boolean libOkHttpGson = isLibrary(OKHTTP_GSON) || StringUtils.isBlank(getLibrary());\n        final boolean libRestAssured = isLibrary(REST_ASSURED);\n        final boolean libRestClient = isLibrary(RESTCLIENT);\n        final boolean libRestEasy = isLibrary(RESTEASY);\n        final boolean libRestTemplate = isLibrary(RESTTEMPLATE);\n        final boolean libRetrofit2 = isLibrary(RETROFIT_2);\n        final boolean libVertx = isLibrary(VERTX);\n        final boolean libWebClient = isLibrary(WEBCLIENT);\n\n        // default jackson unless overridden by setSerializationLibrary\n        this.jackson = !additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY) ||\n                SERIALIZATION_LIBRARY_JACKSON.equals(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));\n        convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, this::setUseOneOfDiscriminatorLookup);\n        convertPropertyToBooleanAndWriteBack(USE_JACKSON_3, this::setUseJackson3);\n        convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT4, this::setUseSpringBoot4);\n        if (useJackson3 && (libRestClient || libRestTemplate || libWebClient) && !useSpringBoot4) {\n            throw new IllegalArgumentException(\"useJackson3 for the restclient, resttemplate, and webclient libraries requires useSpringBoot4=true\");\n        } else if (useJackson3 && !libNative && !libApache && !libJersey3 && !libRestClient && !libRestTemplate && !libWebClient) {\n            throw new IllegalArgumentException(\"useJackson3 is only supported for the 'native', 'apache-httpclient', 'jersey3', 'restclient', 'resttemplate', and 'webclient' libraries. \" +\n                    \"The Spring libraries also require useSpringBoot4=true.\");\n        }\n\n        if (this.useJackson3) {\n            this.applyJackson3Package();\n        } else {\n            this.applyJackson2Package();\n        }\n\n        if(this.useSpringBoot4) {\n            setUseJakartaEe(true);\n            applyJakartaPackage();\n        }\n\n        // override parent one\n        importMapping.put(\"JsonDeserialize\", (useJackson3 ? JACKSON3_PACKAGE : JACKSON2_PACKAGE) + \".databind.annotation.JsonDeserialize\");\n\n        // RxJava","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java#L393-L429","documentation":"Thrown by JavaClientCodegen.processOpts when the useJackson3 option is enabled for a Java client 'library' whose templates have no Jackson 3 support. Only 'native', 'apache-httpclient', 'jersey3', 'restclient', 'resttemplate', and 'webclient' accept useJackson3. The three Spring libraries (restclient, resttemplate, webclient) additionally require useSpringBoot4=true because their Jackson 3 dependency lines only exist on the Spring Boot 4 / Spring 7 template path. The check runs after convertPropertyToBooleanAndWriteBack resolves the flags, so any truthy value ('true', boolean TRUE) in additionalProperties activates it.","triggerScenarios":"Running -g java with --library okhttp-gson|feign|retrofit2|jersey2|vertx|google-api-client|resteasy|microprofile|rest-assured and --additional-properties useJackson3=true. Or using --library restclient|resttemplate|webclient with useJackson3=true but without useSpringBoot4=true (the first branch of the same if/else). Also triggered when the option arrives via a Gradle/Maven plugin configOptions block or a JSON/YAML config file passed with --config.","commonSituations":"Teams upgrading a generated client to Jackson 3 / Java 17 stacks copy the useJackson3=true flag from another project without changing the HTTP library. Others enable useJackson3 on the default okhttp-gson library (library left blank), which is not in the supported set. A third group sets it with Spring libraries while still pinned to Spring Boot 3 via useSpringBoot3 or the default.","solutions":["If you want Jackson 3, switch to a supported HTTP library: --library native (or apache-httpclient, jersey3)","If you must keep restclient/resttemplate/webclient, also pass --additional-properties useSpringBoot4=true","If you must keep an unsupported library (okhttp-gson, feign, ...), remove useJackson3 from additionalProperties and stay on Jackson 2","Check your --config JSON or Gradle 'configOptions' block for a stray useJackson3 entry, not just the CLI flags"],"exampleFix":"# before\nopenapi-generator-cli generate -g java -i petstore.yaml \\\n  --library okhttp-gson --additional-properties useJackson3=true\n\n# after\nopenapi-generator-cli generate -g java -i petstore.yaml \\\n  --library native --additional-properties useJackson3=true\n\n# alternative for Spring stacks\nopenapi-generator-cli generate -g java -i petstore.yaml \\\n  --library restclient --additional-properties useJackson3=true,useSpringBoot4=true","handlingStrategy":"validation","validationCode":"// Validate java client options before invoking the generator\nboolean useJackson3 = Boolean.parseBoolean(String.valueOf(opts.getOrDefault(\"useJackson3\", \"false\")));\nString library = String.valueOf(opts.getOrDefault(\"library\", \"okhttp-gson\"));\nSet<String> jackson3Libs = Set.of(\"native\", \"apache-httpclient\", \"jersey3\", \"restclient\", \"resttemplate\", \"webclient\");\nboolean useSpringBoot4 = Boolean.parseBoolean(String.valueOf(opts.getOrDefault(\"useSpringBoot4\", \"false\")));\nif (useJackson3 && !jackson3Libs.contains(library)) throw new IllegalArgumentException(\"useJackson3 unsupported for library=\" + library);\nif (useJackson3 && (library.equals(\"restclient\") || library.equals(\"resttemplate\") || library.equals(\"webclient\")) && !useSpringBoot4)\n    throw new IllegalArgumentException(\"useJackson3 on \" + library + \" requires useSpringBoot4=true\");","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOpts).generate();\n} catch (IllegalArgumentException e) {\n    // option-matrix violations surface here; rethrow with the command line used\n    throw new IllegalStateException(\"Generation config rejected: \" + String.join(\",\", args) + \" -> \" + e.getMessage(), e);\n}","preventionTips":["Keep a per-generator validated config map in CI and lint additionalProperties against `config-help -g java` output","Treat useJackson3, useSpringBoot4, and library as one bundle — change them together in the same config commit","Print the effective additionalProperties at generation start so failures are reproducible from logs"],"tags":["java","openapi-generator","code-generation","jackson","configuration","option-validation"],"backgroundTag":"unsupported-option-combination","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}