The problem with serialization with scala.collection.JavaConvertions/JavaConverters is that these converters are shells that use the base object (scala / java). They are just a wrapper, and therefore, for its effective serialization, they must have a guarantee that the underlying structure is serializable.
The simplest solution in your case is to implement a structural copy in your conversion method:
// scala Set to Java Set Converters def scalaToJavaSetConverter(scalaSet: Set[Long]): java.util.Set[Long] = { val javaSet = new java.util.HashSet[Long]() scalaSet.foreach(entry => javaSet.add(entry)) javaSet }
maasg source share