Jmeter与Junit无法正常工作(无法初始化类org.apache.jmeter.gui.util.MenuFactory)

时间:2016-07-08 21:05:24

标签: junit jmeter jmeter-plugins

我正在尝试使用JMeter进行一些成本测试,但我的计划是使用我们当前的API单元测试套件作为成本测试计划,因为许多测试模拟用户流程。话虽这么说,我遇到了JMeter的一些问题。我应该在/ lib / junit文件夹中使用jar进行单元测试,但是当我启动JMeter时,编辑选项卡没有任何项目(在Mac上,从我的研究中,这个问题会在窗口上产生一个灰色的编辑按钮),我无法右键单击任何对象,JUnit采样器不会出现在测试计划中。以下是日志中的数据:

2016/07/08 13:51:33 WARN  - jmeter.gui.util.MenuFactory: Missing jar? Could not create kg.apc.jmeter.config.redis.RedisDataSet. java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool$Config 
2016/07/08 13:51:33 INFO  - jmeter.util.BSFTestElement: Registering JMeter version of JavaScript engine as work-round for BSF-22 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser 
2016/07/08 13:51:33 INFO  - jorphan.exec.KeyToolUtils: keytool found at 'keytool' 
2016/07/08 13:51:33 INFO  - jmeter.protocol.http.proxy.ProxyControl: HTTP(S) Test Script Recorder SSL Proxy will use keys that support embedded 3rd party resources in file /Users/tester/apache-jmeter-3.0/bin/proxyserver.jks 
2016/07/08 13:51:34 WARN  - jmeter.gui.util.MenuFactory: Could not instantiate org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.jorphan.reflect.ClassFinder.isChildOf(ClassFinder.java:377)
    at org.apache.jorphan.reflect.ClassFinder.access$000(ClassFinder.java:47)
    at org.apache.jorphan.reflect.ClassFinder$ExtendsClassFilter.accept(ClassFinder.java:92)
    at org.apache.jorphan.reflect.ClassFinder.findClassesInOnePath(ClassFinder.java:441)
    at org.apache.jorphan.reflect.ClassFinder.findClasses(ClassFinder.java:289)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:264)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:196)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:178)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:140)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.setupClasslist(JUnitTestSamplerGui.java:181)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.createClassPanel(JUnitTestSamplerGui.java:212)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.init(JUnitTestSamplerGui.java:167)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.<init>(JUnitTestSamplerGui.java:147)
    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 java.lang.Class.newInstance(Class.java:442)
    at org.apache.jmeter.gui.util.MenuFactory.initializeMenus(MenuFactory.java:492)
    at org.apache.jmeter.gui.util.MenuFactory.<clinit>(MenuFactory.java:160)
    at org.apache.jmeter.control.gui.TestPlanGui.createPopupMenu(TestPlanGui.java:93)
    at org.apache.jmeter.gui.tree.JMeterTreeNode.createPopupMenu(JMeterTreeNode.java:156)
    at org.apache.jmeter.gui.action.EditCommand.doAction(EditCommand.java:47)
    at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:80)
    at org.apache.jmeter.gui.action.ActionRouter.access$000(ActionRouter.java:40)
    at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:62)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

2016/07/08 13:51:34 ERROR - jmeter.gui.util.MenuFactory:  java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.jorphan.reflect.ClassFinder.isChildOf(ClassFinder.java:377)
    at org.apache.jorphan.reflect.ClassFinder.access$000(ClassFinder.java:47)
    at org.apache.jorphan.reflect.ClassFinder$ExtendsClassFilter.accept(ClassFinder.java:92)
    at org.apache.jorphan.reflect.ClassFinder.findClassesInOnePath(ClassFinder.java:441)
    at org.apache.jorphan.reflect.ClassFinder.findClasses(ClassFinder.java:289)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:264)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:196)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:178)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:140)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.setupClasslist(JUnitTestSamplerGui.java:181)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.createClassPanel(JUnitTestSamplerGui.java:212)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.init(JUnitTestSamplerGui.java:167)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.<init>(JUnitTestSamplerGui.java:147)
    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 java.lang.Class.newInstance(Class.java:442)
    at org.apache.jmeter.gui.util.MenuFactory.initializeMenus(MenuFactory.java:492)
    at org.apache.jmeter.gui.util.MenuFactory.<clinit>(MenuFactory.java:160)
    at org.apache.jmeter.control.gui.TestPlanGui.createPopupMenu(TestPlanGui.java:93)
    at org.apache.jmeter.gui.tree.JMeterTreeNode.createPopupMenu(JMeterTreeNode.java:156)
    at org.apache.jmeter.gui.action.EditCommand.doAction(EditCommand.java:47)
    at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:80)
    at org.apache.jmeter.gui.action.ActionRouter.access$000(ActionRouter.java:40)
    at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:62)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

2016/07/08 13:51:34 ERROR - jmeter.JMeter: Uncaught exception:  java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.jorphan.reflect.ClassFinder.isChildOf(ClassFinder.java:377)
    at org.apache.jorphan.reflect.ClassFinder.access$000(ClassFinder.java:47)
    at org.apache.jorphan.reflect.ClassFinder$ExtendsClassFilter.accept(ClassFinder.java:92)
    at org.apache.jorphan.reflect.ClassFinder.findClassesInOnePath(ClassFinder.java:441)
    at org.apache.jorphan.reflect.ClassFinder.findClasses(ClassFinder.java:289)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:264)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:196)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:178)
    at org.apache.jorphan.reflect.ClassFinder.findClassesThatExtend(ClassFinder.java:140)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.setupClasslist(JUnitTestSamplerGui.java:181)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.createClassPanel(JUnitTestSamplerGui.java:212)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.init(JUnitTestSamplerGui.java:167)
    at org.apache.jmeter.protocol.java.control.gui.JUnitTestSamplerGui.<init>(JUnitTestSamplerGui.java:147)
    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 java.lang.Class.newInstance(Class.java:442)
    at org.apache.jmeter.gui.util.MenuFactory.initializeMenus(MenuFactory.java:492)
    at org.apache.jmeter.gui.util.MenuFactory.<clinit>(MenuFactory.java:160)
    at org.apache.jmeter.control.gui.TestPlanGui.createPopupMenu(TestPlanGui.java:93)
    at org.apache.jmeter.gui.tree.JMeterTreeNode.createPopupMenu(JMeterTreeNode.java:156)
    at org.apache.jmeter.gui.action.EditCommand.doAction(EditCommand.java:47)
    at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:80)
    at org.apache.jmeter.gui.action.ActionRouter.access$000(ActionRouter.java:40)
    at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:62)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

2016/07/08 13:51:35 ERROR - jmeter.JMeter: Uncaught exception:  java.lang.NoClassDefFoundError: Could not initialize class org.apache.jmeter.gui.util.MenuFactory
    at org.apache.jmeter.control.gui.TestPlanGui.createPopupMenu(TestPlanGui.java:93)
    at org.apache.jmeter.gui.tree.JMeterTreeNode.createPopupMenu(JMeterTreeNode.java:156)
    at org.apache.jmeter.gui.action.EditCommand.doAction(EditCommand.java:47)
    at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:80)
    at org.apache.jmeter.gui.action.ActionRouter.access$000(ActionRouter.java:40)
    at org.apache.jmeter.gui.action.ActionRouter$1.run(ActionRouter.java:62)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我一直在做一些研究,到目前为止还没有任何解决方案有所帮助。因此,没有人浪费他们的时间,结果如this,并且此日志中的各种堆栈跟踪错误的所有Google搜索结果都没有产生可行的结果。我正在使用Jmeter 3,但已经尝试使用jmeter 2.12和jmeter 2.9。这可能相关也可能不相关,但Jmeter 2.12的工作原理是不会发生此错误,但单元测试中没有一个出现在采样器中。

3 个答案:

答案 0 :(得分:3)

第一行解释了一切:

  

缺少jar?

     

无法创建kg.apc.jmeter.config.redis.RedisDataSet。 java.lang.NoClassDefFoundError:org / apache / commons / pool / impl / GenericObjectPool $ Config

这是由于JMeter类路径中缺少Apache Pool个jar。

看起来您的测试是在安装了Redis插件的地方创建的,并且您当前正在尝试在干净的JMeter上运行它。

我会推荐以下内容:

  1. 获得&#34;清洁&#34; JMeter 3.0
  2. Install JMeter Plugin Manager
  3. 使用插件管理器安装Redis数据集
  4. 将测试库导入&#34; lib / junit&#34;夹
  5. 重新启动JMeter

答案 1 :(得分:1)

我解决了所有人,但它并没有真正解释为什么那些是堆栈跟踪中的错误。单元测试需要凭证,因为事实证明我必须放在Jmeter / bin文件夹中。一旦我这样做,测试运行正常。同样,我不确定为什么这会导致它引起的错误。

答案 2 :(得分:0)

我建议你:

  • 安装干净的3.0版本

  • 在jmeter / lib中添加依赖项

  • 你的lib / junit中的junit类

  • 如果使用junit 4,请确保在JUnit Request Sampler中选中“搜索JUnit4注释”框

无需安装Jmeter插件或插件管理器。

如果问题仍然存在,请显示您的新jmeter.log文件