【问题标题】:java.net.ConnectException: Tried all: '1' addresses, but could not connect over HTTP to serverjava.net.ConnectException:尝试了所有:“1”地址,但无法通过 HTTP 连接到服务器
【发布时间】:2018-06-11 08:52:17
【问题描述】:

我在 Weblogic 服务器中运行程序时遇到以下问题。

网址 http://localhost:8080 在我这边是可以访问的,但是当我使用下面的代码连接服务器时,它因连接异常而失败。

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;

public static String invokeGet(String url, String dsl) {
  String url = "http://localhost:8080";
  Client clientInstance = Client.create();
  clientInstance.addFilter(new HTTPBasicAuthFilter("", ""));

  WebResource webResource = clientInstance.resource(url);

  ClientResponse response =
    webResource.entity(dsl).header("Content-type", "application/json").accept("application/json").get(ClientResponse.class);
     }

详细的错误信息:

Caused by: java.net.ConnectException: Tried all: '1' addresses, but could not connect over HTTP to server: 'hostname', port: '8080'

at weblogic.net.http.HttpClient.openServer(HttpClient.java:333)
    at weblogic.net.http.HttpClient.openServer(HttpClient.java:425)
    at weblogic.net.http.HttpClient.New(HttpClient.java:252)
    at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:213)
    at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:398)
    at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:37)
    at weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:1005)
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:215)
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)
    ... 182 more

还有一点,集成服务器可以正常运行,单机运行失败。

【问题讨论】:

    标签: java weblogic


    【解决方案1】:

    似乎在服务器上 ovveriding 配置属性 defaultzone。 可能你会在这里找到解决方案:

    评论:LINK

    几天后,我在同一个配置文件上查看了数千次,我意识到了这个问题。最后,这只是 defaultzone 的拼写错误。将其更改为 defaultZone 后,一切都按预期工作。 非常感谢您的宝贵时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-01
      • 2019-06-22
      • 1970-01-01
      • 2011-10-04
      • 1970-01-01
      • 2015-05-09
      • 1970-01-01
      相关资源
      最近更新 更多