Getting strange behavior when calling function outside of a closure:
I'm not entirely certain that this applies to Scala but, in Java, I solved the NotSerializableException by refactoring my code so that the closure did not access a non-serializable final field.
NotSerializableException
final