无法运行加特林模拟 - 错误 NoSuchElementException [gatling.scala:83]



我最近使用maven按照本教程运行我的gatling模拟场景,
它运行正常,直到最近我再次尝试重新运行场景然后我得到了错误
[main][ERROR][Gatling.scala:83] i.g.a.Gatling$ - Run crashed java.util.NoSuchElementException: null

我用以下命令运行场景
mvn gatling:test -Dgatling.simulationClass=myscenario

我以为这是由一些损坏的存储库引起的?因为我看到它指向了加特林的依赖。
我试图重新安装依赖:

  • mvn dependency:purge-local-repository-不能解决问题
  • mvn clean install -U-不能解决问题
  • rm -rf ~/.m2/repository-不能解决问题

日志如下:

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------< collection:collection >-----------
[INFO] Building collection 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- gatling-maven-plugin:3.1.0:test (default-cli) @ collection ---
16:34:00.585 [main][ERROR][Gatling.scala:83] i.g.a.Gatling$ - Run crashed
java.util.NoSuchElementException: null
at scala.collection.immutable.BitmapIndexedMapNode.apply(HashMap.scala:635)
at scala.collection.immutable.HashMap.apply(HashMap.scala:132)
at simulations.PoolCollection.<init>(PoolCollection.scala:21)
... 16 common frames omitted
Wrapped by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at io.gatling.app.Runner.run0(Runner.scala:65)
at io.gatling.app.Runner.run(Runner.scala:52)
at io.gatling.app.Gatling$.start(Gatling.scala:80)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at io.gatling.app.Runner.run0(Runner.scala:65)
at io.gatling.app.Runner.run(Runner.scala:52)
at io.gatling.app.Gatling$.start(Gatling.scala:80)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
... 6 more
Caused by: java.util.NoSuchElementException
at scala.collection.immutable.BitmapIndexedMapNode.apply(HashMap.scala:635)
at scala.collection.immutable.HashMap.apply(HashMap.scala:132)
at simulations.PoolCollection.<init>(PoolCollection.scala:21)
... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.377 s
[INFO] Finished at: 2021-01-28T16:34:00+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:3.1.0:test (default-cli) on project collection: Gatling failed.: Process exited with an error: 255 (Exit value: 255) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

堆栈跟踪非常清楚:这是你这边的编码问题,这里不是Gatling的错。

Caused by: java.util.NoSuchElementException
at scala.collection.immutable.BitmapIndexedMapNode.apply(HashMap.scala:635)
at scala.collection.immutable.HashMap.apply(HashMap.scala:132)
at simulations.PoolCollection.<init>(PoolCollection.scala:21)

看看你在PoolCollection类第21行做了什么。您正在尝试从HashMap中获取不存在的条目。

最新更新