简体   繁体   English

java.lang.IllegalStateException:目标主机为null

[英]java.lang.IllegalStateException: Target host is null

I have googled but many concerns was " java.lang.IllegalStateException: Target host must not be null ", but in my case error was " java.lang.IllegalStateException: Target host is null " 我已经用谷歌搜索,但是很多担心是“ java.lang.IllegalStateException:目标主机不能为空 ”,但在我的情况下,错误是“ java.lang.IllegalStateException:目标主机为空

I am trying to post a request using following code 我正在尝试使用以下代码发布请求

StringEntity reqContent = new StringEntity(xmlData);
reqContent.setContentType("text/xml");

HttpPost req = new HttpPost(serverURL);
req.setEntity(reqContent);

httpClient = new DefaultHttpClient(connMgr, params);

httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));

HttpResponse response = httpClient.execute(req);

After executing the request I am getting "Target host is null". 执行请求后,我得到“目标主机为空”。 I am giving a valid host. 我给一个有效的主机。 Does this error comes when Target host which I am trying to access is not available? 当我尝试访问的目标主机不可用时,会出现此错误吗?

发送请求时,我想发送请求的URL变得空,这在我尝试执行请求时导致了此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalStateException目标主机不能为null连接到数据库 - java.lang.IllegalStateException Target host must not be null connecting to database 如何解决 java.lang.IllegalStateException:没有主机? - How to solve java.lang.IllegalStateException: No host? java.lang.IllegalStateException:[TextView]不能为null - java.lang.IllegalStateException: [TextView] must not be null java.lang.IllegalStateException:带有迭代器的null - java.lang.IllegalStateException: null with iterator java.lang.IllegalStateException - java.lang.IllegalStateException java.lang.IllegalStateException:Parent不为null,但此组件不相关 - java.lang.IllegalStateException: Parent was not null, but this component not related java.lang.IllegalStateException:无法为unitName null检索EntityManagerFactory - java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null java.lang.illegalstateexception无法检索单位名称为null的entitymanagerfactory - java.lang.illegalstateexception unable to retrieve entitymanagerfactory for unitname null 击中java.lang.IllegalStateException:在HttpSession中调用setAttribute()时为null - Hitting java.lang.IllegalStateException: null when call setAttribute() in HttpSession 带有mediaPlayer的java.lang.IllegalStateException - java.lang.IllegalStateException with mediaPlayer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM