com.google.gdata.util.AuthenticationException:连接登录URI时出错

我编写了一个Java应用程序,我将使用以下命令启动它:
java -jar MyApp.jar
该应用程序使用Google的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应用程序可以很好地与网络配合使用。 任何想法如何解决这一问题?所有帮助表示赞赏。谢谢!     
已邀请:
您最有可能收到错误,因为您的服务器上缺少包含SSL证书的信任库文件,或者包含无效的内容。 试试这个: 在服务器上:find / -name jssecacerts 在服务器上:find / -name cacerts 记下这些文件所在的路径。将这些文件移动到某处,即。到/ tmp / 将您的信任库文件从imac(可能是/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/lib/security/cacerts)复制到您的服务器,转到您之前看到的路径 重试您的申请 您还可以使用keytool实用程序检查两台计算机上的文件(有关详细信息,请参阅JSSE参考指南)并比较差异。     

要回复问题请先登录注册