Googleシートにアクセスしようとする単純なJavaアプリケーションがありますが、実行するたびに例外が発生します。コードは次のとおりです。私はCredentialオブジェクトを作成しようとするところApp Engine経由でGoogleシートにアクセスすると例外が発生する
public class SheetsIntegration {
private static HttpTransport transport;
private static JacksonFactory jsonFactory;
private static AppEngineDataStoreFactory dataStoreFactory;
private Sheets service;
private static final String APPLICATION_NAME = "My App";
private static List<String> scopes = Arrays.asList(SheetsScopes.SPREADSHEETS);
public SheetsIntegration() {
try {
transport = GoogleNetHttpTransport.newTrustedTransport();
dataStoreFactory = AppEngineDataStoreFactory.getDefaultInstance();
jsonFactory = JacksonFactory.getDefaultInstance();
service = getSheetsService();
} catch (Exception e) {
// handle exception
}
}
public static Credential authorize() throws IOException {
InputStream in = AccessSheet.class.getResourceAsStream("/client_secret_access.json");
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jsonFactory, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(
transport, jsonFactory, clientSecrets, scopes)
.setDataStoreFactory(dataStoreFactory)
.setAccessType("offline")
.build();
AuthorizationCodeInstalledApp app = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver());
Credential credential = app.authorize("user");// This is line 55
return credential;
}
public static Sheets getSheetsService() throws IOException {
Credential credential = authorize();
return new Sheets.Builder(transport, jsonFactory, credential)
.setApplicationName(APPLICATION_NAME)
.build();
}
私はSheetsIntegrationをインスタンス化するとき、私は次の例外を取得...
java.lang.NoClassDefFoundError: Could not initialize class org.mortbay.jetty.Server at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.getRedirectUri(LocalServerReceiver.java:98) at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:76) at com.google.appengine.demos.SheetsIntegration.authorize(SheetsIntegration.java:55) at com.google.appengine.demos.SheetsIntegration.getSheetsService(SheetsIntegration.java:60) at com.google.appengine.demos.SheetsIntegration.(SheetsIntegration.java:37)
SheetsIntegration.java:55がある - 私はにコメントを追加しましたこの行私のポンポンで
私は次のエントリがあります。
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.26</version>
</dependency>
誰もが私がここで間違ってやっているものにいくつかの光を当てることができますか?ありがとう。