mugurelspineci / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

Why i am getting this exception ? UnknownHostException #169

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. This is my code
public static void main(String args[]){
        Translator trans = new Translator();

            try {
                System.out.println("::Before Translation::");
                System.out.println("::Translated Text ::"+trans.converter());

            } catch (GoogleAPIException e) {
                e.printStackTrace();
            }
    }
    public String converter() throws GoogleAPIException {
        System.out.println(":In Converter:");
        GoogleAPI.setHttpReferrer("http://www.google.com");
        System.out.println("::after HttpReffer::");
        GoogleAPI.setKey(GOOGLE_KEY);
        System.out.println("::After Key::");
        String translatedText = Translate.DEFAULT.execute("Hi Bhanu", Language.ENGLISH, Language.HINDI);
        System.out.println("::After Translation::"+translatedText);
        return translatedText;
    }

What is the expected output? What do you see instead?
given : Hi
expected : हाय

What version of the product are you using? On what operating system?

API : google-api-translate-java-0.97.jar
OS : Windows XP

Please provide any additional information below.

Error : 

Error: [google-api-translate-java] Error retrieving translation.
com.google.api.GoogleAPIException: java.lang.Exception: 
[google-api-translate-java] Error retrieving translation.
    at com.google.api.translate.TranslateV2.execute(TranslateV2.java:68)
    at com.sharedaa.translate.Translator.main(Translator.java:37)
Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving 
translation.
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99)
    at com.google.api.translate.TranslateV2.execute(TranslateV2.java:62)
    ... 1 more
Caused by: java.net.UnknownHostException: www.googleapis.com
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93)
    ... 2 more
Caused by: java.net.UnknownHostException: www.googleapis.com
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89)
    ... 2 more

Original issue reported on code.google.com by bhanu1...@gmail.com on 17 Apr 2012 at 6:18