2011-02-05 25 views
1

我寫這我用下面的命令啓動Java應用程序連接:com.google.gdata.util.AuthenticationException:錯誤登錄URI

java -jar MyApp.jar 

應用程序使用谷歌的GData Java庫編輯Google電子表格。當我從我的Mac上運行這個應用程序時,它運行良好。但是,我需要在專用服務器上運行它。當我把它上傳那裏,並嘗試運行它,我收到以下錯誤:

$ java -jar MyApp.jar 
com.google.gdata.util.AuthenticationException: Error connecting with login URI 
    at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:489) 
    at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:346) 
    at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:362) 
    at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:317) 
    at org.graalcenter.stats.bot.GraalStatBot.main(GraalStatBot.java:42) 
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty 
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) 
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611) 
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1574) 
    at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1557) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1150) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1127) 
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:423) 
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) 
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:850) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250) 
    at com.google.gdata.client.GoogleAuthTokenFactory.makePostRequest(GoogleAuthTokenFactory.java:551) 
    at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:487) 
    ... 4 more 
Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty 
    at sun.security.validator.PKIXValidator.(PKIXValidator.java:75) 
    at sun.security.validator.Validator.getInstance(Validator.java:178) 
    at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:129) 
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:225) 
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:270) 
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:973) 
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:142) 
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:533) 
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:471) 
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:904) 
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1116) 
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1143) 
    ... 11 more 
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty 
    at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200) 
    at java.security.cert.PKIXParameters.(PKIXParameters.java:120) 
    at java.security.cert.PKIXBuilderParameters.(PKIXBuilderParameters.java:104) 
    at sun.security.validator.PKIXValidator.(PKIXValidator.java:73) 
    ... 22 more 

這是導致錯誤的代碼:

public static void main(String[] args) { 
     FeedURLFactory factory = FeedURLFactory.getDefault(); 
     SpreadsheetService service = new SpreadsheetService("my-app"); 

     try { 
      service.setUserCredentials(USER_NAME, USER_PASSWORD, ACCOUNT_TYPE); 
     } catch (AuthenticationException ex) { 
      ex.printStackTrace(); 
      System.exit(0); 
     } 
    }

我曾嘗試谷歌搜索的錯誤,並提示它通常是由代理人造成的;不過,我並不支持我的專用服務器上的代理。我寫的其他Java應用程序可以在網絡上正常工作。

任何想法如何解決這個問題?所有的幫助表示讚賞。謝謝!

回答

1

由於您的託管SSL證書的信任存儲文件在您的服務器上缺失或包含某些無效內容,因此很可能會出現此錯誤。

嘗試了這一點:

  • 在服務器上:查找/ -name jssecacerts
  • 在服務器上:查找/ -name cacerts的
  • 請記這些文件駐留在路徑上移動。這些文件在某處,即。 to/tmp/
  • 將您的truststore文件從imac(可能是/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/lib/security/cacerts)複製到您的服務器,路徑你剛纔
  • 看到重試你的應用程序

你也可以用keytool實用程序(見JSSE Reference Guide獲取更多信息)在兩臺計算機上檢查文件,並比較它們的差異。