Hi Barbara,

On Thu, Sep 19, 2002 at 12:04:07PM +0200, Barbara Post wrote:
> I get a NPE. I followed :
> http://outerthought.net/wiki/Wiki.jsp?page=JavaLogging method 1.
> 
> First class is a classical custom Action, which has its logger defined in
> the sitemap.
> Logging of this action works fine.

        ok.

> In this action I create an instance of a custom class that extends
> AbstractLogEnabled :
> 
> TaminoAccess tamac = new TaminoAccess();                    (the void
> constructor does anything)
>         tamac.enableLogging(this.getLogger());
>         tamac.setUri(this.uri);

        Where exactly this this code above ? I suspect it's in the
        constructor of your custom action ?
        
        If this is the case then the call to 'this.getLogger()' will
        return null because the Avalon component manager won't have yet
        enabled logging on that sitemap component (and hence your
        non-cocoon class won't have a logging object to log to)
        
        To fix this, implement Initializable on your custom action and add
        the code to create and set the logger on your non-cocoon class there.
        
        The initialize() method on your action will be called well after
        enableLogging() by the ComponentManager, so you should have a valid
        logging object then.
        
        (BTW - If the variable happened to be created at within the class
        (ie. not in the constructor) then an alternative could be to overload
        enableLogging() on your custom action and propogate the logger
        object there).
        
        If that's not the case, can you print out what 'this.getLogger()'
        returns and set us in a stacktrace of the NPE.
        
        Hope that helps.
        
        Cheers,
        
        Marcus
        

> in the method directly called by setUri(this.uri) I try to log as follow :
> 
> if (getLogger().isDebugEnabled()){
>     getLogger().debug("tamino server : " + this.taminoServer);
>     getLogger().debug("tamino database : " + this.taminoDatabase);
>     getLogger().debug("tamino collection : " + this.taminoCollection);
>     }
> 
> This throws a  NPE.

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to