Yoshihiro-Maeda / google-api-translate-java

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

[google-api-translate-java] Error retrieving translation. #162

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I've created following class in the eclipse
public class GoogleTranslator {

 public static void main(String[] args) {
    // Set the HTTP referrer to your website address.
     GoogleAPI.setHttpReferrer("http://google.com");

        // Set the Google Translate API key
        // See: http://code.google.com/apis/language/translate/v2/getting_started.html
        GoogleAPI.setKey("AIzaSyC0ieByV5WPYxrlNvQZCa8-PQDXWcDhPFM");

        try {
            String translatedText = Translate.DEFAULT.execute("Hello", Language.ENGLISH, Language.RUSSIAN);
            System.out.println(translatedText);
        } catch (GoogleAPIException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }   
 }
}
2. I'm trying to use google-api-translate-java api.
Getting the following 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.asency.action.GoogleTranslator.main(GoogleTranslator.java:20)
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.io.IOException: Server returned HTTP response code: 403 for 
URL: 
https://www.googleapis.com/language/translate/v2?key=AIzaSyC0ieByV5WPYxrlNvQZCa8
-PQDXWcDhPFM&q=Hello&target=ru&source=en
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1368)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1362)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1016)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93)
    ... 2 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for 
URL: 
https://www.googleapis.com/language/translate/v2?key=AIzaSyC0ieByV5WPYxrlNvQZCa8
-PQDXWcDhPFM&q=Hello&target=ru&source=en
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89)
    ... 2 more

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

version: google-api-translate-java-0.97
operation system: windows xp

Original issue reported on code.google.com by sergei.sidorov86@gmail.com on 21 Feb 2012 at 10:15

GoogleCodeExporter commented 8 years ago
Are you able to solve the issue..I am also facing the same.

Original comment by sundi...@gmail.com on 31 Mar 2012 at 9:27

GoogleCodeExporter commented 8 years ago
hello, 
i am also having same problem, any solution yet?

thanks in advance.

Original comment by samer.m....@gmail.com on 20 Jun 2012 at 2:39

GoogleCodeExporter commented 8 years ago
Me too! 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 br.mendigo.view.Main.main(Main.java:23)
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.io.IOException: Server returned HTTP response code: 403 for 
URL: 

Original comment by rodlps22 on 23 Jul 2012 at 10:34

GoogleCodeExporter commented 8 years ago
same proble i have? how to solve this 

Original comment by lenin.wo...@gmail.com on 29 Jul 2012 at 2:54

GoogleCodeExporter commented 8 years ago
Tengo el mismo problema, alguien puede decirme como solucionarlo?

Original comment by area...@gmail.com on 27 Sep 2012 at 2:32

GoogleCodeExporter commented 8 years ago
me too having the same problem friends

Original comment by dineshsh...@gmail.com on 20 Aug 2013 at 7:47

GoogleCodeExporter commented 8 years ago
me too having the same problem.how to solve this? thanks in advance.

Original comment by zhuxiaow...@gmail.com on 14 Feb 2014 at 9:10

GoogleCodeExporter commented 8 years ago
can anyone solve the issue please,if any one gets the solution please share the 
solution, as many are facing similar problem.

Original comment by sampath....@gmail.com on 6 Mar 2014 at 8:53

GoogleCodeExporter commented 8 years ago
me too having the same problem.how to solve this? thanks in advance.

Original comment by Plus.Ref...@gmail.com on 13 Oct 2014 at 8:34

GoogleCodeExporter commented 8 years ago
me too having the same problem.how to solve this? thanks in advance.

Original comment by Jitendra...@gmail.com on 5 Jun 2015 at 6:08

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I am facing the same problem. My error log is given below -

Error: [google-api-translate-java] Error retrieving translation.
Exception in thread "main" 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.bits.translate.google.test.FirstTest.main(FirstTest.java:16)
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(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1888)
    at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1883)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1882)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1455)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93)
    ... 2 more
Caused by: java.net.UnknownHostException: www.googleapis.com
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:649)
    at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1103)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:997)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89)
    ... 2 more

Original comment by mainuddi...@gmail.com on 10 Jun 2015 at 11:42