camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Narsi Nallamilli <>
Subject Camel dozer component unable to map custom function on field with null value
Date Wed, 09 Mar 2016 15:51:57 GMT
I am working on a camel project and user camel dozer for transformation(json
to json). However if source json's field is null it is not getting mapped to
targer json's field. So I though to map the field with custom function to
check if the field is null, if so return "null" value to map.

<field custom-converter-id="_customMapping"

caseNull function,
public Object caseNull(Object object){
	return null==object?"null":object;

I have found the issue in

In Object mapCustom(Object source) it is calling getClass() on the field
value and in this case being null, throwing Failed to load custom function.

try {
            Class<?> customClass = resolver.resolveClass(className);
            customObj = customClass.newInstance();

            // If a specific mapping operation has been supplied use that
            if (operation != null && prmTypesAndValues != null) {
                method = selectMethod(customClass, operation, source,
            } else if (operation != null) {
                method = customClass.getMethod(operation,
            } else {
                method = selectMethod(customClass, source);
        } catch (Exception e) {
            throw new RuntimeException("Failed to load custom function", e);

Please help with solution.

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message