sorry, I don't like questions about serializability myself, but still...

Can anyone give me a hint why

  for (i <- 0 to (maxId - 1)) {  ...  }

throws a NotSerializableException in the loop body while

  var i = 0
  while (i < maxId) {
    // same code as in the for loop
    i += 1

works fine? I guess there is something fundamentally different in the way Scala realizes for loops?