avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clover, James" <James.Clo...@disney.com>
Subject NullPointerException in ResourceLimitingThreadPool (was:RE: Is the Command package of Excalibur usable?)
Date Mon, 06 May 2002 03:09:10 GMT
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 - James.Clover@disney.com
Disney Enterprise Portal Operations Team


 

--
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