The system variables passed to java class doesnt work in gatling simulation


I have the following simulation class in gatling:

class BasicSimulation extends Simulation {

var p= new SmokeTest();

.baseURL(p.extractfunction()) // Here is the root for all relative URLs
.acceptHeader(“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”) // Here are the common headers
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)


The extractfunction() is a method in a java class which extracts System variables and provides the base url as the output(which is a string). when the extractfunction() is run as a integration test, it passes. But it fails when called via the Simulation class.

Anybody who knows what can be done to solve this??