# can we call java method which returns object from scenario.exec method?

**URL:** <https://community.gatling.io/t/can-we-call-java-method-which-returns-object-from-scenario-exec-method/5145>\
**Category:** Gatling (Open-Source)\
**Created:** [July 23, 2019, 12:46pm UTC](https://community.gatling.io/t/can-we-call-java-method-which-returns-object-from-scenario-exec-method/5145 "2019-07-23T12:46:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LakshmanaRao\_Burli](https://avatars.discourse-cdn.com/v4/letter/l/a9adbd/32.png) [@LakshmanaRao\_Burli](https://community.gatling.io/u/LakshmanaRao_Burli)\
**Post date:** [July 23, 2019, 12:46pm UTC](https://community.gatling.io/t/can-we-call-java-method-which-returns-object-from-scenario-exec-method/5145/1 "2019-07-23T12:46:08Z")

</div>

Hi team,

I want to write Gatling test cases for avrorpc api’s. But protocol is not supporting. So im trying to call java static function from scenario.exec method. But getting compile time exception because it will support only actionBuilder or Scenariobuilder.

Please find code below for more details.

```auto
package com.dbs.c2e.mstd.performance

import java.util
import java.util.{HashMap, UUID}

import com.intuit.karate.gatling.PreDef.karateFeature
import io.gatling.core.Predef.{Simulation, scenario}

import scala.collection.mutable

class performanceTest2 extends Simulation{

  System.setProperty("javax.net.ssl.keyStore", "src/main/resources/mykeystore.jks")
  System.setProperty("javax.net.ssl.trustStore", "src/main/resources/mykeystore.jks")
  System.setProperty("javax.net.ssl.keyStorePassword", "changeit")
  System.setProperty("javax.net.ssl.trustStorePassword", "changeit")

  import org.apache.avro.ipc.HttpTransceiver

  val client = new HttpTransceiver(new Nothing(<url>))

  import com.dbs.c2e.mstd.avro.casa.CasaDomain
  import org.apache.avro.ipc.specific.SpecificRequestor

  val proxy: CasaDomain = SpecificRequestor.getClient(classOf[CasaDomain], client)

  val metadata = new util.HashMap[String, AnyRef]
  metadata.put("X-CorrelationId", UUID.randomUUID.toString)
  metadata.put("ChannelId", "DGB")
  metadata.put("accessId", "mdtw-tw")
  metadata.put("accessSecret", "30nat9Zc6xrTLYYWphsI")

  import com.dbs.c2e.mstd.avro.casa.CasaAccountSummaryRequest

  val request = new CasaAccountSummaryRequest
  request.setAccountNumber("2d44d784-51b9-44c1-a3d7-e181ae1e6f72")
  request.setMetadata(metadata)
 // System.out.println("Response:" + proxy.getCasaAccountSummary(request).toString)

  val response = proxy.getCasaAccountSummary(request).toString

// def test: CasaServiceBaseTest = new CasaServiceBaseTest()
  def test = CasaServiceBaseTest.getCasaAccountSummary()
  private val bankingAccountSummaryFullTest = scenario("Get Casa Functional Testing").exec(response)

}

```
