{"record":{"id":"1e2438fe2b9b21b2","repo":"alibaba/nacos","slug":"100-1e2438","errorCode":"100","errorMessage":"Nacos serialize for class [%s] failed. ","messagePattern":"Nacos serialize for class \\[(.+?)\\] failed\\. ","errorType":"error_code","errorClass":"NacosSerializationException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/nacos/common/json/Jackson3JsonAdapterDelegate.java","lineNumber":141,"sourceCode":"        synchronized (subtypes) {\n            if (!subtypes.contains(subtype)) {\n                subtypes.add(subtype);\n            }\n            mapper = createObjectMapper(subtypes);\n            canonicalMapper = createCanonicalObjectMapper(subtypes);\n        }\n    }\n    \n    private JavaType constructJavaType(Type type) {\n        return mapper.constructType(type);\n    }\n    \n    private <T> T write(Object obj, JsonWriter<T> writer) {\n        try {\n            return writer.write();\n        } catch (JacksonException e) {\n            Class<?> serializedClass = obj == null ? Object.class : obj.getClass();\n            throw new NacosSerializationException(serializedClass, e);\n        }\n    }\n    \n    private <T> T read(JsonReader<T> reader, Class<?> cls) {\n        try {\n            return reader.read();\n        } catch (JacksonException e) {\n            throw new NacosDeserializationException(cls, e);\n        }\n    }\n    \n    private <T> T read(JsonReader<T> reader, Type type) {\n        try {\n            return reader.read();\n        } catch (JacksonException e) {\n            throw new NacosDeserializationException(type, e);\n        }\n    }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/common/src/main/java/com/alibaba/nacos/common/json/Jackson3JsonAdapterDelegate.java#L123-L159","documentation":"Thrown by Jackson3JsonAdapterDelegate.write() when the Jackson 3 ObjectMapper throws a JacksonException during serialization. Wrapped as NacosSerializationException (code 100) with the serialized class (Object.class for null). Functionally the Jackson 3 counterpart of error 743, but catches the Jackson 3 base JacksonException rather than Jackson 2's JsonProcessingException.","triggerScenarios":"Using the JACKSON3 adapter and serializing an object that Jackson 3 cannot handle: circular references, classes lacking a no-arg constructor or @JsonCreator constructor, unsupported JDK types, or types needing a module not registered on the delegate mapper.","commonSituations":"Switched the JSON backend to Jackson 3 but the model relied on Jackson 2-specific annotations or modules; serializing java.time types without the jsr310-equivalent module for Jackson 3; anonymous/record/class-without-constructor classes under Jackson 3's stricter defaults.","solutions":["Read NacosSerializationException.getCause() for the exact JacksonException and offending field/property.","Add a no-argument constructor or a @JsonCreator constructor compatible with Jackson 3.","Register the equivalent Jackson 3 module (jsr310 / parameter-names) on the delegate mapper via the adapter's subtype registration.","Reproduce with a standalone Jackson 3 ObjectMapper to isolate from Nacos.","If a class is incompatible with Jackson 3 and cannot be changed, fall back to the Jackson 2 adapter."],"exampleFix":"// before — Jackson 3, no default constructor\npublic class Config { private String data; public Config(String data){this.data=data;} }\njsonAdapter.toJson(new Config(\"x\")); // code 100\n\n// after\npublic class Config {\n    public Config() {}\n    private String data;\n    public Config(String data){this.data=data;}\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String json = jsonAdapter.toJson(obj);\n} catch (NacosSerializationException e) {\n    log.error(\"Jackson3 serialize failed for {}\", e.getSerializedClass(), e.getCause());\n    throw e;\n}","preventionTips":["Ensure serialized classes have a no-arg or @JsonCreator constructor compatible with Jackson 3.","Register Jackson 3 equivalents of modules you used under Jackson 2 (jsr310, parameter-names).","Reproduce with a standalone Jackson 3 ObjectMapper to isolate model issues."],"tags":["serialization","jackson3","json","runtime"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}