2011-08-12 15 views
0

を取得することがエラーを与える:は、私はこのコードを使用していた場合ないIllegalAccessError

2011-08-10 13:18:13.368::WARN: EXCEPTION
java.lang.IllegalAccessError: tried to access method org.mortbay.util.Utf8StringBuffer.(I)V from class org.mortbay.jetty.HttpURI

コード:ここで

package com.google.api.client.sample.docs.v3; 

import com.google.api.client.auth.oauth.OAuthCredentialsResponse; 
import com.google.api.client.auth.oauth.OAuthHmacSigner; 
import com.google.api.client.auth.oauth.OAuthParameters; 
import com.google.api.client.googleapis.auth.oauth.GoogleOAuthAuthorizeTemporaryTokenUrl; 
import com.google.api.client.googleapis.auth.oauth.GoogleOAuthGetAccessToken; 
import com.google.api.client.googleapis.auth.oauth.GoogleOAuthGetTemporaryToken; 
import com.google.api.client.http.HttpTransport; 
import com.google.api.client.sample.docs.v3.model.DocsUrl; 
import java.awt.Desktop; 
import java.awt.Desktop.Action; 
import java.net.URI; 

public class Auth { 

    private static final String APP_NAME ="Google Documents List Data API Java Client Sample"; 

    private static OAuthHmacSigner signer; 

    private static OAuthCredentialsResponse credentials; 

    static void authorize(HttpTransport transport) throws Exception { 
     // callback server 
     LoginCallbackServer callbackServer = null; 
     String verifier = null; 
     String tempToken = null; 
     try { 

      callbackServer = new LoginCallbackServer(); 
      callbackServer.start(); 
      // temporary token 
      GoogleOAuthGetTemporaryToken temporaryToken =new GoogleOAuthGetTemporaryToken(); 
      signer = new OAuthHmacSigner(); 
      signer.clientSharedSecret = "anonymous"; 
      temporaryToken.signer = signer; 
      temporaryToken.consumerKey = "in.gappsdemo.in"; 
      //temporaryToken.scope ="https://apps-apis.google.com/a/feeds/user/"; 
      temporaryToken.scope = DocsUrl.ROOT_URL; 
      temporaryToken.displayName = APP_NAME; 
      temporaryToken.callback = callbackServer.getCallbackUrl(); 
      System.out.println("temporaryToken.callback: "+temporaryToken.callback); 
      OAuthCredentialsResponse tempCredentials = temporaryToken.execute(); 
      signer.tokenSharedSecret = tempCredentials.tokenSecret; 
      System.out.println("signer.tokenSharedSecret: " + signer.tokenSharedSecret); 
      // authorization URL 
      GoogleOAuthAuthorizeTemporaryTokenUrl authorizeUrl =new GoogleOAuthAuthorizeTemporaryTokenUrl(); 
      authorizeUrl.temporaryToken = tempToken = tempCredentials.token; 
      String authorizationUrl = authorizeUrl.build(); 
      System.out.println("Go to this authorizationUrl: " + authorizationUrl); 
      // launch in browser 
      boolean browsed = false; 
      if (Desktop.isDesktopSupported()) { 
       Desktop desktop = Desktop.getDesktop(); 
       if (desktop.isSupported(Action.BROWSE)) { 
        System.out.println("In if browsed condition:"); 
        desktop.browse(URI.create(authorizationUrl)); 
        browsed = true; 
       } 
      } 
      if (!browsed) { 
       String browser = "google-chrome"; 
       Runtime.getRuntime().exec(new String[] {browser, authorizationUrl}); 
       System.out.println("In if !browsed condition1:"); 
      } 
      System.out.println("tempToken: "+tempToken); 
      verifier = callbackServer.waitForVerifier(tempToken); 
      System.out.println("GoogleOAuthGetAccessToken: "); 
     } finally { 
      System.out.println("server Stop:"); 
      if (callbackServer != null) { 
       System.out.println("server Stop:"); 
       callbackServer.stop(); 
      } 
     } 
     System.out.println("GoogleOAuthGetAccessToken: "); 
     GoogleOAuthGetAccessToken accessToken = new GoogleOAuthGetAccessToken(); 
     accessToken.temporaryToken = tempToken; 
     accessToken.signer = signer; 
     accessToken.consumerKey = "in.gappsdemo.in"; 
     accessToken.verifier = verifier; 
     credentials = accessToken.execute(); 
     signer.tokenSharedSecret = credentials.tokenSecret; 
     System.out.println("signer.tokenSharedSecret: "); 
     createOAuthParameters().signRequestsUsingAuthorizationHeader(transport); 
    } 

    static void revoke() { 
     if (credentials != null) { 
      try { 
       GoogleOAuthGetAccessToken.revokeAccessToken(createOAuthParameters()); 
      } catch (Exception e) { 
       e.printStackTrace(System.err); 
      } 
     } 
    } 

    private static OAuthParameters createOAuthParameters() { 
     OAuthParameters authorizer = new OAuthParameters(); 
     authorizer.consumerKey = "in.gappsdemo.in"; 
     authorizer.signer = signer; 
     authorizer.token = credentials.token; 
     return authorizer; 
    } 
} 

答えて

1

潜在的に2 relatedpostsです。例外ではなくエラーが発生していることに注目してください。 JVMを-verboseで実行して、各クラスがどこからロードされているかを確認したり、あるクラス/ jarでコンパイルしているのを確認したり、別のクラス/ jarで誤って実行しているかどうかを確認したりできます。

また、パッケージが "org.mortbay.util"と "org.mortbay.jetty"の違いとは少し違うので、UTF8StringBufferコンストラクタがより見えるようにする必要があります。しかし、やはり通常、コンパイラはそれをキャッチします。

私はこれが完全な答えではないことを認識していますが、確かに、少なくとも2つの場所から探し始めます。

関連する問題