Java.net.malformedurlexception illegal character found in host

3

New! Save questions or answers and organize your favorite content.
Learn more.

I tried to install Jmeter on my colleague computer when I executed http request.He has been showing this error, but I found that there is no such error in my computer. I wonder if anyone has encountered a similar problem?

My

My1 My2


Colleague

colleague1 colleague2

-- error message

java.net.MalformedURLException: Illegal character found in host: '/'
at java.base/java.net.URL.<init>(URL.java:480)
at java.base/java.net.URL.<init>(URL.java:360)
at java.base/java.net.URL.<init>(URL.java:383)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getUrl(HTTPSamplerBase.java:1053)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
at java.base/java.lang.Thread.run(Thread.java:830)

asked Nov 14, 2019 at 7:59

Java.net.malformedurlexception illegal character found in host

蘇家郁蘇家郁

311 gold badge1 silver badge3 bronze badges

1

This problem occurs when using the http request sampler, putting '/' at the end of the Server Name or Ip textbox. It will work if you delete the '/' character at the end of the host information and add it to path.

Java.net.malformedurlexception illegal character found in host

answered Nov 14, 2019 at 14:09

Java.net.malformedurlexception illegal character found in host

Bilal DemirBilal Demir

4784 silver badges14 bronze badges

2

  1. This www.amazon.com/ref=nav_logo is not a valid hostname

    Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, and the hyphen (-). A hostname may not start with a hyphen.

  2. In any case your URL query string is not correct, it should look like:

    https://www.amazon.com/?ref=nav_logo
                           ^mind this character
    

So correct HTTP Request sampler configuration would be:

Java.net.malformedurlexception illegal character found in host

Resulting into the following request observable via View Results Tree listener

Java.net.malformedurlexception illegal character found in host


Going forward be aware that you can build a JMeter Test Plan using HTTP(S) Test Script Recorder or JMeter Chrome Extension

answered Nov 14, 2019 at 10:34

Dmitri TDmitri T

147k4 gold badges75 silver badges127 bronze badges

1

Even though I cannot tell you why the test behaves differently on your machine vs that of your colleaugue (I would guess that you probably chose different client implementations in the advanced section of the HTTP Request Sampler), you should definitely consider what part of your URL is:

  • Protocol
  • Server Name or IP
  • Path
  • Parameter

and use the corresponding fields in JMeter accordingly.

Hint: "/ref=nav_logo" is most definitely NOT part of the Server Name.

answered Nov 14, 2019 at 8:42

I faced this issue and it was for simple reason. in the server name/ip address instead giving only the severname/ip address i.e server1 i had accidentally included the https://server1 and spend two hours to resolve it

answered Jul 23, 2021 at 6:24

Java.net.malformedurlexception illegal character found in host