Can get simple jsonPath check to work

Hi guys,

I’m trying to check a simple json response without success:

HTTP response:
status=
200 OK
headers=
Server: [Apache-Coyote/1.1]
Content-Type: [application/json]
Transfer-Encoding: [chunked]

body=
[{“ctrDthAtu”:“2015-05-12T12:30:04.000+0000”,“nroIntTur”:11673,…other attrs}]

I’ve tried

jsonPath("$.nroIntTur").ofType[Int].saveAs(“nroIntTur”)

but got:

KO jsonPath($.nroIntTur).find(0).exists, found nothing

as my response is an array of jsonObjects I’ve also tried the array notation:

jsonPath("$[0].nroIntTur").ofType[Int].saveAs(“nroIntTur”) but i get this stacktrace:

Uncaught error from thread [GatlingSystem-akka.actor.default-dispatcher-5] shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[GatlingSystem]
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/HttpServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)

Any help is appreciated

refs:
http://goessner.net/articles/JsonPath/

https://github.com/gatling/jsonpath

Wat

Where does this HttpServlet thingy comes from? Gatling has nothing to do with servlets?
Could you provide the full statcktrace, please?

here we go:

2015-05-20 09:52:36 0s elapsed
---- TurmaRestSimulation -------------------------------------------------------
[ ] 0%
waiting: 1 / active: 0 / done:0
---- Requests ------------------------------------------------------------------

I also receive the same exception when the response is not an array, eg:

{“ctrDthAtu”:“2015-05-12T12:30:04.000+0000”,“nroIntTur”:11673…

and the check $.nroIntTur

found the problem, maven dependency conflict, removing dep below solves the problem:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

https://github.com/boonproject/boon/issues/317

Yep.

I’ll provide a fix for Boon, but until then, please remove the dep if you can. Or use another jar such as the JBoss/WildFly ones.

Hi Stephane,

indeed jboss javaee6 api solved it:

org.jboss.spec jboss-javaee-6.0 3.0.3.Final pom

Note that using Javaee7-api gives a clear error:

javax javaee-api 7.0 provided

Uncaught error from thread [GatlingSystem-akka.actor.default-dispatcher-11] shutting down JVM since ‘akka.jvm-exit-on-fatal-error’ is enabled for ActorSystem[GatlingSystem]
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.boon.core.Sys.detectContainer(Sys.java:207)
at org.boon.core.Sys.(Sys.java:196)
at org.boon.core.value.LazyValueMap.buildMap(LazyValueMap.java:225)
at org.boon.core.value.LazyValueMap.entrySet(LazyValueMap.java:214)
at java.util.AbstractMap.containsKey(AbstractMap.java:144)
at io.gatling.jsonpath.JsonPathWalker.walk1(JsonPath.scala:63)
at io.gatling.jsonpath.JsonPathWalker.io$gatling$jsonpath$JsonPathWalker$$walk(JsonPath.scala:52)
at io.gatling.jsonpath.JsonPathWalker$$anonfun$io$gatling$jsonpath$JsonPathWalker$$walk$1.apply(JsonPath.scala:52)
at io.gatling.jsonpath.JsonPathWalker$$anonfun$io$gatling$jsonpath$JsonPathWalker$$walk$1.apply(JsonPath.scala:52)
at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:396)
at scala.collection.Iterator$$anon$1.hasNext(Iterator.scala:870)
at scala.collection.Iterator$$anon$14.skip(Iterator.scala:476)
at scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:477)
at scala.collection.Iterator$class.toStream(Iterator.scala:1188)
at scala.collection.AbstractIterator.toStream(Iterator.scala:1202)
at scala.collection.TraversableOnce$class.toSeq(TraversableOnce.scala:283)
at scala.collection.AbstractIterator.toSeq(Iterator.scala:1202)
at io.gatling.core.check.extractor.jsonpath.SingleJsonPathExtractor$$anonfun$extract$1.apply(JsonPathExtractor.scala:53)
at io.gatling.core.check.extractor.jsonpath.SingleJsonPathExtractor$$anonfun$extract$1.apply(JsonPathExtractor.scala:53)
at io.gatling.core.validation.Success.map(Validation.scala:32)
at io.gatling.core.check.extractor.jsonpath.SingleJsonPathExtractor.extract(JsonPathExtractor.scala:53)
at io.gatling.core.check.extractor.CriterionExtractor.apply(Extractor.scala:33)
at io.gatling.core.check.CheckBase$$anonfun$check$2$$anonfun$apply$2$$anonfun$apply$4.apply(Check.scala:84)
at io.gatling.core.check.CheckBase$$anonfun$check$2$$anonfun$apply$2$$anonfun$apply$4.apply(Check.scala:83)
at io.gatling.core.validation.Success.flatMap(Validation.scala:33)
at io.gatling.core.check.CheckBase$$anonfun$check$2$$anonfun$apply$2.apply(Check.scala:83)
at io.gatling.core.check.CheckBase$$anonfun$check$2$$anonfun$apply$2.apply(Check.scala:82)
at io.gatling.core.validation.Success.flatMap(Validation.scala:33)
at io.gatling.core.check.CheckBase$$anonfun$check$2.apply(Check.scala:82)
at io.gatling.core.check.CheckBase$$anonfun$check$2.apply(Check.scala:81)
at io.gatling.core.validation.Success.flatMap(Validation.scala:33)
at io.gatling.core.check.CheckBase.check(Check.scala:81)
at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:35)
at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:32)
at io.gatling.core.check.Check$.checkRec$1(Check.scala:37)
at io.gatling.core.check.Check$.check(Check.scala:59)
at io.gatling.http.ahc.AsyncHandlerActor.checkAndProceed$1(AsyncHandlerActor.scala:281)
at io.gatling.http.ahc.AsyncHandlerActor.io$gatling$http$ahc$AsyncHandlerActor$$processResponse(AsyncHandlerActor.scala:322)
at io.gatling.http.ahc.AsyncHandlerActor$$anonfun$receive$1.applyOrElse(AsyncHandlerActor.scala:89)
at akka.actor.Actor$class.aroundReceive(Actor.scala:467)
at io.gatling.core.akka.BaseActor.aroundReceive(BaseActor.scala:22)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254)
at akka.dispatch.Mailbox.run(Mailbox.scala:221)
at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.util.MissingResourceException: Can’t find bundle for base name javax.servlet.LocalStrings, locale pt_BR
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:773)
at javax.servlet.GenericServlet.(GenericServlet.java:95)
… 52 more

Thanks for the information!