{"record":{"id":"a4d21920e8aa23eb","repo":"flowable/flowable-engine","slug":"an-error-occurs-converting-output-value-as-json","errorCode":null,"errorMessage":"An error occurs converting output value as JSon","messagePattern":"An error occurs converting output value as JSon","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/data/TransformationDataOutputAssociation.java","lineNumber":63,"sourceCode":"    public void evaluate(DelegateExecution execution) {\n        Object value = this.transformation.getValue(execution);\n\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();\n        VariableTypes variableTypes = processEngineConfiguration.getVariableServiceConfiguration().getVariableTypes();\n        try {\n            variableTypes.findVariableType(value);\n        } catch (final FlowableException e) {\n            // Couldn't find a variable type that is able to serialize the output value\n            // Perhaps the output value is a Java bean, we try to convert it as JSon\n            try {\n                final ObjectMapper mapper = JsonMapper.builder()\n                        // By default, Jackson serializes only public fields, we force to use all fields of the Java Bean\n                        .changeDefaultVisibility(visibilityChecker -> visibilityChecker.withFieldVisibility(Visibility.ANY))\n                        .build();\n\n                value = mapper.convertValue(value, JsonNode.class);\n            } catch (final IllegalArgumentException e1) {\n                throw new FlowableException(\"An error occurs converting output value as JSon\", e1);\n            }\n        }\n\n        execution.setVariable(this.getTarget(), value);\n    }\n}\n","sourceCodeStart":45,"sourceCodeEnd":70,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/data/TransformationDataOutputAssociation.java#L45-L70","documentation":"TransformationDataOutputAssociation.evaluate converts the source expression value to a Jackson JsonNode when the target variable is JSON, using ObjectMapper.convertValue. If Jackson cannot convert the value (e.g. an incompatible bean/structure), it throws IllegalArgumentException, which Flowable wraps in this FlowableException. The target variable is then never set.","triggerScenarios":"A dataOutputAssociation with a transformation whose evaluated output cannot be converted to JsonNode by Jackson — e.g. the expression returns an object Jackson cannot serialize (no accessible properties, recursive structure, incompatible types) while the code path forces JsonNode conversion.","commonSituations":"Transformation expressions returning custom beans with fields Jackson refuses to handle; cyclic object graphs; value types that map ambiguously to JSON (e.g. raw Map with non-String keys); upgrades changing Jackson visibility handling.","solutions":["Inspect the wrapped IllegalArgumentException cause to see which property/conversion failed and fix the source object (add getters, remove cycles, use @JsonIgnore)","Make the expression return a Jackson-friendly type (Map, List, primitives, JsonNode) instead of an exotic bean","Register a custom serializer/module on the ObjectMapper path or pre-convert the value yourself in the expression","Ensure the bean has a no-arg constructor and public accessors so convertValue can map it"],"exampleFix":"// before: expression returns a bean Jackson cannot map (cyclic reference)\nexpression.setValue(userEntity);\n\n// after: return a simple DTO\nUserDto dto = UserDto.from(userEntity);\nexpression.setValue(dto);","handlingStrategy":"try-catch","validationCode":"// Pre-check: ensure the value is Jackson-convertible\nnew ObjectMapper().convertValue(value, JsonNode.class); // throws IllegalArgumentException early if not","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.createDeployment().addClasspathResource(process).deploy();\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"converting output value as JSon\")) {\n        // fix the transformation source object; log cause\n        logger.warn(\"JSON transformation failed: {}\", e.getCause());\n    }\n}","preventionTips":["Make dataOutputAssociation sources plain Maps/lists/primitives or JsonNode","Avoid cyclic object graphs in beans used as transformation outputs","Test transformation expressions with representative values before deploying","Keep beans with no-arg constructors and standard getters"],"tags":["jackson","json","data-association","serialization","bpmn"],"backgroundTag":"json-marshal-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}