Problem running my first Actor

17 views
Skip to first unread message

Yair Ogen

unread,
Mar 4, 2014, 9:02:04 AM3/4/14
to jumi-tes...@googlegroups.com
I followed the hello world sample and having this runtime error:

Exception in thread "pool-1-thread-1" java.lang.RuntimeException: uncaught exception from null when processing message ServiceActor.startTransaction(ServiceImp{totalRequestCount=0, totalStatisticsRequestCount=0, totalStatisticsStartTime=0, failedRequestCount=0, latency=0, interfaceName='test', port=12345, protocol='junit', serviceDescription='default desc', apiName='0', usedThreads=0}, 125)
at fi.jumi.actors.listeners.CrashEarlyFailureHandler.uncaughtException(CrashEarlyFailureHandler.java:19)
at fi.jumi.actors.Actors$MessageToActor.run(Actors.java:124)
at fi.jumi.actors.Actors$ActorThreadImpl.process(Actors.java:87)
at fi.jumi.actors.Actors$ActorThreadImpl.processNextMessage(Actors.java:71)
at fi.jumi.actors.MultiThreadedActors$BlockingActorProcessor.run(MultiThreadedActors.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at fi.jumi.actors.eventizers.dynamic.DynamicEvent.fireOn(DynamicEvent.java:27)
at fi.jumi.actors.Actors$MessageToActor.run(Actors.java:122)
... 6 more

Any ideas what I'm doing wrong?

Here is my code:

Class parameters:

    public static final ExecutorService actorsThreadPool = Executors.newCachedThreadPool();
    public static ActorThread actorThread = null;
    public static final ActorRef<CommunicationInfo.ServiceActor> serviceActor = createServiceActor(actorsThreadPool);
    public static final CommunicationInfo.ServiceActorImpl serviceActorImpl =  new CommunicationInfo.ServiceActorImpl();


and the init method:



private static ActorRef<CommunicationInfo.ServiceActor> createServiceActor(ExecutorService actorsThreadPool) {
        Actors actors = new MultiThreadedActors(
                actorsThreadPool,
                new DynamicEventizerProvider(),
                new CrashEarlyFailureHandler(),
                new NullMessageListener()
        );

        actorThread = actors.startActorThread();
        ActorRef<CommunicationInfo.ServiceActor> srvActor = actorThread.bindActor(CommunicationInfo.ServiceActor.class, serviceActorImpl);
        return srvActor;
    }

Esko Luontola

unread,
Mar 4, 2014, 4:28:58 PM3/4/14
to jumi-tes...@googlegroups.com
Looks like serviceActorImpl is not yet initialized before you call
bindActor with it - it's still null at that point in time. Your code
initializes it only after calling createServiceActor.


Yair Ogen wrote on 4.3.2014 16:02:
> Here is my code:
>
> Class parameters:
>
> public static final ExecutorService actorsThreadPool =
> Executors.newCachedThreadPool();
> public static ActorThread actorThread = null;
> public static final ActorRef<CommunicationInfo.ServiceActor>
> serviceActor = createServiceActor(actorsThreadPool);
> public static final CommunicationInfo.ServiceActorImpl
> serviceActorImpl = new CommunicationInfo.ServiceActorImpl();
>
>
> and the init method:
>
>
>
> private static ActorRef<CommunicationInfo.ServiceActor>
> createServiceActor(ExecutorService actorsThreadPool) {
> Actors actors = new MultiThreadedActors(
> actorsThreadPool,
> new DynamicEventizerProvider(),
> new CrashEarlyFailureHandler(),
> new NullMessageListener()
> );
>
> actorThread = actors.startActorThread();
> ActorRef<CommunicationInfo.ServiceActor> srvActor =
> actorThread.bindActor(CommunicationInfo.ServiceActor.class,
> serviceActorImpl);
> return srvActor;
> }
>


--
Esko Luontola
www.orfjackal.net

Yair Ogen

unread,
Mar 5, 2014, 6:14:04 AM3/5/14
to jumi-tes...@googlegroups.com
Thanks. I created the Impl statically and it should have been first.

Seems to work fine now.

Yair
Reply all
Reply to author
Forward
0 new messages