4 Replies Latest reply on Sep 9, 2003 12:55 PM by jmychasiw

    NullPointerException and Log4j

    jmychasiw Newbie

      Sorry for the broad question but was wondering if anyone has seen anything similar.

      We are using jboss-3.0.4_tomcat-4.0.6 bundle and sending our application logs to it's internal log4j.

      We throw our own Exception from a session EJB and end up catching it in the Struts Layer, logging the error and displaying a message based on the resource key supplied in the Root Exception. We do this type of thing throughout the application without a problem.

      At some point a NullPointerException is thrown that overrides the original exception.

      I have isolated it to the logging area because if I shut off logging (set the level to FATAL) the problem goes away and we see the expected message.

      Has anyone seen this before?

      I first posted this to the log4j list and it was pointed out that log4j was given a NULL stack trace.

      see:http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg09185.html//www.mail-archive.com/log4j-user@jakarta.apache.org/msg09185.html

      This problem has been hard to trackdown because we have not been able to determine what is different about the methods that are having this problem.

      Any help would be appreciated..

      java.lang.NullPointerException
      at java.io.Writer.write(Writer.java:126)
      at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:39)
      at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:299)
      at org.apache.log4j.WriterAppender.append(WriterAppender.java:150)
      at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)
      at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:57)
      at org.apache.log4j.Category.callAppenders(Category.java:187)
      at org.apache.log4j.Category.forcedLog(Category.java:372)
      at org.apache.log4j.Category.log(Category.java:834)
      at org.jboss.logging.Logger.info(Logger.java:158)
      at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:391)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:208)
      at org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:380)
      at org.jboss.ejb.Container.invoke(Container.java:712)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
      at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
      at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:117)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
      at $Proxy656.saveCurrentTransferAdjustment(Unknown Source)
      at com.nlg.ar.common.interfaces.ArServiceImpl.saveCurrentTransferAdjustment(ArServiceImpl.java:1260)
      at com.nlg.ar.web.customer.action.CustomerAdjSaveTransferAction.executeAction(CustomerAdjSaveTransferAction.java:45)
      at com.nlg.ar.web.common.action.ArAuthenticatedAction.execute(ArAuthenticatedAction.java:56)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1349)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:507)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
      at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1033)
      at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:283)
      at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:436)
      at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:326)
      at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1349)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:507)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
      at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
      at java.lang.Thread.run(Thread.java:534)

        • 1. Re: NullPointerException and Log4j
          Raja Master

          What kind of exception are you throwing? Is it an Application exception?

          • 2. Re: NullPointerException and Log4j
            jmychasiw Newbie

            Thanks for the reply.

            Sorry for sounding dense but could you please clarify 'Application Exception'. I assume you mean an exception from our application?

            The Exception that we are throwing is our own exception. When I **shut logging off** the correct exception stack trace is below.

            I have noted that the logging line identifying
            Application Exception appears before our 'Application Exception'.

            [03 Sep 2003 08:24:23] INFO [HttpProcessor[8080][2]] [testCR-MGR] IP [127.0.0.1] org.jboss.ejb.plugins.LogInterceptor:info:158 - Application Exception
            com.nlg.ar.common.exception.AdjustmentException
            at com.nlg.ar.ejb.session.ArAccountingSessionBean.getSourceCode(ArAccountingSessionBean.java:1933)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:660)
            at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
            at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
            at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:301)
            at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:81)
            at $Proxy179.getSourceCode(Unknown Source)
            at com.nlg.ar.ejb.session.ArStatefulSessionBean.updateAdjustmentVO(ArStatefulSessionBean.java:3871)
            at com.nlg.ar.ejb.session.ArStatefulSessionBean.updateCurrentAdjustment(ArStatefulSessionBean.java:3654)
            at com.nlg.ar.ejb.session.ArStatefulSessionBean.saveCurrentAdjustment(ArStatefulSessionBean.java:3386)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:817)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
            at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:268)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:107)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:178)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:60)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
            at org.jboss.ejb.StatefulSessionContainer.invoke(StatefulSessionContainer.java:380)
            at org.jboss.ejb.Container.invoke(Container.java:712)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
            at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:98)
            at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:102)
            at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:77)
            at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:80)
            at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:117)
            at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
            at $Proxy169.saveCurrentAdjustment(Unknown Source)
            at com.nlg.ar.common.interfaces.ArServiceImpl.saveCurrentAdjustment(ArServiceImpl.java:1189)
            at com.nlg.ar.web.customer.action.CustomerAdjSaveAdjustmentAction.executeAction(CustomerAdjSaveAdjustmentAction.java:62)
            at com.nlg.ar.web.common.action.ArAuthenticatedAction.execute(ArAuthenticatedAction.java:56)
            at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:465)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1349)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:507)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
            at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1033)
            at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:283)
            at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:436)
            at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:326)
            at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1349)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:507)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
            at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
            at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
            at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
            at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
            at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
            at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
            at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
            at java.lang.Thread.run(Thread.java:534)

            • 3. Re: NullPointerException and Log4j
              Raja Master

              Sorry if i dint get you right. But if you set ur Log level to FATAL, how are u getting a info level message?
              org.jboss.ejb.plugins.LogInterceptor:info:158 - Application Exception
              com.nlg.ar.common.exception.AdjustmentException

              This is the code from the LogInterceptor where your excpetion is thrown.
              else if (e instanceof Exception)
              {
              if (callLogging)
              {
              log.info("Application Exception", e);
              }
              return (Exception)e;
              }

              The "Application Exception" is what you get in your log output. But im still confused as to how u can get a Info level message if ur level is set to Fatal?

              -Raj

              • 4. Re: NullPointerException and Log4j
                jmychasiw Newbie

                Here is my late reply, we are very soon to release and are busy:-).

                I Should clarify that the problem that I am having
                *goes away* when I set the level to FATAL.
                When I have it set to INFO or lower the NullPointer occurs.

                The Log4j guy's pointed out that the stacktrace that is being passed in from JBoss is null.

                I have yet to try my code out on the latest stable JBoss as we must build our JBoss on JDK 1.4 with Tomcat, and that has not worked for me at this time.