You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Laran Coates <la...@yahoo.com> on 2001/09/05 16:32:30 UTC

Pooling Problems

Hi there.  I'm working on something using some of the Pooling classes and
I'm having problems with the Logger in the DefaultPool.

This is more or less what I'm doing.

<code>

class MClass
extends AbstractLoggable {

  public MClass()
  {
     init();
  }

  void init()
  {

    Pool mPool =
      new SoftResourceLimitingPool(
        Class.forName( "com.blah" ), 1, 10 );

    mPool.setLogger( getLogger() );

    mPool.initialize();

    // Problem happens on next line...
    System.out.println( mPool.get().toString() );

  }

}

</code>

When I run that code the get() call to the Pool throws a NPE at line 148 in
DefaultPool.

Am I not initializing the Pool or the Logger properly?
Anyone got any ideas?

Laran Coates
Azurn Networks


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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


RE: Pooling Problems

Posted by giacomo <gi...@apache.org>.
On Wed, 5 Sep 2001, Laran Coates wrote:

> And category can be anything I want?

Yes. The idea is that you have categories like:

   cocoon
   cocoon.components
   cocoon.components.store
   cocoon.main
   cocoon.servlet

The main category is cocoon but with any number of sub categories. You
can set individual LogTargets to those categories or have them use their
parent loggers targets. And yes there is a category "" which is the root
logger.

Giacomo


>
> -----Original Message-----
> From: giacomo [mailto:giacomo@apache.org]
> Sent: Wednesday, September 05, 2001 1:39 PM
> To: Avalon Development; laran_coates@yahoo.com
> Subject: RE: Pooling Problems
>
>
> On Wed, 5 Sep 2001, Laran Coates wrote:
>
> The usual approach is:
>
>   Logger logger =
>          Hierarchy.getDefaultHierarchy().getLoggerFor( category );
>
> Giacomo
>
> > Ok, I subclassed Logger to try to get a Logger I could work with, but I
> > can't seem to get a constructor that it likes.  It won't compile because
> > it's barfing on a public, no arg Constructor.  Any ideas on how I can get
> > around this?  I noticed an OutputStreamLogger.  Should I try with that?
> >
> >
> > -----Original Message-----
> > From: Peter Donald [mailto:donaldp@apache.org]
> > Sent: Wednesday, September 05, 2001 10:59 AM
> > To: Avalon Development
> > Subject: Re: Pooling Problems
> >
> >
> > On Thu, 6 Sep 2001 00:32, Laran Coates wrote:
> > > Hi there.  I'm working on something using some of the Pooling classes
> and
> > > I'm having problems with the Logger in the DefaultPool.
> > >
> > > This is more or less what I'm doing.
> > >
> > > <code>
> > >
> > > class MClass
> > > extends AbstractLoggable {
> > >
> > >   public MClass()
> > >   {
> > >      init();
> > >   }
> > >
> > >   void init()
> > >   {
> > >
> > >     Pool mPool =
> > >       new SoftResourceLimitingPool(
> > >         Class.forName( "com.blah" ), 1, 10 );
> > >
> > >     mPool.setLogger( getLogger() );
> > >
> > >     mPool.initialize();
> > >
> > >     // Problem happens on next line...
> > >     System.out.println( mPool.get().toString() );
> > >
> > >   }
> > >
> > > }
> > >
> > > </code>
> > >
> > > When I run that code the get() call to the Pool throws a NPE at line 148
> > in
> > > DefaultPool.
> > >
> > > Am I not initializing the Pool or the Logger properly?
> > > Anyone got any ideas?
> >
> > The problem is when MClass.init() is called, MClass has not been passed a
> > logger and thuse getLogger() will return null. This is what is causing the
> > error.
> >
> > The solution would be to remove init() from MClass constructory and
> replace
> >
> > MClass mClass = new MClass();
> >
> > with
> >
> > MClass mClass = new MClass();
> > mClass.setLogger( aLogger );
> > mClass.init();
> >
> > or something similar.
> >
> > --
> > Cheers,
> >
> > Pete
> >
> > *------------------------------------------------*
> > | You can't wake a person who is pretending      |
> > |       to be asleep. -Navajo Proverb.           |
> > *------------------------------------------------*
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
>
>


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


RE: Pooling Problems

Posted by Laran Coates <la...@yahoo.com>.
And category can be anything I want?

-----Original Message-----
From: giacomo [mailto:giacomo@apache.org]
Sent: Wednesday, September 05, 2001 1:39 PM
To: Avalon Development; laran_coates@yahoo.com
Subject: RE: Pooling Problems


On Wed, 5 Sep 2001, Laran Coates wrote:

The usual approach is:

  Logger logger =
         Hierarchy.getDefaultHierarchy().getLoggerFor( category );

Giacomo

> Ok, I subclassed Logger to try to get a Logger I could work with, but I
> can't seem to get a constructor that it likes.  It won't compile because
> it's barfing on a public, no arg Constructor.  Any ideas on how I can get
> around this?  I noticed an OutputStreamLogger.  Should I try with that?
>
>
> -----Original Message-----
> From: Peter Donald [mailto:donaldp@apache.org]
> Sent: Wednesday, September 05, 2001 10:59 AM
> To: Avalon Development
> Subject: Re: Pooling Problems
>
>
> On Thu, 6 Sep 2001 00:32, Laran Coates wrote:
> > Hi there.  I'm working on something using some of the Pooling classes
and
> > I'm having problems with the Logger in the DefaultPool.
> >
> > This is more or less what I'm doing.
> >
> > <code>
> >
> > class MClass
> > extends AbstractLoggable {
> >
> >   public MClass()
> >   {
> >      init();
> >   }
> >
> >   void init()
> >   {
> >
> >     Pool mPool =
> >       new SoftResourceLimitingPool(
> >         Class.forName( "com.blah" ), 1, 10 );
> >
> >     mPool.setLogger( getLogger() );
> >
> >     mPool.initialize();
> >
> >     // Problem happens on next line...
> >     System.out.println( mPool.get().toString() );
> >
> >   }
> >
> > }
> >
> > </code>
> >
> > When I run that code the get() call to the Pool throws a NPE at line 148
> in
> > DefaultPool.
> >
> > Am I not initializing the Pool or the Logger properly?
> > Anyone got any ideas?
>
> The problem is when MClass.init() is called, MClass has not been passed a
> logger and thuse getLogger() will return null. This is what is causing the
> error.
>
> The solution would be to remove init() from MClass constructory and
replace
>
> MClass mClass = new MClass();
>
> with
>
> MClass mClass = new MClass();
> mClass.setLogger( aLogger );
> mClass.init();
>
> or something similar.
>
> --
> Cheers,
>
> Pete
>
> *------------------------------------------------*
> | You can't wake a person who is pretending      |
> |       to be asleep. -Navajo Proverb.           |
> *------------------------------------------------*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
>
>


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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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


RE: Pooling Problems

Posted by giacomo <gi...@apache.org>.
On Wed, 5 Sep 2001, Laran Coates wrote:

The usual approach is:

  Logger logger =
         Hierarchy.getDefaultHierarchy().getLoggerFor( category );

Giacomo

> Ok, I subclassed Logger to try to get a Logger I could work with, but I
> can't seem to get a constructor that it likes.  It won't compile because
> it's barfing on a public, no arg Constructor.  Any ideas on how I can get
> around this?  I noticed an OutputStreamLogger.  Should I try with that?
>
>
> -----Original Message-----
> From: Peter Donald [mailto:donaldp@apache.org]
> Sent: Wednesday, September 05, 2001 10:59 AM
> To: Avalon Development
> Subject: Re: Pooling Problems
>
>
> On Thu, 6 Sep 2001 00:32, Laran Coates wrote:
> > Hi there.  I'm working on something using some of the Pooling classes and
> > I'm having problems with the Logger in the DefaultPool.
> >
> > This is more or less what I'm doing.
> >
> > <code>
> >
> > class MClass
> > extends AbstractLoggable {
> >
> >   public MClass()
> >   {
> >      init();
> >   }
> >
> >   void init()
> >   {
> >
> >     Pool mPool =
> >       new SoftResourceLimitingPool(
> >         Class.forName( "com.blah" ), 1, 10 );
> >
> >     mPool.setLogger( getLogger() );
> >
> >     mPool.initialize();
> >
> >     // Problem happens on next line...
> >     System.out.println( mPool.get().toString() );
> >
> >   }
> >
> > }
> >
> > </code>
> >
> > When I run that code the get() call to the Pool throws a NPE at line 148
> in
> > DefaultPool.
> >
> > Am I not initializing the Pool or the Logger properly?
> > Anyone got any ideas?
>
> The problem is when MClass.init() is called, MClass has not been passed a
> logger and thuse getLogger() will return null. This is what is causing the
> error.
>
> The solution would be to remove init() from MClass constructory and replace
>
> MClass mClass = new MClass();
>
> with
>
> MClass mClass = new MClass();
> mClass.setLogger( aLogger );
> mClass.init();
>
> or something similar.
>
> --
> Cheers,
>
> Pete
>
> *------------------------------------------------*
> | You can't wake a person who is pretending      |
> |       to be asleep. -Navajo Proverb.           |
> *------------------------------------------------*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
>
>


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


RE: Pooling Problems

Posted by Laran Coates <la...@yahoo.com>.
Ok, I subclassed Logger to try to get a Logger I could work with, but I
can't seem to get a constructor that it likes.  It won't compile because
it's barfing on a public, no arg Constructor.  Any ideas on how I can get
around this?  I noticed an OutputStreamLogger.  Should I try with that?


-----Original Message-----
From: Peter Donald [mailto:donaldp@apache.org]
Sent: Wednesday, September 05, 2001 10:59 AM
To: Avalon Development
Subject: Re: Pooling Problems


On Thu, 6 Sep 2001 00:32, Laran Coates wrote:
> Hi there.  I'm working on something using some of the Pooling classes and
> I'm having problems with the Logger in the DefaultPool.
>
> This is more or less what I'm doing.
>
> <code>
>
> class MClass
> extends AbstractLoggable {
>
>   public MClass()
>   {
>      init();
>   }
>
>   void init()
>   {
>
>     Pool mPool =
>       new SoftResourceLimitingPool(
>         Class.forName( "com.blah" ), 1, 10 );
>
>     mPool.setLogger( getLogger() );
>
>     mPool.initialize();
>
>     // Problem happens on next line...
>     System.out.println( mPool.get().toString() );
>
>   }
>
> }
>
> </code>
>
> When I run that code the get() call to the Pool throws a NPE at line 148
in
> DefaultPool.
>
> Am I not initializing the Pool or the Logger properly?
> Anyone got any ideas?

The problem is when MClass.init() is called, MClass has not been passed a
logger and thuse getLogger() will return null. This is what is causing the
error.

The solution would be to remove init() from MClass constructory and replace

MClass mClass = new MClass();

with

MClass mClass = new MClass();
mClass.setLogger( aLogger );
mClass.init();

or something similar.

--
Cheers,

Pete

*------------------------------------------------*
| You can't wake a person who is pretending      |
|       to be asleep. -Navajo Proverb.           |
*------------------------------------------------*

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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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


Re: Pooling Problems

Posted by Peter Donald <do...@apache.org>.
On Thu, 6 Sep 2001 00:32, Laran Coates wrote:
> Hi there.  I'm working on something using some of the Pooling classes and
> I'm having problems with the Logger in the DefaultPool.
>
> This is more or less what I'm doing.
>
> <code>
>
> class MClass
> extends AbstractLoggable {
>
>   public MClass()
>   {
>      init();
>   }
>
>   void init()
>   {
>
>     Pool mPool =
>       new SoftResourceLimitingPool(
>         Class.forName( "com.blah" ), 1, 10 );
>
>     mPool.setLogger( getLogger() );
>
>     mPool.initialize();
>
>     // Problem happens on next line...
>     System.out.println( mPool.get().toString() );
>
>   }
>
> }
>
> </code>
>
> When I run that code the get() call to the Pool throws a NPE at line 148 in
> DefaultPool.
>
> Am I not initializing the Pool or the Logger properly?
> Anyone got any ideas?

The problem is when MClass.init() is called, MClass has not been passed a 
logger and thuse getLogger() will return null. This is what is causing the 
error.

The solution would be to remove init() from MClass constructory and replace

MClass mClass = new MClass();

with 

MClass mClass = new MClass();
mClass.setLogger( aLogger );
mClass.init();

or something similar.

-- 
Cheers,

Pete

*------------------------------------------------*
| You can't wake a person who is pretending      |
|       to be asleep. -Navajo Proverb.           |
*------------------------------------------------*

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


Re: Pooling Problems

Posted by Paul Hammant <Pa...@yahoo.com>.
Laran,

>
>    mPool.setLogger( getLogger() );
>
>
>When I run that code the get() call to the Pool throws a NPE at line 148 in
>DefaultPool.
>
I suspect that it's logger and I have had problems in the past with 
things extending AbstractLogger. Debug your getLogger() method before 
handing it to mPool.  The key to the problem is in the server.xml, 
become very au-fait with HelloWorldServer and it's conf/ files.

Regards,

- Paul H


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


Re: Pooling Problems

Posted by giacomo <gi...@apache.org>.
On Wed, 5 Sep 2001, Laran Coates wrote:

> Hi there.  I'm working on something using some of the Pooling classes and
> I'm having problems with the Logger in the DefaultPool.
>
> This is more or less what I'm doing.
>
> <code>
>
> class MClass
> extends AbstractLoggable {
>
>   public MClass()
>   {
>      init();
>   }
>
>   void init()
>   {
>
>     Pool mPool =
>       new SoftResourceLimitingPool(
>         Class.forName( "com.blah" ), 1, 10 );
>
>     mPool.setLogger( getLogger() );
>
>     mPool.initialize();
>
>     // Problem happens on next line...
>     System.out.println( mPool.get().toString() );
>
>   }
>
> }
>
> </code>
>
> When I run that code the get() call to the Pool throws a NPE at line 148 in
> DefaultPool.
>
> Am I not initializing the Pool or the Logger properly?
> Anyone got any ideas?

What is getLogger() returning? Did your MClass got a logger?

Giacomo

>
> Laran Coates
> Azurn Networks
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
>
>


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