cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "N. Tisserand (JIRA)" <>
Subject [jira] Created: (CXF-3171) http.proxyHost and http.proxyPort of System properties win when no proxy is required
Date Tue, 07 Dec 2010 12:08:10 GMT
http.proxyHost and http.proxyPort of System properties win when no proxy is required

                 Key: CXF-3171
             Project: CXF
          Issue Type: Bug
          Components: Transports
    Affects Versions: 2.3.1, 2.2.12, 2.2.11, 2.3.0, 2.2.10, 2.0.13, 2.1.10, 2.2.9, 2.2.8,
2.2.7, 2.2.6, 2.2.5, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2
            Reporter: N. Tisserand

When VM args "{{-Dhttp.proxyHost=xxxxxxxx -Dhttp.proxyPort=3128}}" are set, there is no way
to connect a webservice directly without passing throuh the proxy xxxxxxxx.

The client CXF is build as following :
{code:java|borderStyle=solid}JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

  MyWs instance = (MyWs) factory.create();
  Client client = ClientProxy.getClient(instance);
  HTTPConduit conduit = (HTTPConduit) client.getConduit();
  HTTPClientPolicy httpClientPolicy = conduit.getClient();
  try {
    String proxyHost = bundle.getProperty("");
    String proxyPort = bundle.getProperty("web.service.proxy.port");

    if (proxyHost != null && !proxyHost.isEmpty()) {
    } else {
      // Force NO proxy ?
      // httpClientPolicy.unsetProxyServerPort();  // tried without success
  } catch (NumberFormatException nfe) {
    log.error("ClientWS.init: proxy initialization failed", nfe);

When creating the instance with , CXF use HttpURLConnectionFactoryImpl (or HttpsURLConnectionFactory)
to open the url :
{code:java|borderStyle=solid}    if (proxy != null) {
      return (HttpURLConnection) url.openConnection(proxy);
    } else {
      return (HttpURLConnection) url.openConnection();
When the variable "{{proxy}}" is null, {{url.openConnection()}} is used, and benifits of VM
args ({{http.proxyHost}} and {{http.proxyPort}}).

The only solution to bypass the proxy, while keeping existing VM args, is to add a System
property "{{http.nonProxyHosts}}" in order to exclude the host of the proxy. This can be done
with an other VM arg "{{-Dhttp.nonProxyHosts=xxxx}}" or programmatically : {{System.setProperty("http.nonProxyHosts",

According to (chapter
3 Proxy class) when no proxy is required url.openConnection() should be used like this :
{code:java|borderStyle=solid}     url.openConnection(Proxy.NO_PROXY);{code}
The technote points out : ??"Now, this guarantees you that this specific URL will be retrieved
though a direct connection bypassing any other proxy settings, which can be convenient."??

I think that using {{url.openConnection(Proxy.NO_PROXY)}} could fix this problem in :
* org.apache.cxf.transport.http.HttpURLConnectionFactoryImpl.createConnection(Proxy proxy,
URL url)   > line #51  (release 2.3.1)
* org.apache.cxf.transport.https.HttpsURLConnectionFactory.createConnection(Proxy proxy, URL
url) > line #120 (release 2.3.1)

(!) WARNING (!) : this issue can conflicts with this other one : [CXF-2839|]
A lot of tests will be required.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message