Registered: Oct, 2012
Re: Section 8.5, PilotProvider changes
Posted: Feb 27, 2013 10:48 AM
> Yep, I had that already. I'm a scala neophyte, so I could
> easily be wrong about this, but I think I would have
> gotten a compile time error, had I not included that.
> Instead, the code compiles fine (and all the tests even
> pass), but I get a runtime error.
Yeah, both fortunately and unfortunately, Akka uses some reflection to get its job done, which means that you're not going to get a compile time error on those particular bits.
However, this sparks another question... What does your Plane's actor creation have? It should be
val plane = system.actorOf(Props(Plane()), "Plane")
inside the Avionics.scala file.
val plane = system.actorOf(Props[Plane], "Plane")
then that'll explain it.
> Personally, I like having little exercises, but with
> solutions in the back, because it's easy to read a book
> through without understanding it, without some checks, but
> it's annoying to get stuck for hours if you're just
> completely missing something obvious. And, even if I do
> something that works, it's nice to see it done the "right"
> way, when I'm doing something inefficiently. But, everyone
> has different preferences about books; that's just my 2c.
I'm hoping to get the code out there soon... I've just been too busy to get it all done. I am working on it, though so... :)
>> I haven't had time to try to debug since running into the
> error, but I'll try to look later today, when I'll have
> some spare cycles.
> In case it's obvious to you, just from the error message,
> here's the error I'm getting:
> Caused by: java.lang.ClassCastException:
> zzz.akka.avionics.Plane cannot be cast to
Give that code above a try. If you've got the Props[Plane] there then the change I've given you will fix the issue.
> BTW, thanks for both writing the book and putting in time
> to answer questions and address issues. Despite the
> occasional frustration, I'm liking your book a lot.
I'm glad! And thanks for the feedback. When you clarify this stuff for me, it helps me make the book better and that's golden! I also greatly appreciate you taking up the challenge of really learning this stuff rather than just reading it through. Great work!