CA APM - java.lang.NullPointerException errors during agent startup when Java Flight Recorder is enabled.

Document ID : KB000040917
Last Modified Date : 14/02/2018
Show Technical Document Details


We get a lot of the following exceptions reported in the Java agent log on startup

2/16/16 08:03:02 AM EET [ERROR] [IntroscopeAgent.Agent]
at oracle.jrockit.jfr.jdkevents.IoTracer.fileWriteBegin(
at sun.misc.IoTrace.fileWriteBegin(Unknown Source)


The agent and application functionality does not appear to be affected so what is the significance of these messages?



This is relevant to any Java agent environment where the Java Flight Recorder (JFR) ( -XX:+FlightRecorder) is enabled in the JVM



This is is a problem of the way JFR has be written

To run JFR, the fileWriteToken variable needs to be initialized through init() call before the execution of oracle.jrockit.jfr.jdkevents.IoTracer.fileWriteBegin() method. JFR initialization happens after premain(). When trying to write to the log (here reading the Autoprobe log ) during premain(), JFR gets an event callback due to write() API of OutputStream. But since JFR is not initialized completely, fileWriteToken becomes null and throws a NPE from fileWriteBegin(). This is a problem of JFR where they have not considered that the javaagent could be running before its initialization phase.

These exceptions are generated during Agent startup and once JFR is initialized, they disappear. There is no breakage in functionality of either the Agent or JFR.


Additional Information:

The problem is not specific to APM but any monitor implemented via the –javaagent feature of the JVM