On Wed, 10 Oct 2001 07:07, Xin, Wayne wrote:
> I got a NullPointerException when trying to run the a simple test class on
> DefaultTimeScheduler.start(). Since I don't have an example, I'm hoping
> someone can tell me what went wrong.

> public class AvalonSchedulerTest
> {
>     public static void main( String[] args )
>     {
>         // AvalonSchedulerTest ast = new AvalonSchedulerTest();
>         Target aTarget = new Target() {
>             public void targetTriggered(String triggerName)
>             {
>                 System.out.println("Event happening - " + triggerName);
>             }
>         };
>         TimeTrigger aTrigger = new PeriodicTimeTrigger(1000, 1000);
>         DefaultTimeScheduler dts = new DefaultTimeScheduler();
>         dts.initialize();
>         dts.addTrigger("A Trigger", aTrigger, (Target) aTarget);
>
>         try
>         {
>             dts.start();
>         } catch (Exception ex)
>         {
>             ex.printStackTrace();
>         }

addTrigger is supposed to happen after service started but thats not the 
probelm. If you look at DefaultTimeScheduler.start() you will see that the 
only place null pointer could occur like that is when m_threadManager is null.

m_threadManager is set via the compose() method which you haven't called. You 
need to create a ThreadManager object and then pass it into 
DefaultTimeScheduler like the following

DefaultComponentManager componentManager = new DefaultComponentManager();
componentManager.put( ThreadManager.ROLE, myThreadManager );
dts.compose( componentManager );

-- 
Cheers,

Pete

------------------------------------------
I just hate 'yes' men, don't you Smithers?
------------------------------------------

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

Reply via email to