# How to read Session attributes outside of Gatling DSL

**URL:** <https://community.gatling.io/t/how-to-read-session-attributes-outside-of-gatling-dsl/2191>\
**Category:** Gatling (Open-Source)\
**Created:** [April 9, 2015, 8:27am UTC](https://community.gatling.io/t/how-to-read-session-attributes-outside-of-gatling-dsl/2191 "2015-04-09T08:27:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yves](https://avatars.discourse-cdn.com/v4/letter/y/9e8a1a/32.png) [@Yves](https://community.gatling.io/u/Yves)\
**Post date:** [April 9, 2015, 8:27am UTC](https://community.gatling.io/t/how-to-read-session-attributes-outside-of-gatling-dsl/2191/1 "2015-04-09T08:27:48Z")

</div>

Hi,

I would like to read the Session Map after a call to a feeder in a Scala function.

Assume here is my code :

class RechercheUSParCriteresIdsMonoValueEvol extends Simulation {

// some Stuff

object consultationService {

def rechercheUS (pTypeUS: String, IdFoncUS: String = “IDENTIFIANT”, nbIdFoncUS: Int = 0) : ChainBuilder = {

return exec { session =\>  
var pCriteres : String = “”  
if (nbIdFoncUS != 0){  
pCriteres = pCriteres + generateBuilder(IdFoncUS, nbIdFoncUS)  
}  
val newsession = session.set(“pCritere”, pCriteres).set(“pTypeUS”, pTypeUS)  
newsession  
}  
.exec(  
soapPost(“RECHERCHE\_ID\_FONC\_US”, urlService, “Request\_rechercherUnitesStructurellesParCriteres.txt”)  
)  
.pause(pacingTime)  
}

def generateBuilder (tCritere : String, nbTCritere: Int) : String = {  
val session: Session = ???

var valeursCriteres : List[String] = List()

for ( x ← 0 to nbTCritere - 1) {  
feed(usiFeeder) → must inject data in the session  
valeursCriteres = session(“idFonctionnelUs”).as[String] :: valeursCriteres  
}  
return (new pCriteres(true, tCritere, valeursCriteres)).toString()  
}  
}

// Some stuff

}

The compilation is OK, but at runtime I got this exception on the line where I declare ( val session: Session = ??? )

Exception in thread “main” scala.NotImplementedError: an implementation is missing  
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)  
at consultationService .RechercheUS.(RecordedSimulation.scala:54)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)  
at java.lang.reflect.Constructor.newInstance(Unknown Source)  
at java.lang.Class.newInstance(Unknown Source)  
at io.gatling.core.runner.Runner.run(Runner.scala:41)  
at io.gatling.app.Gatling$$anonfun$runSimulationIfNecessary$1.apply(Gatling.scala:126)  
at io.gatling.app.Gatling$$anonfun$runSimulationIfNecessary$1.apply(Gatling.scala:111)  
at scala.Option.getOrElse(Option.scala:121)  
at io.gatling.app.Gatling.runSimulationIfNecessary(Gatling.scala:111)  
at io.gatling.app.Gatling.start(Gatling.scala:67)  
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:53)  
at io.gatling.app.Gatling$.main(Gatling.scala:44)  
at io.gatling.app.Gatling.main(Gatling.scala)

Any Idea on what happened ?

Thx

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 9, 2015, 11:10am UTC](https://community.gatling.io/t/how-to-read-session-attributes-outside-of-gatling-dsl/2191/2 "2015-04-09T11:10:34Z")

</div>

??? is exactly that: something that throws a NotImplementedError at runtime.

It’s used as an intermediate step to write down all your logic while coding but you’re not finished implementing yet.  
You shouldn’t be using it here and expect the Simulation to work.

---

<div class="post-metadata">

**Author:** ![Yves](https://avatars.discourse-cdn.com/v4/letter/y/9e8a1a/32.png) [@Yves](https://community.gatling.io/u/Yves)\
**Post date:** [April 9, 2015, 11:36am UTC](https://community.gatling.io/t/how-to-read-session-attributes-outside-of-gatling-dsl/2191/3 "2015-04-09T11:36:57Z")

</div>

Ok i was asking myself what was then meaning of ???.

So how could i fetch the Session and use them like : valeursCriteres = session(“idFonctionnelUs”).as[String] :: valeursCriteres without need to do exec { session =\> …

thx
