avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <david.g...@hic.gov.au>
Subject Re: Logkit: NullPointerException in JMSQueueTarget constructor
Date Wed, 20 Mar 2002 04:50:32 GMT


I have been a little busy at work to look at this but it has come back and
bitten again so I raise it again..

We attempted to run logging in another environment and got the dreaded NPE.
The problem we have is that the NPE hides the actual message.

My original suggestion to fix the problem was to modify the class
org.apache.log.output.AbstractTarget as follows to instantiate the class
with a default value.

org.apache.log.output.AbstractTarget
    private ErrorHandler m_errorHandler = new
         org.apache.log.util.DefaultErrorHandler();

This would create a dependency between the org.apache.log.output package
and org.apache.log.util package.

If the creation of a DefaultErrorhandler per Target is a problem, then we
could instantiate a static instance of the DefaultErrorHandler in that
class and use that thus:

org.apache.log.output.AbstractTarget
    private ErrorHandler m_errorHandler =
org.apache.log.util.SingletonDefaultErrorHandler;


The only other suggestion is to make changes within the getErrorHandler()
of the class to check for a null value for m_errorHandler but this has no
advantages over the above (that I can see).

I would like to see a fix to this problem and while I can patch the Logkit
code, I would much prefer the library was fixed.



Any objections? Comments?







<david.gray@hic.gov.au> on 27/02/2002 18:24:14

Please respond to "Avalon Developers List" <avalon-dev@jakarta.apache.org>

To:    "Avalon Developers List" <avalon-dev@jakarta.apache.org>
cc:

Subject:    Logkit: NullPointerException in JMSQueueTarget constructor


We are getting a NPE in the above class when attempting to instantiate the
class. What we think is causing the instantiation to fail is that the
Server (in this case Websphere) does not have authorization to access JMS
(actually MQ Series under that).

The failing code is in "openConnection()" which looks like this:
    protected synchronized void openConnection()
    {
        try
        {
            m_connection = m_factory.createQueueConnection();
            m_connection.start();

            m_session =
                m_connection.createQueueSession( false,
Session.AUTO_ACKNOWLEDGE);

            m_sender = m_session.createSender( m_queue );
        }
        catch( final Exception e )
        {
            getErrorHandler().error( "Error starting connection", e, null
);
        }
    }
I think that it fails in createQueueConnection(), the code catches the
exception runs getErrorHandler()  which then throws the NPE because the
error handler is not defined!


If you track through the code, the private variable ErrorHandler
m_errorHandler in AbstractTarget is never initialized.

I suspect the only way to resolve this sort of problem is to initialize the
field thus:

    private ErrorHandler m_errorHandler = new
org.apache.log.util.DefaultErrorHandler();

Has anyone else seen this problem?








****************************************************************
NOTICE - This message is intended only for the use of the 
addressee named above and may contain privileged and 
confidential information.  If you are not the intended recipient
of this message you are hereby notified that you must not 
disseminate, copy or take any action based upon it.  If you 
received this message in error please notify HIC immediately.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of HIC.
****************************************************************

--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message