Jmeter错误“javax.naming.NoInitialContextException:需要在环境或系统属性中指定类名”

时间:2017-06-27 17:36:06

标签: jmeter beanshell

我第一次使用Jmeter,当我尝试运行JMS中的任何预定义函数时,我发现问题如下: -

  

javax.naming.NoInitialContextException:需要在环境或系统属性中指定类名,或在applet参数中或在应用程序资源文件中指定类名:java.naming.factory.initial

我不太清楚这里必须指定哪个类名。

以下是日志中的信息: -

017-06-27 22:59:06,868 ERROR o.a.j.p.j.s.JMSSampler: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) ~[?:1.8.0_101]
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) ~[?:1.8.0_101]
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source) ~[?:1.8.0_101]
    at javax.naming.InitialContext.lookup(Unknown Source) ~[?:1.8.0_101]
    at org.apache.jmeter.protocol.jms.sampler.JMSSampler.threadStarted(JMSSampler.java:329) [ApacheJMeter_jms.jar:3.2 r1790748]
    at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:677) [ApacheJMeter_core.jar:3.2 r1790748]
    at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:996) [jorphan.jar:3.2 r1790748]
    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:978) [jorphan.jar:3.2 r1790748]
    at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:646) [ApacheJMeter_core.jar:3.2 r1790748]
    at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:634) [ApacheJMeter_core.jar:3.2 r1790748]
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) [ApacheJMeter_core.jar:3.2 r1790748]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
2017-06-27 22:59:06,915 INFO o.a.j.f.LogFunction: Thread Group 1-1  :  "Hello world"
2017-06-27 22:59:06,915 WARN o.a.j.p.j.s.JMSSampler: Session may not be null while creating message 

图像:

enter image description here

1 个答案:

答案 0 :(得分:0)

您需要提供将创建初始上下文的工厂类的完全限定类名。初始上下文是命名操作的起点。

有关详细说明,请参阅javax.naming.Context class JavaDoc(如果有帮助)。

所以基本上你需要弄清楚你需要测试什么Message Queue服务器,一旦你至少知道正在使用什么,你需要找到正确的QueueConnectionFactory和InitialContext类名,队列名和其他JMS属性。

查看Building a JMS Testing Plan - Apache JMeter文章了解详情。