java 通过代理连接到远程 weblogic 服务器时出现问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11358328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 04:45:57  来源:igfitidea点击:

Issue while connecting to remote weblogic server over proxy

javaurlproxyweblogic

提问by user613114

I have configured a proxy in my java source code as:

我在我的 java 源代码中配置了一个代理:

systemSettings.put("http.proxyHost", "www.proxyserver.com");
systemSettings.put("http.proxyPort", "8080");
systemSettings.put("http.nonProxyHosts", "10.x.y.z");

Here 10.x.y.z is the actual IP of my weblogic server. But whenever code tried to connect to weblogic server, I receive error as:

这里 10.xyz 是我的 weblogic 服务器的实际 IP。但是每当代码尝试连接到 weblogic 服务器时,我都会收到以下错误:

Caused by: java.net.ConnectException: t3://10.x.y.z:7001: Destination unreachable; nested exception is: java.net.ProtocolException: unrecognized response from proxy: 'HTTP/1.0 403 Forbidden'; No available router to destination at weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:216) at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170) at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:153) at weblogic.jndi.WLInitialContextFactoryDelegate$1.run(WLInitialContextFactoryDelegate.java:345) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:340)

引起:java.net.ConnectException: t3://10.xyz:7001: Destination unreachable; 嵌套异常是:java.net.ProtocolException:来自代理的无法识别的响应:'HTTP/1.0 403 Forbidden'; 在 weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:216) 在 weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170) 在 weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:153) 上没有可用的路由器到目的地在 weblogic.jndi.WLInitialContextFactoryDe​​legate$1.run(WLInitialContextFactoryDe​​legate.java:345) 在 weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) 在 weblogic.security.service.SecurityManager.runAs(SecurityManager.java: 146) 在 weblogic.jndi.WLInitialContextFactoryDe​​legate.getInitialContext(WLInitialContextFactoryDe​​legate.java:340)

It seems that setting http.nonProxyHosts is not working as expected. I tried to find solution over the Internet, but most of them says remove proxy settings. I can not remove proxy, as my code tries to connect to some of the Internet URLs. Also note that, weblogic server is on remote machine. Can you please give me a hint, what must be the issue here?

似乎设置 http.nonProxyHosts 没有按预期工作。我试图通过互联网找到解决方案,但大多数人说删除代理设置。我无法删除代理,因为我的代码尝试连接到某些 Internet URL。另请注意,weblogic 服务器位于远程机器上。你能不能给我一个提示,这里一定是什么问题?

采纳答案by user613114

I resolved the issue. I had setup the proxy initially when connection with weblogic was setup. So due to some network restrictions I believe it didnt work. In modified code, I used the same 3 lines to setup proxy:

我解决了这个问题。我最初在与 weblogic 的连接建立时设置了代理。所以由于一些网络限制,我认为它不起作用。在修改后的代码中,我使用相同的 3 行来设置代理:

System.setProperty("java.net.useSystemProxies", "false");
System.setProperty("http.proxyHost", "www.proxyserver.com");
System.setProperty("http.proxyPort", "8080");

The only difference is, I did it at exact place where I needed. So for initial connection setup with weblogic proxy wont be used. I also did not have to bypass, weblogic server URL to not to use proxy.

唯一的区别是,我在我需要的确切位置进行了操作。因此,不会使用带有 weblogic 代理的初始连接设置。我也没有绕过,weblogic 服务器 URL 不使用代理。

@Arcadien: I appreciate your efforts to help me. Thanks.

@Arcadien:感谢您为帮助我所做的努力。谢谢。

回答by Arcadien

Have a look at this OTN thread.

看看这个 OTN 线程

From 3rd comment :

从第三条评论:

  1. You are setting nonProxyHosts, which doesn't exist as a system property, via System.setProperties().
  1. 您正在通过 System.setProperties() 设置不作为系统属性存在的 nonProxyHosts。

I haven't read all so far, but it seems the system.properties is not the convenient way to set nonProxyHosts.

到目前为止我还没有阅读所有内容,但 system.properties 似乎不是设置 nonProxyHosts 的便捷方法。

Did you tried to set it from command line ?

您是否尝试从命令行设置它?

-Dhttp.nonProxyHosts="*.foo.com|localhost".