United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6630733 : Config: Web Start not detecting proxy properly

Details
Type:
Bug
Submit Date:
2007-11-16
Status:
Resolved
Updated Date:
2016-02-18
Project Name:
JDK
Resolved Date:
2016-02-18
Component:
deploy
OS:
generic
Sub-Component:
webstart
CPU:
generic
Priority:
P4
Resolution:
Not an Issue
Affected Versions:
6
Fixed Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
jre 1.6.0_02 b06

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2

A DESCRIPTION OF THE PROBLEM :
Well,

I tried a code snippet I found and get two radically different answers for proxy hostname/port depending upon if I use Web Start or not.

If I use Web Start I do not get the correct proxy info. The response seems to be I am making a DIRECT connect to the internet when in fact that is not the case.

If I create an app directly without using Web Start I get the correct hostname/port.

The code snippet:

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URI;
import java.net.URL;
import java.util.Iterator;
import java.util.List;

import com.sun.java.browser.net.ProxyInfo;
import com.sun.java.browser.net.ProxyService;



public class MainTest {



/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

//detect("http://www.myuniportal.com");

detect2();



}



public static void detect2() {

try {



System.setProperty("java.net.useSystemProxies","true");

List l = ProxySelector.getDefault().select(

new URI("http://www.yahoo.com/"));



for (Iterator iter = l.iterator(); iter.hasNext(); ) {



Proxy proxy = (Proxy) iter.next();



System.out.println("proxy type : " + proxy.type());



InetSocketAddress addr = (InetSocketAddress)

proxy.address();



if(addr == null) {



System.out.println("No Proxy");



} else {



System.out.println("proxy hostname : " +

addr.getHostName());



System.out.println("proxy port : " +

addr.getPort());



}

}

} catch (Exception e) {

e.printStackTrace();

}





}

public static void detect(String location)

{

String proxyHost;

int proxyPort;

try {

ProxyInfo info[] = ProxyService.getProxyInfo(new URL(location));

if(info != null && info.length>0)

{

proxyHost = info[0].getHost();

proxyPort = info[0].getPort();

System.out.println("PROXY = " + proxyHost + ":" + proxyPort);

}

}catch (Exception ex) {

System.err.println(

"could not retrieve proxy configuration, attempting direct connection." + ex);

}

}



} 


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Take the test code above and create a jar to run it and download via web start. The output indicates a direct connection to the internet yet it is using a proxy. I need to get the proxy name and port from java when running in the web start environment behind a proxy.

Thx,
-Tony


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
Well,

I tried a code snippet I found and get two radically different answers for proxy hostname/port depending upon if I use Web Start or not.

If I use Web Start I do not get the correct proxy info. The response seems to be I am making a DIRECT connect to the internet when in fact that is not the case.

If I create an app directly without using Web Start I get the correct hostname/port.

The code snippet:

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.URI;
import java.net.URL;
import java.util.Iterator;
import java.util.List;

import com.sun.java.browser.net.ProxyInfo;
import com.sun.java.browser.net.ProxyService;



public class MainTest {



/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

//detect("http://www.myuniportal.com");

detect2();



}



public static void detect2() {

try {



System.setProperty("java.net.useSystemProxies","true");

List l = ProxySelector.getDefault().select(

new URI("http://www.yahoo.com/"));



for (Iterator iter = l.iterator(); iter.hasNext(); ) {



Proxy proxy = (Proxy) iter.next();



System.out.println("proxy type : " + proxy.type());



InetSocketAddress addr = (InetSocketAddress)

proxy.address();



if(addr == null) {



System.out.println("No Proxy");



} else {



System.out.println("proxy hostname : " +

addr.getHostName());



System.out.println("proxy port : " +

addr.getPort());



}

}

} catch (Exception e) {

e.printStackTrace();

}





}

public static void detect(String location)

{

String proxyHost;

int proxyPort;

try {

ProxyInfo info[] = ProxyService.getProxyInfo(new URL(location));

if(info != null && info.length>0)

{

proxyHost = info[0].getHost();

proxyPort = info[0].getPort();

System.out.println("PROXY = " + proxyHost + ":" + proxyPort);

}

}catch (Exception ex) {

System.err.println(

"could not retrieve proxy configuration, attempting direct connection." + ex);

}

}



} 

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
None that I know of.

                                    

Comments
I posted the above code as a webstart app at: http://oklahoma.us.oracle.com/www/tests/1.9.0/6630733/test.jnlp, and it show the expected proxys:
proxy type : HTTP
proxy hostname : adc-proxy.oracle.com
proxy port : 80
proxy type : HTTP
proxy hostname : rmdc-proxy.oracle.com
proxy port : 80
proxy type : DIRECT
No Proxy

then ran same thing stand alone:
and it gets only direct:
proxy type : DIRECT
No Proxy

setting the system property java.net.useSystemProxies after app has started has no effect.
note that https://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html says:
------------------------
java.net.useSystemProxies (default: false)
On recent Windows systems and on Gnome 2.x systems it is possible to tell the java.net stack, setting this property to true, to use the system proxy settings (both these systems let you set proxies globally through their user interface). Note that this property is checked only once at startup.
------------------------


The webstart is correct since JCP is configured to use browser setting and browser is set to use oracle proxy pac file.

closing as not a bug.
                                     
2016-02-18



Hardware and Software, Engineered to Work Together