{"record":{"id":"b705a3172711f9c4","repo":"OtterMind/Chat2DB","slug":"data-export-json-error","errorCode":"data.export.json.error","errorMessage":"data.export.json.error","messagePattern":"data\\.export\\.json\\.error","errorType":"exception","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/task/export/json/JsonDataExporter.java","lineNumber":88,"sourceCode":"                        writer.println(\",\");\n                    }\n                    asyncContext.info(DateUtil.formatTime(new Date()) + \":\" + String.format(\"Exported %d rows\", n));\n                    writeBatch(writer, objectMapper, dataBatch);\n                    firstBatch = false;\n                }\n            }\n            writer.println(\"]\");\n        }, asyncContext, asyncContext::checkCancelled);\n    }\n\n    private void writeBatch(PrintWriter writer, ObjectMapper objectMapper, List<Map<String, Object>> dataBatch) {\n        try {\n            String jsonBatch = objectMapper.writeValueAsString(dataBatch);\n            writer.println(jsonBatch.substring(1, jsonBatch.length() - 1));\n            writer.flush();\n            dataBatch.clear();\n        } catch (JsonProcessingException e) {\n            throw new BusinessException(\"data.export.json.error\", null, e);\n        }\n    }\n\n}\n","sourceCodeStart":70,"sourceCodeEnd":93,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/task/export/json/JsonDataExporter.java#L70-L93","documentation":"BusinessException 'data.export.json.error' from JsonDataExporter.writeBatch when ObjectMapper.writeValueAsString throws JsonProcessingException serializing a data batch to JSON during streaming export.","triggerScenarios":"A row map contains a value ObjectMapper cannot serialize (e.g. a non-JSON-serializable type, a self-referencing object, or a JDBC type without a serializer), or serialization hits a JDK type restriction.","commonSituations":"ResultSet column mapped to an exotic SQL/JDBC type (BLOB, array, custom); null-handling producing an unsupported Java type; mapper misconfiguration after an upgrade.","solutions":["Inspect the wrapped JsonProcessingException for the offending type and convert that column to a String/plain value before batching.","Configure the ObjectMapper used by the exporter (register JavaTimeModule / SqlModule) to handle the JDBC types present.","Skip or stringify problematic columns in the export query/projection."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-configure the exporter ObjectMapper with JDBC/time modules\nObjectMapper om = new ObjectMapper();\nom.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());\nom.disable(com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);","typeGuard":null,"tryCatchPattern":"try { String batch = objectMapper.writeValueAsString(dataBatch); }\ncatch (JsonProcessingException e) {\n    throw new BusinessException(\"data.export.json.error\", null, e);\n}","preventionTips":["Register JavaTime/Sql modules on the export ObjectMapper.","Convert exotic JDBC types (BLOB/array) to String before batching.","Test export with the actual column types of high-variance tables."],"tags":["export","json","serialization","jackson"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}