2017-06-28 16 views
-1

我想通过我的Java代码(非gu jmeter)远程连接jmeter,但出现错误:rconfigure()方法java.rmi.UnmarshalException当我试图通过我的Java代码(非gu jmeter)远程连接jmeter时,出现错误

这里是我的代码:

public static void main(String[] argv) throws Exception { 

    // Set jmeter home path 
    File jmeterHome = new File("E:\\apache-jmeter-3.2"); 

    if (jmeterHome.exists()) { 

     // Inserting the properties of Jmeter. 

     File jmeterProperties = new File(
       "E:\\apache-jmeter-3.2\\bin\\jmeter.properties"); 
     if (jmeterProperties.exists()) { 
      // Creating JMeter Engine 

      StandardJMeterEngine jmeter = new StandardJMeterEngine(); 
      // JMeter initialization (properties, log levels, locale, etc) 

      JMeterUtils.setJMeterHome(jmeterHome.getPath()); 
      JMeterUtils.loadJMeterProperties(jmeterProperties.getPath()); 

      // you can comment this line out to see extra log messages of 
      // i.e DEBUG level 

      JMeterUtils.initLogging(); 
      JMeterUtils.initLocale(); 

      // JMeter Test Plan, basically JOrphan HashTree 
      HashTree testPlanTree = new HashTree(); 

      // First HTTP Sampler 
      HTTPSamplerProxy sampler = new HTTPSamplerProxy(); 
      sampler.setDomain("https://google.com/"); 
      sampler.setPort(8080); 
      sampler.setPath("/"); 
      sampler.setMethod("GET"); 

      sampler.setProperty(TestElement.TEST_CLASS, 
        HTTPSamplerProxy.class.getName()); 

      sampler.setProperty(TestElement.GUI_CLASS, 
        HttpTestSampleGui.class.getName()); 

      // Loop Controller 
      LoopController loopController = new LoopController(); 
      loopController.setLoops(10); 
      loopController.setFirst(true); 
      loopController.setProperty(TestElement.TEST_CLASS, 
        LoopController.class.getName()); 
      loopController.setProperty(TestElement.GUI_CLASS, 
        LoopControlPanel.class.getName()); 
      loopController.initialize(); 

      // InterleaveControler 

      // InterleaveControl controller = new InterleaveControl(); 

      // Thread Group 
      ThreadGroup threadGroup = new ThreadGroup(); 
      threadGroup.setName("Sample Thread Group"); 
      threadGroup.setNumThreads(100); 
      threadGroup.setRampUp(10); 
      threadGroup.setSamplerController(loopController); 
      threadGroup.setProperty(TestElement.TEST_CLASS, 
        ThreadGroup.class.getName()); 
      threadGroup.setProperty(TestElement.GUI_CLASS, 
        ThreadGroupGui.class.getName()); 

      // Test Plan 
      TestPlan testPlan = new TestPlan("Test planing"); 
      testPlan.setProperty(TestElement.GUI_CLASS, 
        TestPlanGui.class.getName()); 
      testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel() 
        .createTestElement()); 

      // Construct Test Plan from previously initialized elements 
      testPlanTree.add(testPlan); 
      HashTree threadGroupHashTree = testPlanTree.add(testPlan, 
        threadGroup); 
      threadGroupHashTree.add(sampler); 

      // save generated test plan to JMeter's .jmx file format 
      SaveService.loadProperties(); 
      SaveService.saveTree(testPlanTree, new FileOutputStream(
        "E:\\JunitJArs\\junitjunitjmeter_api.csv")); 

      // add Summarizer output to get test progress in stdout like: 
      // summary = 2 in 1.3s = 1.5/s Avg: 631 Min: 290 Max: 973 Err: 0 
      // (0.00%) 

      Summariser summer = null; 
      String summariserName = JMeterUtils.getPropDefault(
        "summariser.name", "summary"); 
      if (summariserName.length() > 0) { 
       summer = new Summariser(summariserName); 
      } 

      // Store execution results into a .jtl file, we can save file as 
      // csv also 

      String reportFile = "C:\\Users\\User\\Desktop\\Jmeter\\new\\report.jtl"; 
      String csvFile = "C:\\Users\\User\\Desktop\\Jmeter\\new\\report.csv"; 

      ResultCollector logger = new ResultCollector(summer); 
      logger.setFilename(reportFile); 

      ResultCollector csvlogger = new ResultCollector(summer); 
      csvlogger.setFilename(csvFile); 

      testPlanTree.add(testPlanTree.getArray()[0], logger); 
      testPlanTree.add(testPlanTree.getArray()[0], csvlogger); 

      // Run Test Plan 

      List<JMeterEngine> engines = new LinkedList<>(); 
      Properties remoteProps = new Properties(); 

      DistributedRunner distributedRunner = new DistributedRunner(
        remoteProps); 

      List<String> hosts = new LinkedList<>(); 

      // adding JMeter slaves here 

      hosts.add("172.16.104.199"); 


      distributedRunner.setStdout(System.out); 
      distributedRunner.setStdErr(System.err); 

      distributedRunner.init(hosts, testPlanTree); 


      engines.addAll(distributedRunner.getEngines()); 
      distributedRunner.start(); 

      // jmeter.configure(testPlanTree); 
      ///jmeter.run(); 
      System.err.println("Your Test excuted"); 
      System.exit(0); 
     } 
    } 
    System.err.println("Jmeter properties error"); 
    System.exit(1); 
} 

在控制台显示其

-Configuring remote engine: 172.16.104.199

Starting remote engines

Starting the test @ Wed Jun 28 17:45:07 IST 2017 (1498652107364) Error in rconfigure() method java.rmi.UnmarshalException

我试图寻找,但没有得到任何适当的解决方案

+0

我是新来的JMeter如有needfull给予不同它可以发生。 – KISHOR

+0

你能给出完整的堆栈跟踪错误吗? – user7294900

+0

@ user7294900我每次都得到这个 配置远程引擎:172.16.104.160 连接拒绝主机:172.16.104.160;嵌套的例外是: \t java.net.ConnectException:连接超时:连接 无法配置172.16.104.160 异常线程“main”停止远程发动机 远程发动机已经停止 了java.lang.RuntimeException:下列远程发动机无法配置:[172.16.104.160] \t在org.apache.jmeter.engine.DistributedRunner.init(DistributedRunner.java:112) \t在withRemote.Remoteee.main(Remoteee.java:187) – KISHOR

回答

0

如果在客户端的JDK版本比服务器 看到Post

+0

我试图使用相同的Java版本和Jmeter版本,但又得到相同的问题。 你能告诉我什么属性(关键和价值)我们必须通过distributedrunner。 – KISHOR

相关问题