rdd.foreach will print the elements in the stdout of the worker nodes, which wont be visible if this example is run on a cluster. Rather, using stateDstream.print() (as shown in the NetworkWordCount example) is recommended.