avro tools and log4j and log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory) and WARNING: An illegal reflective access operation has occurred

Download https://repo1.maven.org/maven2/org/apache/avro/avro-tools/1.8.2/avro-tools-1.8.2.jar from

java -jar /path/to/avro-tools-1.8.2.jar tojson /path/to/file.avro 
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.hadoop.security.authentication.util.KerberosUtil (file:/path/to/avro-tools-1.8.2.jar) to method sun.security.krb5.Config.getInstance()
WARNING: Please consider reporting this to the maintainers of org.apache.hadoop.security.authentication.util.KerberosUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
{"body":"a1","timestamp":"2021-12-15T23:00:00.000Z"}
{"body":"b1","timestamp":"2021-12-15T23:00:01.000Z"}
{"body":"c1","timestamp":"2021-12-15T23:00:01.000Z"}

Fix ‘log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).’ by passing location of log4j.properties file:

java -Dlog4j.configuration=file:/path/to/log4j.properties \
 -jar /path/to/avro-tools-1.8.2.jar tojson /path/to/file.avro 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.hadoop.security.authentication.util.KerberosUtil (file:/path/to/avro-tools-1.9.2.jar) to method sun.security.krb5.Config.getInstance()
WARNING: Please consider reporting this to the maintainers of org.apache.hadoop.security.authentication.util.KerberosUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
{"body":"a1","timestamp":"2021-12-15T23:00:00.000Z"}
{"body":"b1","timestamp":"2021-12-15T23:00:01.000Z"}
{"body":"c1","timestamp":"2021-12-15T23:00:01.000Z"}

Fix ‘WARNING: An illegal reflective access operation has occurred’ by upgrading avro tools to version 1.10 https://repo1.maven.org/maven2/org/apache/avro/avro-tools/1.10.2/avro-tools-1.10.2.jar

java -Dlog4j.configuration=file:/path/to/log4j.properties \
 -jar /path/to/avro-tools-1.10.2.jar tojson /path/to/file.avro
{"body":"a1","timestamp":"2021-12-15T23:00:00.000Z"}
{"body":"b1","timestamp":"2021-12-15T23:00:01.000Z"}
{"body":"c1","timestamp":"2021-12-15T23:00:01.000Z"}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s