{"record":{"id":"56e2d7a2d4e24ad0","repo":"OpenAPITools/openapi-generator","slug":"this-library-currently-only-supports-jackson-seria","errorCode":null,"errorMessage":"This library currently only supports jackson serialization. Try adding '--additional-properties serializationLibrary=jackson' to your command.","messagePattern":"This library currently only supports jackson serialization\\. Try adding '--additional-properties serializationLibrary=jackson' to your command\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java","lineNumber":875,"sourceCode":"        additionalProperties.put(JVM, true);\n        additionalProperties.put(JVM_OKHTTP, true);\n\n        if (JVM_OKHTTP4.equals(getLibrary())) {\n            additionalProperties.put(JVM_OKHTTP4, true);\n        }\n\n        supportedLibraries.put(JVM_OKHTTP, \"A workaround to use the same template folder for both 'jvm-okhttp3' and 'jvm-okhttp4'.\");\n        setLibrary(JVM_OKHTTP);\n\n        // jvm specific supporting files\n        supportingFiles.add(new SupportingFile(\"infrastructure/Errors.kt.mustache\", infrastructureFolder, \"Errors.kt\"));\n        supportingFiles.add(new SupportingFile(\"infrastructure/ResponseExtensions.kt.mustache\", infrastructureFolder, \"ResponseExtensions.kt\"));\n        supportingFiles.add(new SupportingFile(\"infrastructure/ApiResponse.kt.mustache\", infrastructureFolder, \"ApiResponse.kt\"));\n    }\n\n    private void processJvmSpring(final String infrastructureFolder) {\n        if (getSerializationLibrary() != SERIALIZATION_LIBRARY_TYPE.jackson) {\n            throw new RuntimeException(\"This library currently only supports jackson serialization. Try adding '--additional-properties serializationLibrary=jackson' to your command.\");\n        }\n\n        commonJvmMultiplatformSupportingFiles(infrastructureFolder);\n        addSupportingSerializerAdapters(infrastructureFolder);\n\n        additionalProperties.put(JVM_SPRING, true);\n        additionalProperties.put(JVM, true);\n    }\n\n    private void processJvmSpringWebClientLibrary(final String infrastructureFolder) {\n        processJvmSpring(infrastructureFolder);\n        additionalProperties.put(JVM_SPRING_WEBCLIENT, true);\n    }\n\n    private void processJvmSpringRestClientLibrary(final String infrastructureFolder) {\n        if (additionalProperties.getOrDefault(USE_SPRING_BOOT3, false).equals(false)\n                && additionalProperties.getOrDefault(USE_SPRING_BOOT4, false).equals(false)) {\n            throw new RuntimeException(\"This library requires Spring Boot 3 or 4. Try adding '--additional-properties useSpringBoot3=true' or '--additional-properties useSpringBoot4=true' to your command.\");","sourceCodeStart":857,"sourceCodeEnd":893,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java#L857-L893","documentation":"processJvmSpring — shared by the jvm-spring-webclient and jvm-spring-restclient libraries (KotlinClientCodegen.java:886, 896) — hard-requires serializationLibrary=jackson because the Spring stack templates are Jackson-based. Since the default serializationLibrary is moshi, selecting either Spring library without the explicit flag throws this RuntimeException.","triggerScenarios":"`-g kotlin --library=jvm-spring-webclient` (default moshi → throw); `--library=jvm-spring-restclient -p serializationLibrary=gson|moshi|kotlinx_serialization`.","commonSituations":"Switching a kotlin client from okhttp4 (moshi default worked) to a Spring library by changing only --library; option presets that omit serializationLibrary.","solutions":["Add `-p serializationLibrary=jackson` when using jvm-spring-webclient or jvm-spring-restclient.","Remember the pairing rules: spring libraries ⇒ jackson; jvm-volley ⇒ gson; other libraries default to moshi."],"exampleFix":"# before\nopenapi-generator-cli generate -g kotlin --library=jvm-spring-webclient -i api.yaml\n# after\nopenapi-generator-cli generate -g kotlin --library=jvm-spring-webclient -i api.yaml -p serializationLibrary=jackson","handlingStrategy":"validation","validationCode":"# shell: spring libraries demand jackson\ncase \"$LIBRARY\" in\n  jvm-spring-webclient|jvm-spring-restclient)\n    [ \"${SERIALIZATION_LIBRARY:-moshi}\" = \"jackson\" ] || { echo \"$LIBRARY requires serializationLibrary=jackson\" >&2; exit 2; } ;;\nesac","typeGuard":null,"tryCatchPattern":"try {\n    DefaultGenerator().opts(clientOptInput).generate()\n} catch (e: RuntimeException) {\n    throw IllegalStateException(\"Spring library serialization mismatch: ${e.message}\", e)\n}","preventionTips":["Always set serializationLibrary=jackson when selecting a jvm-spring-* library.","Do not reuse an okhttp4 (moshi) options line with a Spring library.","Document the pairing: spring ⇒ jackson, volley ⇒ gson, others ⇒ moshi default."],"tags":["openapi-generator","kotlin","spring","serialization","configuration"],"backgroundTag":"serialization-library-mismatch","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}