gatling - 在加特林中,出现“线程“主”java.lang.ExceptionInInitializerError 中的异常”错误
问题描述
当我在 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))
}
不知道怎么解决?有没有人遇到过类似的问题?
解决方案
我收到了这个错误,并且能够通过将 scala 目录标记为 Test Sources Root 来解决它
右键单击 scala 文件夹 > 将目录标记为 > 测试源根目录
推荐阅读
- swift - 在 Combine 中链接 n 个请求
- rust - 如何通过回调管理生命周期
- python - VScode 在 scipy stats 中找不到模块规范
- excel - 如果使用 vba 的 Excel 电子表格中的单元格为空白,则将一列中的最后 3 个文本字符复制到另一列
- transfer-learning - YoloV4/Darknet:提高一类预训练模型的准确性
- javascript - java脚本中的querySelectorAll()返回零
- sql - Oracle:使用 xml 类型的表创建模式
- mysql - Mysql通过id将表中的行连接到下一行(不是顺序的)
- snowflake-cloud-data-platform - 建立自定义 SAML IDP
- javascript - React 重新渲染导致的性能问题