Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
141 views
in Technique[技术] by (71.8m points)

java - Unable to connect to jmeter

I am trying to make java to talk to JMeter but I am getting an error.

My JMeter version is 5.3.3 so I am trying and this is the error I always get.

I need to find a solution to this problem thanks.!

package com.company;

import org.apache.jmeter.JMeter;
import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws Exception {
    // write your code here
        JMeterUtils.setJMeterHome("C:\Users\idan99\Desktop\apache-jmeter-5.3\");
        StandardJMeterEngine jmeter = new StandardJMeterEngine();
        JMeterUtils.loadJMeterProperties("C:\Users\idan99\Desktop\apache-jmeter-5.3\bin\saveservice.properties");
        JMeterUtils.initLogging();
        JMeterUtils.initLocale();

        SaveService.loadProperties();

        FileInputStream in = new FileInputStream("src/test_sim_users.jmx");
        HashTree hashTree = SaveService.loadTree(in);
        in.read();
        in.close();


        jmeter.configure(hashTree);
        jmeter.run();

Security framework of XStream not initialized, XStream is probably vulnerable.
17:07:20.942 [main] ERROR org.apache.jmeter.save.SaveService - Conversion error com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : 
first-jmeter-class  : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:65)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : org.apache.jmeter.save.ScriptWrapper
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/com.blazemeter.jmeter.threads.concurrency.ConcurrencyThreadGroup
line number         : 15
version             : 2.6 r1237317
-------------------------------
Exception in thread "main" java.lang.NullPointerException
    at org.apache.jmeter.engine.StandardJMeterEngine.configure(StandardJMeterEngine.java:176)
    at com.company.Main.main(Main.java:31)

This is the error, what can I do to resolve this?

question from:https://stackoverflow.com/questions/66048744/unable-to-connect-to-jmeter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...