# Incomprehensible type issue =\> why the hell "required: io.gatling.core.session.Session" ???

**URL:** https://community.gatling.io/t/incomprehensible-type-issue-why-the-hell-required-io-gatling-core-session-session/5377
**Category:** Gatling (Open-Source)
**Created:** [November 27, 2019, 2:39pm UTC](https://community.gatling.io/t/incomprehensible-type-issue-why-the-hell-required-io-gatling-core-session-session/5377 "2019-11-27T14:39:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nicolas\_Delucinge](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@Nicolas\_Delucinge](https://community.gatling.io/u/Nicolas_Delucinge)
#### Post date: [November 27, 2019, 2:39pm UTC](https://community.gatling.io/t/incomprehensible-type-issue-why-the-hell-required-io-gatling-core-session-session/5377/1 "2019-11-27T14:39:51Z")

</div>

Hello everybody

I am using following “pure Scala” function within my scenario

def extractCharacteristicFromConfig(config:String, numChar:Int): String = {  
val jsonObject: JsValue = Json.parse(config)

//println("==\> DEBUG : config=" +config +" - numChar=" +numChar)

return Json.stringify(jsonObject(numChar))  
}

and when i am doing my mvn:gatling test I got this kind of issue from ZincCompiler

found : Int  
required: io.gatling.core.session.Session  
return Json.stringify(jsonObject(numChar))  
^  
15:29:30.711 [ERROR] i.g.c.ZincCompiler$ - one error found  
15:29:30.718 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed

I am 100% sure than input parameters (config & numChar) are correctly set thanks to the previous DEBUG println  
I really dont get the reason of this type mistmatch issue (even if I am pretty sure it is an obvious one for Gatling experts 🙂 )

Thanks in advance for any suggestion!!

For your information here is the overall call chain:

val sc\_scenario\_1\_loop = scenario(Prefix + " - S&C loop")  
.exec(SC\_Execution\_Chain())

def SC\_Execution\_Chain() =  
exec(  
session =\> {  
val conf = dataGen.getRandomConfiguration(“c:/TEMP/configurations.json”)  
// lets create 3 session variables to store information required to manage PUT /…/characteritics requests  
session.set(“randomConfig”, (conf \ “configuration”).get)  
.set(“configCharacteristics”, (conf \ “characteristics”).get)  
.set(“nbConfigCharacteristics”, (conf \ “characteristics” \ “id”).size)  
}  
)  
// start a new product configuration  
.exec(postConfiguration())  
.exec(  
session =\> {  
session.set(“scEncodedConfigurationId”, percentEncoding(session(“scConfigurationId”).as[String]))  
}  
)

// for i from 1 to nbConfigCharacteristics do  
.repeat(session =\> session(“nbConfigCharacteristics”).as[Int], “i”) {  
exec(  
session =\> {  
session.set(“characteristicSetting”, extractCharacteristicFromConfig(session(“configCharacteristics”).as[String], session(“i”).as[Int]))

}  
)  
.exec(putConfigurationCharacteristics("${scEncodedConfigurationId}", “${characteristicSetting}”))

}

// get the from a complete JSON configuration (=[{characteristic}, …, {characteristic}])  
def extractCharacteristicFromConfig(config:String, numChar:Int): String = {  
val jsonObject: JsValue = Json.parse(config)

//println("==\> DEBUG : config=" +config +" - numChar=" +numChar +" - char=" +Json.stringify(jsonObject(numChar)))

return Json.stringify(jsonObject(numChar))

}

---

<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: [November 27, 2019, 2:59pm UTC](https://community.gatling.io/t/incomprehensible-type-issue-why-the-hell-required-io-gatling-core-session-session/5377/2 "2019-11-27T14:59:59Z")

</div>

Please mind your language here. Some people will find “why the hell” offensive.

I don’t know what your JsValue is (Play?) but it looks like it doesn’t have an apply method so you can’t call jsonObject(Int).

---

<div class="post-metadata">

### Author: ![Nicolas\_Delucinge](https://avatars.discourse-cdn.com/v4/letter/n/58f4c7/32.png) [@Nicolas\_Delucinge](https://community.gatling.io/u/Nicolas_Delucinge)
#### Post date: [November 27, 2019, 4:37pm UTC](https://community.gatling.io/t/incomprehensible-type-issue-why-the-hell-required-io-gatling-core-session-session/5377/3 "2019-11-27T16:37:40Z")

</div>

Hi Stephane

Very sorry for the “why the hell” - I did not want to offend anyone

Indeed JsValue comes from JSON Play framework.  
To be sure I tested the content of the extractCharacteristicFromConfig is a “pure Scala context” (using below piece of code)

import play.api.libs.json.\_

val numChar:Int = 2  
val config:String =  
“”"

> [  
> {“id”:“T\_RATED\_CURRENT”,“bomPath”:“00000010”,“value”:“50\_A”},  
> {“id”:“T\_POLES\_DESCRIPTION”,“bomPath”:“00000010”,“value”:“4P”},  
> {“id”:“TC\_CONNECTIONS”,“bomPath”:“0000”,“value”:“COMPRESSION\_LUG”}  
> ]  
> “”"  
> val jsonObject: JsValue = Json.parse(config)  
> println(“Debug: config=” +config +" - numChar=" +numChar +" - char=" +jsonObject(numChar))  
> println("Debug : " +Json.stringify(jsonObject(numChar)))

==\> It works fine

What confuse me is the required: io.gatling.core.session.Session error message that makes me think that I am using “badly” Gatling and I dont get why…

---

<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: [November 27, 2019, 5:01pm UTC](https://community.gatling.io/t/incomprehensible-type-issue-why-the-hell-required-io-gatling-core-session-session/5377/4 "2019-11-27T17:01:13Z")

</div>

Your problem is that both play-json and Gatling provide implicit conversions with similar signature and they clash with each other.

You have 2 solutions:

- move play-json code to its own classes where you don’t import Gatling components
- make play-json conversions explicit: Json.stringify(JsValue.jsValueToJsLookup(jsonObject)(numChar))
