You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Dan Groves (JIRA)" <ji...@apache.org> on 2017/04/25 19:58:04 UTC

[jira] [Created] (AMQ-6662) NullPointerException in org.apache.activemq.broker.jmx.Log4JConfigView

Dan Groves created AMQ-6662:
-------------------------------

             Summary: NullPointerException in org.apache.activemq.broker.jmx.Log4JConfigView
                 Key: AMQ-6662
                 URL: https://issues.apache.org/jira/browse/AMQ-6662
             Project: ActiveMQ
          Issue Type: Bug
    Affects Versions: 5.14.5
            Reporter: Dan Groves


My company's application uses JMX with ActiveMQ and log4j-over-slf4j version 1.7.2.  While trying to get the get the attributes for the ActiveMQ Log4JConfiguration bean, our application gets the following NullPointerException:

{noformat}
Caused by: java.lang.NullPointerException: null
	at org.apache.activemq.broker.jmx.Log4JConfigView.getRootLogLevel(Log4JConfigView.java:53) ~[activemq-broker-5.14.5.jar:5.14.5]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_112]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_112]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) ~[na:1.8.0_112]
	at sun.reflect.GeneratedMethodAccessor548.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_112]
	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) ~[na:1.8.0_112]
	at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:112) ~[na:1.8.0_112]
	at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:46) ~[na:1.8.0_112]
	at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237) ~[na:1.8.0_112]
	at com.sun.jmx.mbeanserver.PerInterface.getAttribute(PerInterface.java:83) ~[na:1.8.0_112]
	at com.sun.jmx.mbeanserver.MBeanSupport.getAttribute(MBeanSupport.java:206) ~[na:1.8.0_112]
	at javax.management.StandardMBean.getAttribute(StandardMBean.java:372) ~[na:1.8.0_112]
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:647) ~[na:1.8.0_112]
{noformat} 

I stripped out the rest of the stack trace to hide our IP.

From {{Log4JConfigView:getRootLogLevel}}:

{noformat}
    @Override
    public String getRootLogLevel() throws Exception {
        ClassLoader cl = getClassLoader();

        if (!isLog4JAvailable(cl)) {
            return null;
        }

        Class<?> loggerClass = getLoggerClass(cl);
        if (loggerClass == null) {
            return null;
        }

        Method getRootLogger = loggerClass.getMethod("getRootLogger", new Class[]{});
        Method getLevel = loggerClass.getMethod("getLevel", new Class[]{});
        Object rootLogger = getRootLogger.invoke(null, (Object[])null);

        return getLevel.invoke(rootLogger, (Object[])null).toString();
    }
{noformat}

Note the last line.  This line is fine if {{Logger::getLevel}} returns non-null, but will throw a {{NullPointerException}} otherwise.  The Apache log4j 1.x  Javadoc says that {{Logger::getLevel}} can return null.  The Javadoc for log4j 2.x doesn't say if {{Logger::getLevel}} can return null.  Log4j-over-slf4j's implementation of {{Logger::getLevel}} always returns null, following the log4j 1.x API:

https://jira.qos.ch/browse/SLF4J-65



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)