Search code examples
pluginsjmeterbeanshell

OauthSampler from JMeter 3.0 to JMeter 3.3


I have a test plan that works great in JMeter 3.0 (it was conceived with this version).

I tried to upgrade JMeter to 3.3 and now I have few new errors.

2018-02-19 16:40:51,544 INFO o.a.j.s.FileServer: Default base='D:\Automation\bin'
2018-02-19 16:40:51,544 INFO o.a.j.s.FileServer: Set new base='D:\Automation\bin'
2018-02-19 16:40:51,711 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2018-02-19 16:40:51,714 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8
2018-02-19 16:40:51,717 INFO o.a.j.s.SaveService: Using SaveService properties version 3.2
2018-02-19 16:40:51,721 INFO o.a.j.s.SaveService: Loading file: D:\Automation\bin\ENDPOINT.jmx
2018-02-19 16:40:51,969 INFO o.a.j.p.h.c.CacheManager: Will only cache the following methods: [GET]
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser
2018-02-19 16:40:52,321 INFO o.a.j.s.FileServer: Set new base='D:\Automation\bin'
2018-02-19 16:40:52,670 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2018-02-19 16:40:52,671 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1
2018-02-19 16:40:52,671 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2018-02-19 16:40:52,671 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2018-02-19 16:40:53,049 WARN o.j.r.Plugin: Unable to load class: com.atlantbh.jmeter.plugins.oauth.OAuthSampler
java.lang.NoClassDefFoundError: org/apache/jmeter/protocol/http/sampler/HTTPSampler2
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_151]
    at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_151]
    at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader.access$100(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_151]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_151]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    at org.jmeterplugins.repository.Plugin.getJARPath(Plugin.java:193) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.Plugin.detectInstalledPlugin(Plugin.java:107) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.Plugin.detectInstalled(Plugin.java:96) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.PluginManager.load(PluginManager.java:84) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.PluginManagerMenuItem$1.run(PluginManagerMenuItem.java:41) [jmeter-plugins-manager-0.19.jar:?]
Caused by: java.lang.ClassNotFoundException: org.apache.jmeter.protocol.http.sampler.HTTPSampler2
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    ... 16 more

How can I overcome this error? I know that OAuth Sampler is deprecated. Is there a way to fix this? Also I have some error when I try to read from a file (might not be related).

2018-02-19 16:41:07,229 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
2018-02-19 16:41:07,229 WARN o.a.j.f.BeanShell: Error running BSH script
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
    at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:183) ~[ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.util.BeanShellInterpreter.eval(BeanShellInterpreter.java:189) ~[ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.functions.BeanShell.execute(BeanShell.java:100) [ApacheJMeter_functions.jar:3.3 r1808647]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:137) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:92) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:281) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.config.Argument.getValue(Argument.java:146) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.config.Arguments.getArgumentsAsMap(Arguments.java:94) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.engine.PreCompiler.createArgumentsMap(PreCompiler.java:114) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.engine.PreCompiler.addNode(PreCompiler.java:101) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:996) [jorphan.jar:3.3 r1808647]
    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:978) [jorphan.jar:3.3 r1808647]
    at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:369) [ApacheJMeter_core.jar:3.3 r1808647]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:166) ~[ApacheJMeter_core.jar:3.3 r1808647]
    ... 14 more

Solution

  • Looking into commit 2651c6ffc534e0137849377fce4b1b0e1aafca47 the file src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java has been removed as a part of issue 60727 during JMeter 3.2 release

    So maximum JMeter version you can use with OAuth Sampler is JMeter 3.1.

    You can reach out to JMeter Plugins developers and/or maintainers via JMeter Plugins Forum and clarify the status and the plans or use one of alternative approaches described in How to Run Performance Tests on OAuth Secured Apps with JMeter, they should be JMeter-version-agnostic.

    You can download JMeter 3.1 from Apache JMeter Archives page