The ResourceLimitingPool code is all fairly stable and well tested.  The 
way that the getWorker method
is handling the NPE is a little confusing and needs to be cleaned up.

Please modify the getWorker method as follows:
----
        catch( final Exception e )
        {
            e.printStackTrace();
            throw new IllegalStateException( "Unable to access thread 
pool due to " + e );
        }
----
This way you can see where the original exception is coming from.  Most 
likely this is being caused
by not following the contracts of the component.  Maybe you are 
forgetting to call enableLogging
with a logger or something.  (Until I can see the above stack tract, I 
am guessing though)

Cheers,
Leif


Clover, James wrote:

>I'm trying to get the Command (w/CommandManager and a TPCThreadManager)
>package to work.  I've tried a couple of things, including running off a
>freshly built nightly CVS dated 5/5 (thanks Jeff, for the help - turns out
>my stuff checked out of CVS was wrong).
>
>Here's my problem:
>
>I'm trying to instantiate a CommandManager w/TPCThreadManager; here's my
>code:
>       commandManager = new CommandManager();
>       threadManager = new TPCThreadManager
>               (cpuCount, threadPerCpuCount, sleepTime);
>       threadManager.register(commandManager);
>
>Note that there is no Component configuration stuff (I'm new to Avalon, but
>it didn't seem like either of these classes used any configuration file
>stuff - please correct me if I'm wrong, particularly in regards to the
>Instrument stuff that I mention below).
>
>When I run this, I get an exception from the instantiation of the
>TPCThreadManager.  Here's the beginning of the stack trace:
>java.lang.IllegalStateException: Unable to access thread pool due to
>java.lang.NullPointerException
>        at
>org.apache.avalon.excalibur.thread.impl.ResourceLimitingThreadPool.getWorker
>(ResourceLimitingThreadPool.java:264)
>        at
>org.apache.avalon.excalibur.thread.impl.ResourceLimitingThreadPool.execute(R
>esourceLimitingThreadPool.java:235)
>        at
>org.apache.avalon.excalibur.thread.impl.ResourceLimitingThreadPool.execute(R
>esourceLimitingThreadPool.java:223)
>        at
>org.apache.excalibur.event.command.TPCThreadManager.<init>(TPCThreadManager.
>java:71)
>
>As you can see, the error is happening in the getWorker method of the
>ResourceLimitingThreadPool.  The code for the method is:
>    protected WorkerThread getWorker()
>    {
>        try
>        {
>            final WorkerThread worker = (WorkerThread)m_pool.get();
>
>            // TODO: Remove next line
>            worker.setContextClassLoader(
>Thread.currentThread().getContextClassLoader() );
>
>            return worker;
>        }
>        catch( final Exception e )
>        {
>            throw new IllegalStateException( "Unable to access thread pool
>due to " + e );
>        }
>    }
>
>There seems to be only one place where a NullPointerException could occur,
>and that's with the "worker" variable being null, and thus the m_pool (an
>instance of ResourceLimitingPool) is returning null.  Looking at the
>ResourceLimitingPool class, it talks about how it will either block or
>return the resource, but it doesn't seem to talk about returning null.  It
>also contains Instrument references, but I'm not sure how these work.
>
>Am I missing some configuration or is this code simply not finished?
>Previously, I'd been using the Excalibur 4.1 scratchpad and seemed to get
>the same error.
>
>Thanks for the help,
>James
>
>-----------------------------------------------------------------
>James Clover - [EMAIL PROTECTED]
>Disney Enterprise Portal Operations Team
>
>
> 
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
>  
>




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

Reply via email to