# Get the a List from session

**URL:** <https://community.gatling.io/t/get-the-a-list-from-session/1285>\
**Category:** Gatling (Open-Source)\
**Created:** [August 14, 2014, 10:15am UTC](https://community.gatling.io/t/get-the-a-list-from-session/1285 "2014-08-14T10:15:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@Neil](https://community.gatling.io/u/Neil)\
**Post date:** [August 14, 2014, 10:15am UTC](https://community.gatling.io/t/get-the-a-list-from-session/1285/1 "2014-08-14T10:15:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pierre\_DAL-PRA](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pierre\_DAL-PRA](https://community.gatling.io/u/Pierre_DAL-PRA)\
**Post date:** [August 14, 2014, 11:24am UTC](https://community.gatling.io/t/get-the-a-list-from-session/1285/2 "2014-08-14T11:24:49Z")

</div>

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]]`

Cheers,

Pierre

---

<div class="post-metadata">

**Author:** ![Neil](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@Neil](https://community.gatling.io/u/Neil)\
**Post date:** [August 14, 2014, 11:38am UTC](https://community.gatling.io/t/get-the-a-list-from-session/1285/3 "2014-08-14T11:38:46Z")

</div>

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 [https://github.com/gatling/gatling/blob/master/src/sphinx/session/session\_api.rst#id6](https://github.com/gatling/gatling/blob/master/src/sphinx/session/session_api.rst#id6)
