You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by starrman <st...@gmail.com> on 2007/09/08 20:06:00 UTC

Desktop App attempting to communicate with Web App using HttpClient... Receiving UnknownHostException

I have a Java Swing app (desktop app) that is attempting to communicate with
a website using HttpClient. When I run this app from within the IDE the HTTP
communications works flawlessly. When I attempt to run the app from the
command line the HTTP communication fails with a
java.net.UnknownHostException

Any Ideas?

Here is the code snippet:

                        String googleUrl = "http://www.google.com/";
			HttpClient client = new HttpClient();
			GetMethod get = new GetMethod(googleUrl);

			int iGetResultCode = client.executeMethod(get);
			final String strGetResponseBody = get.getResponseBodyAsString();

Here is the Exception I am seeing...

java.net.UnknownHostException: www.google.com
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
        at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
        at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
-- 
View this message in context: http://www.nabble.com/Desktop-App-attempting-to-communicate-with-Web-App-using-HttpClient...-Receiving-UnknownHostException-tf4406763.html#a12572121
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Desktop App attempting to communicate with Web App using HttpClient... Receiving UnknownHostException

Posted by starrman <st...@gmail.com>.
The problem was Norton Firewall.  As soon as I disabled the Norton Firewall
the HTTP communication worked as expected when I launch the application from
the command line 



starrman wrote:
> 
> I have a Java Swing app (desktop app) that is attempting to communicate
> with a website using HttpClient. When I run this app from within the IDE
> the HTTP communications works flawlessly. When I attempt to run the app
> from the command line the HTTP communication fails with a
> java.net.UnknownHostException
> 
> Any Ideas?
> 
> Here is the code snippet:
> 
>                         String googleUrl = "http://www.google.com/";
> 			HttpClient client = new HttpClient();
> 			GetMethod get = new GetMethod(googleUrl);
> 
> 			int iGetResultCode = client.executeMethod(get);
> 			final String strGetResponseBody = get.getResponseBodyAsString();
> 
> Here is the Exception I am seeing...
> 
> java.net.UnknownHostException: www.google.com
>         at java.net.PlainSocketImpl.connect(Unknown Source)
>         at java.net.SocksSocketImpl.connect(Unknown Source)
>         at java.net.Socket.connect(Unknown Source)
>         at java.net.Socket.connect(Unknown Source)
>         at java.net.Socket.<init>(Unknown Source)
>         at java.net.Socket.<init>(Unknown Source)
>         at
> org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
>         at
> org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
>         at
> org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
>         at
> org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
>         at
> org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
>         at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
>         at
> org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
> 

-- 
View this message in context: http://www.nabble.com/Desktop-App-attempting-to-communicate-with-Web-App-using-HttpClient...-Receiving-UnknownHostException-tf4406763.html#a12572203
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org