java.net.ConnectException : Tried all: '1' addresses, 但无法通过 HTTP 连接到服务器

标签 java weblogic

我在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

还有一点是,我在集成服务器中可以正常运行它,但在独立服务器中无法运行它。

最佳答案

似乎是在服务器上检查配置属性defaultzone。 也许您会在这里找到解决方案:

评论:LINK

After days, looking thousand times on the same config file I realized the issue. At the end it was just a misspelling of defaultzone. After changing it to defaultZone everything works like expected. Thank you very much for your time.

关于java.net.ConnectException : Tried all: '1' addresses, 但无法通过 HTTP 连接到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50793771/

相关文章:

java - Java 中的正则表达式 : match groups until first symbol occurrence

c# - 关于 Java 中的 synchronized 关键字(和 C# 的锁)的几个问题

web-services - 具有单个数组元素的复杂类型引发编码异常

java - 刷新连接时 Weblogic JMS 客户端线程卡住

java - JBoss AS 7.1.1 中的跨域 POST

java - 根据Main Activity类的条件在Adapter类的listview中插入图片

java - 为什么 apk 不自动安装在三星设备上

java - 使用 WebLogic 放置 Web 应用程序的 Jar

jakarta-ee - WebLogic 中默认的 "authenticated role"的角色名称是什么?如何在我的部署描述符中引用它?

java - 为什么这个解码器会抛出 MalformedURLException?