{"record":{"id":"da394111ea8c46e5","repo":"eclipse-vertx/vert.x","slug":"mapping","errorCode":null,"errorMessage":"Mapping ","messagePattern":"Mapping ","errorType":"exception","errorClass":"EncodeException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java21/io/vertx/core/json/jackson/v3/JacksonCodec.java","lineNumber":373,"sourceCode":"      } else if (json instanceof JsonArray) {\n        json = ((JsonArray)json).getList();\n      }\n      if (json instanceof Map) {\n        generator.writeStartObject();\n        for (Map.Entry<String, ?> e : ((Map<String, ?>)json).entrySet()) {\n          generator.writeName(e.getKey());\n          Object value = e.getValue();\n          encodeJson0(value, generator);\n        }\n        generator.writeEndObject();\n      } else if (json instanceof List) {\n        generator.writeStartArray();\n        for (Object item : (List<?>) json) {\n          encodeJson0(item, generator);\n        }\n        generator.writeEndArray();\n      } else if (!encodeSingleType(generator, json)) {\n        throw new EncodeException(\"Mapping \" + json.getClass().getName() + \"  is not available without Jackson Databind on the classpath\");\n      }\n    } catch (IOException e) {\n      throw new EncodeException(e.getMessage(), e);\n    }\n  }\n\n  /**\n   * This is a way to overcome a limit of OpenJDK on MaxRecursiveInlineLevel:\n   * avoiding the \"direct\" recursive calls allow the JIT to have a better inlining budget for the recursive calls.\n   */\n  private static void encodeJson0(Object json, JsonGenerator generator) throws EncodeException {\n    try {\n      if (json instanceof JsonObject) {\n        json = ((JsonObject)json).getMap();\n      } else if (json instanceof JsonArray) {\n        json = ((JsonArray)json).getList();\n      }\n      if (json instanceof Map) {","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java21/io/vertx/core/json/jackson/v3/JacksonCodec.java#L355-L391","documentation":"JacksonCodec.encodeJson encodes Vert.x JSON values (Map/List/String/Number/Boolean/null) to a Jackson generator without databind. When the value's type is not one of the supported single types (encodeSingleType returns false), it throws EncodeException naming the class, stating that mapping is unavailable without Jackson Databind on the classpath. The 'Mapping ' prefix is concatenated with the class name of the unsupported object.","triggerScenarios":"Calling JacksonCodec.encodeJson(generator, value) with a POJO, a JsonObject, a byte[], an Instant, or any type that is not Map/List/String/Number/Boolean/null while Jackson's databind module (jackson-databind) is not on the classpath, so no fallback POJO serialization exists.","commonSituations":"Running with only jackson-core on the classpath (databind excluded to reduce size or excluded by the v3 jackson module packaging) and trying to encode arbitrary POJOs; passing a JsonObject rather than its underlying map; encoding Buffer/Instant directly.","solutions":["Add com.fasterxml.jackson.core:jackson-databind to the classpath so POJO/extra types can be serialized","Convert unsupported types manually before encoding: pass JsonObject.getMap()/the underlying Map, call toString(), or pre-encode to supported JSON types","Encode Buffer/Instant as base64 Strings or ISO strings yourself before calling encodeJson"],"exampleFix":"// before\nJacksonCodec.encodeJson(generator, myPojo); // EncodeException: Mapping com.acme.Pojo is not available...\n// after\nJacksonCodec.encodeJson(generator, Json.encodeToBuffer(myPojo).toJsonObject().getMap());\n// or: add jackson-databind to the classpath","handlingStrategy":"validation","validationCode":"static boolean isEncodableWithoutDatabind(Object v) {\n  return v == null || v instanceof Map || v instanceof List || v instanceof String\n      || v instanceof Number || v instanceof Boolean;\n}","typeGuard":"static boolean canEncode(Object v) {\n  return !(v instanceof JsonObject) && isEncodableWithoutDatabind(v);\n}","tryCatchPattern":"try {\n  JacksonCodec.encodeJson(generator, value);\n} catch (EncodeException e) {\n  if (e.getMessage().contains(\"without Jackson Databind\")) {\n    // add jackson-databind or convert value to supported types\n  }\n}","preventionTips":["Ensure jackson-databind is on the runtime classpath if POJO encoding is needed","Convert JsonObject to its underlying map, and Buffer/Instant to String, before encoding","Keep a unit test that encodes the app's value types to catch classpath regressions"],"tags":["java","json","encoding","classpath","databind"],"backgroundTag":"json-serialization-failed","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}