I am upgrading to JMeter 3.2 from 3.0 and getting the below stackoverflow error. In addition to this is am not able to validate my script.
2017-09-13 16:17:30,804 INFO o.a.j.t.JMeterThread: Thread started: UI Navigation 1-1
2017-09-13 16:17:37,311 INFO o.a.j.t.JMeterThread: Thread started: UI Navigation 1-2
2017-09-13 16:17:38,904 INFO o.a.j.t.JMeterThread: Thread finished: UI Navigation 1-1
2017-09-13 16:17:38,904 ERROR o.a.j.JMeter: Uncaught exception:
java.lang.StackOverflowError: null
at java.lang.Class.getDeclaredFields0(Native Method) ~[?:1.8.0_144]
at java.lang.Class.privateGetDeclaredFields(Unknown Source) ~[?:1.8.0_144]
at java.lang.Class.getDeclaredField(Unknown Source) ~[?:1.8.0_144]
at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller$1.run(Context.java:209) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller$1.run(Context.java:204) ~[nashorn.jar:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_144]
at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller.initialize(Context.java:204) ~[nashorn.jar:?]
at jdk.nashorn.internal.codegen.CompilationPhase$InstallPhase.transform(CompilationPhase.java:508) ~[nashorn.jar:?]
at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:624) ~[nashorn.jar:?]
at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:655) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.Context.compile(Context.java:1317) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1251) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:627) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:535) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:524) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) ~[nashorn.jar:?]
at org.apache.jmeter.functions.JavaScript.executeWithNashorn(JavaScript.java:142) ~[ApacheJMeter_functions.jar:3.2 r1790748]
at org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:103) ~[ApacheJMeter_functions.jar:3.2 r1790748]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:141) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:116) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:101) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:281) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.SwitchController.getSelection(SwitchController.java:133) ~[ApacheJMeter_components.jar:3.2 r1790748]
at org.apache.jmeter.control.SwitchController.getSelectionAsInt(SwitchController.java:91) ~[ApacheJMeter_components.jar:3.2 r1790748]
at org.apache.jmeter.control.SwitchController.next(SwitchController.java:63) ~[ApacheJMeter_components.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:219) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.next(GenericController.java:173) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.next(LoopController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.nextIsNull(LoopController.java:151) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.GenericController.next(GenericController.java:168) ~[ApacheJMeter_core.jar:3.2 r1790748]
at org.apache.jmeter.control.LoopController.next(LoopController.java:123) ~[ApacheJMeter_core.jar:3.2 r1790748]
--This goes on for 1000 lines
This affects only one of my scripts, all other run fine.
If you look closely at the stack trace it is complaining about SwitchController this is the clue i needed. I am using a switch controller in my script to run different transaction controllers. I am using the logic mentioned in the Using Switch Controller: Random Weighted Values page.
It is this code that was causing the problem. It now returns a floating Number object instead of a whole number.
This was solved by my team mate using the below code.
This code returns a whole number and my switch was working again. This will affect anyone using this logic and upgrading to JMeter 3.2