Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

morphline java code error

Highlighted

morphline java code error

New Contributor

I try to read a json message from Flume and convert some fields with java code.

 

If I remove the java block everything work fine, data are saved to HDFS as avro file. When I add the java nothing append or if i use "put" instead of "replaceValues" I got an error message:

 

15/10/08 11:17:35 WARN morphline.MorphlineHandlerImpl: Morphline /home/user/flume_agent/morphlines.conf@morphline1 failed to process record: {_attachment_body=[[B@79c1fc2a], timestamp=[1444295855777], topic=[user_test]}

my morphline file:

 

morphlines : [
    {
     	id : morphline1
        importCommands : ["org.kitesdk.**"]
        commands : [
            { readJson {
                outputClass : com.fasterxml.jackson.databind.JsonNode
              }
            }
            {
              extractJsonPaths {
                flatten : true
                paths : {
                  latitude: "/var"
                  longitude: "/var"
                  gps_timestamp: "/var"
                }
              }
            }
            {
             	java {
                    imports: """
                        import java.util.*;
                    """
                    code: """
                       	record.replaceValues("latitude","latitude");
                        record.replaceValues("longitude","longitude");
                       	record.replaceValues("gps_timestamp","timestamp");
                       	return child.process(record);
                    """
                }
            }
            { toAvro {
              schemaFile: /home/romain.sagean/flume_agent/geoloc.avsc
            } }
            # serialize the object as avro
            { writeAvroToByteArray: {
              format: containerlessBinary
            } }
        ]
    }
]

 

1 REPLY 1

Re: morphline java code error

Expert Contributor
To automatically print diagnostic information such as the content of records as they pass through the morphline commands, consider enabling TRACE log level, for example by adding the following line to your log4j.properties file:

log4j.logger.org.kitesdk.morphline=TRACE


Don't have an account?
Coming from Hortonworks? Activate your account here