如何设置 Glassfish 通过代理服务器进行访问?
我在办公室内的本地计算机上运行 Glassfish v2.1.1 实例时遇到问题,我们有一个用于传出连接的代理服务器。我最初的解决方法是在家工作。
我正在公司外部的 HTTPS 服务器上调用 SOAP 服务。由于 Glassfish 不通过公司的代理服务器,因此在尝试初始化 SOAP 客户端时出现以下错误:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://www.hostname.com...
并且
Caused by: java.net.UnknownHostException: www.hostname.com
我在命令行上设置了代理环境变量,并且我的系统代理设置都正常工作,以便我可以使用浏览器访问 WSDL。我应该如何配置 Glassfish?
I have been having issues with running a Glassfish v2.1.1 instance on my local machine from within the office, where we have a proxy server for outgoing connections. My initial workaround has been to work from home.
I am calling a SOAP service on a HTTPS server outside of the company. As Glassfish is not going via the company's proxy server, I get the following error when trying to initialise my SOAP clients:
javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://www.hostname.com...
and
Caused by: java.net.UnknownHostException: www.hostname.com
I have proxy environment variables set on my command line, as well as my system proxy settings all working correctly so that I can get to the WSDL with the browser. How should I configure Glassfish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我很难找到这个问题的答案,因为网上没有详细介绍这个主题。一个链接告诉我如何配置 HTTP 代理,但没有提到 HTTPS,所以我花了一段时间才弄清楚。
打开 Glassfish 服务器上的管理控制台并转到:
应用服务器-> JVM 设置 -> JVM 选项。单击“添加 JVM 选项”4 次,然后输入以下 4 个选项
,其中 proxyhostname 和端口号适合您的设置。然后你需要重新启动服务器。
请注意,我找不到任何用于从 PAC 文件设置代理的选项,也找不到需要身份验证的代理的选项。在这种情况下,您可能需要安装本地身份验证代理处理程序,例如 Mac OS X 的 Authoxy,它将您的本地主机转变为非身份验证代理并屏蔽来自中央身份验证代理的身份验证请求。
此外,此链接适用于 JVM 的各种代理选项:
http://download.oracle.com/javase/6 /docs/technotes/guides/net/proxies.html
I had a lot of trouble finding an answer to this, as the topic isn't covered in a lot of detail on the web. One link told me how to configure the HTTP proxy, but mentioned nothing about HTTPS, so it took me a while to figure it out.
Open up the admin console on your Glassfish server and go to:
Application Server -> JVM Settings -> JVM Options. Click "Add JVM Option" 4 times and enter the following 4 options
Where proxyhostname and the port number are correct for your setup. Then you need to restart the server.
Note that I couldn't find any options for setting up the proxy from a PAC file, nor for proxies which require auth. In this case, you may need to install a local auth proxy handler like Authoxy for Mac OS X, which turns your localhost into a non-auth proxy and masks the authentication request from the central auth proxy.
Also, this link was good for various proxy options to the JVM:
http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
您必须显式设置代理服务器。根据 Glassfish 版本,有多个选项可用。一般来说,您可以使用 JVM 参数或 Glassfish 管理控制台来设置代理。 此处提供了 GF3 的介绍(抱歉,仅提供链接,但我不想在这里重复所有细节)。
You have to explicitly set the proxy server. Several options are available depending on the Glassfish version. In general you can set the proxy by either using JVM arguments or the Glassfish Admin console. An intro for GF3 is available here (sorry for only providing a link, but I do not want to repeat all the details here).
为了使答案完整,如果代理需要用户名和密码,请在 Glassfish 中设置以下内容:
Just to make the answer complete, if the proxy requires user name and password, set the following in Glassfish:
无法解析主机,您确定使用可通过互联网 DNS 服务器解析的主机名,还是使用只能从您的网络内部解析的主机名,或者更糟糕的是,您的计算机本地的主机条目?
除此之外,代理服务器可能会拒绝您访问某些端口,但这可能不是您现在的问题。如果代理允许访问端口 80,并且出现任何连接超时错误,请尝试在端口 80 上运行 Glassfish。
The host cannot be resolved, are you sure you use a hostname resolvable by an internet DNS server or are you using something that can only be resolved from within your network or even worse, a hosts entry local to your machine?
Aside from that, the proxy server might be denying you access to some ports, but this is probably not your problem right now. If the proxy allows access to port 80, try running your Glassfish on port 80 as well if you get any connection timeout errors.