Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
525 views
in Technique[技术] by (71.8m points)

maven - Can't run Gatling simulation - error NoSuchElementException [gatling.scala:83]

I recently run my gatling simulation scenario using maven following this tutorial,
It runs okay week ago, until recently I try to re run the scenario again then I got error
[main][ERROR][Gatling.scala:83] i.g.a.Gatling$ - Run crashed java.util.NoSuchElementException: null.

I run the scenatio with this command
mvn gatling:test -Dgatling.simulationClass=myscenario

I thought this caused by some corrupt repository? Because I see it points to gatling dependency.
I tried to reinstall the dependency with:

  • mvn dependency:purge-local-repository - doesn't solve the issue
  • mvn clean install -U - doesn't solve the issue
  • rm -rf ~/.m2/repository - doesn't solve the issue

Here are the logs:

[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
question from:https://stackoverflow.com/questions/65934899/cant-run-gatling-simulation-error-nosuchelementexception-gatling-scala83

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The stacktrace is pretty clear: that's a coding issue on your side and Gatling is not at fault here.

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)

Look at whatever you're doing in your PoolCollection class at line 21. You're trying to get an entry that doesn't exist from a HashMap.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...