【问题标题】:In gatling, I got an error with "Exception in thread "main" java.lang.ExceptionInInitializerError"在 gatling 中,出现“线程“主”java.lang.ExceptionInInitializerError 中的异常”错误
【发布时间】:2019-11-26 13:04:44
【问题描述】:

在scala目录下运行Engine.scala,报错:

 Exception in thread "main" java.lang.ExceptionInInitializerError
    at Engine$.delayedEndpoint$Engine$1(Engine.scala:7)
    at Engine$delayedInit$body.apply(Engine.scala:4)
    at scala.Function0.apply$mcV$sp(Function0.scala:34)
    at scala.Function0.apply$mcV$sp$(Function0.scala:34)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App.$anonfun$main$1$adapted(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:389)
    at scala.App.main(App.scala:76)
    at scala.App.main$(App.scala:74)
    at Engine$.main(Engine.scala:4)
    at Engine.main(Engine.scala)
Caused by: java.lang.NullPointerException
    at io.gatling.commons.util.PathHelper$.url2path(PathHelper.scala:34)
    at IDEPathHelper$.<init>(IDEPathHelper.scala:7)
    at IDEPathHelper$.<clinit>(IDEPathHelper.scala)
    ... 11 more

而BaiduHomePageSimulation.scala是:

package test.scala

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class BaiduSimulation extends Simulation {
    // Set the root path of the request
    val httpConf = http.baseUrl("https://www.baidu.com")
    /*
    run 10 seconds, during:the default unit is seconds, if you want to use microseconds eg. during(100 millisecond)
    */
    val scn = scenario("BaiduSimulation").during(10){
        exec(http("baidu_home").get("/"))
    }
    // set the thread count
    setUp(scn.inject(atOnceUsers(10)).protocols(httpConf))
}

不知道怎么解决?有没有人遇到过类似的问题?

【问题讨论】:

    标签: gatling


    【解决方案1】:

    我遇到了这个错误,并且能够通过将 scala 目录标记为测试源根目录来解决它

    右键单击 scala 文件夹 > 将目录标记为 > 测试源根目录

    【讨论】:

    • 我必须将包含“Scala”文件夹的“Test”文件夹标记为“Test Sources Root”才能使其工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 2015-10-11
    • 1970-01-01
    • 2013-12-06
    • 2013-12-09
    • 2013-11-26
    相关资源
    最近更新 更多