Get the a List from session

How do I get the list from session

val keywords = session.get(“keywords”).as[List[String]]
says java.lang.ClassCastException:

The session was populated by jsonPath.saveAs

Hi Neil,

“Lists” of objects that are stored in the session are not List[T], but IndexedSeq[T].
Therefore, you would have to write this to get keywords from the session :

val keywords = session("keywords").as[IndexedSeq[String]]



Thanks Pierre.

I inspected the session and found that it was an Vector. I figured out that I was re-setting the session by replacing the Vector to as String , so in second iteration onwards. it was giving me exception

The following worked.

val keywords = session("keywords").as[Vector[String]]

For 2.0 Migration . Doc is at