# Execution in Loop

**URL:** <https://community.gatling.io/t/execution-in-loop/2916>\
**Category:** Gatling (Open-Source)\
**Created:** [April 12, 2016, 5:09pm UTC](https://community.gatling.io/t/execution-in-loop/2916 "2016-04-12T17:09:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Queiroz](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Allan\_Queiroz](https://community.gatling.io/u/Allan_Queiroz)\
**Post date:** [April 12, 2016, 5:09pm UTC](https://community.gatling.io/t/execution-in-loop/2916/1 "2016-04-12T17:09:11Z")

</div>

Hello guys,

I can imagine that my doubt could be a kind of stupid but lets go 🙂

I’m loading a scenario from a Json file and trying to execute the requests inside a loop.  
Everything works fine, the file Json is parsed, objects are populated but when the cursor reach the setUp line, I’m receiving this error:

**java.lang.IllegalArgumentException: requirement failed: Scenario Basic Scenario is empty**

This is the code. Why calling scn.exe inside a loop doesn’ t work?

Thank you very much!!!

`

import com.google.gson.Gson  
import io.gatling.core.Predef.\_  
import io.gatling.http.Predef.\_  
import org.apache.commons.io.IOUtils

class Gatling extends Simulation {

var classLoader = getClass().getClassLoader();  
var jsonDataInputStream = classLoader.getResourceAsStream(“scenario.json”);  
var jsonDataContent = IOUtils.toString(jsonDataInputStream);

var gson = new Gson()  
var scenarioJson = gson.fromJson(jsonDataContent, classOf[Scenario])

val httpConf = http  
.baseURL(scenarioJson.getHttp.getBaseUrl)  
.acceptHeader(scenarioJson.getHttp.getAcceptHeader)  
.doNotTrackHeader(scenarioJson.getHttp.getDoNotTrackHeader)  
.acceptLanguageHeader(scenarioJson.getHttp.getAcceptLanguageHeader)  
.acceptEncodingHeader(scenarioJson.getHttp.getAcceptEncodingHeader)  
.userAgentHeader(scenarioJson.getHttp.getUserAgentHeader)

var scn = scenario(scenarioJson.getName);  
val requests = scenarioJson.getRequests.iterator()

while (requests.hasNext()){

var request = requests.next()  
var auth = scenarioJson.getAuth

scn.exec(http(request.getName)  
.get(request.getUrl)  
.basicAuth(auth.getUsername, auth.getPassword))  
.pause(2)

// println("################################")  
// println(request.getName)  
// println(request.getUrl)  
// println("################################")  
}

setUp(scn.inject(atOnceUsers(100)).protocols(httpConf))

}

`

---

<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 12, 2016, 5:18pm UTC](https://community.gatling.io/t/execution-in-loop/2916/2 "2016-04-12T17:18:48Z")

</div>

Gatling DSL components are IMMUTABLE builders, so exec returns a new instance.
