Пакет API «Memcache» или Call 'get ()' не был найденJAVA

Программисты JAVA общаются здесь
Anonymous
Пакет API «Memcache» или Call 'get ()' не был найден

Сообщение Anonymous »

Я работаю над примерами API Google Drive, которые можно найти на следующих сайтах: Использование учетных записей служб, вставка файла и установление разрешений. Как вы можете догадаться, я только начинаю с API Google. Таким образом, я уверен, что ответ есть, но мои знания по этой теме еще недостаточно широки, чтобы интерпретировать результаты. Чтобы поехать на мою услугу. Однако я не могу вставить файл. Я получаю следующую ошибку: < /p>

com.google.apphosting.api.apiproxy$callnotfoundexception: пакет API 'Memcache' или вызов 'get ()' не был найден.
at com.google.apphosting.api.apiproxy $ 1.get (apiproxy.java:162)
at com.google.apphosting.api.apiproxy $ 1.get (apiproxy.java:160)
at com.google.appengine.api.utils.futurewrapper.get (futurewrapper.java:86)
at com.google.appengine.api.memcache.memcacheserviceimpl.quietget (memcacheserviceimpl.java:26)
at com.google.appengine.api.memcache.memcacheserviceimpl.get (memcacheserviceimpl.java:49)
att com.google.appengine.api.appidentity.appidentityserviceimpl.getAccessToken (AppidentityServiceimpl.java:188)
at com.google.api.client.googleapis.extensions.appengine.auth.oauth.appidentitycredential.interceptemptient.jauthaventian : 93)
at com.google.api.client.http.httprequest.execute (httprequest.java:859)
at com.google.api.client.googleapis.media.mediahtpuploader.executecurrentrequestwithoutgzip (mediahttpuploader.executecurrentrequestwithoutgzip (mediahtpuploader.jecutecurrentrequestwithoutgzip (mediahttpuploader.jecutecurrentrequestwithoutgzip > at com.google.api.client.googleapis.media.mediahttpuploader.executecurrentrequest (mediahttpuploader.java:562)
com.google.api.client.googleapis.media.mediahttpuploader.executeuploadinitiation (mediahttpuploader.java:519)
at com.google.api.client.googleapis.media.mediahttpuploader.ResumableUpload (mediahttpuploader.java:384)
at com.google.api.client.googleapis.media.mediahttpupload.upload (mediahtpupuis.media.mediahttpupload. бренд /> at com.google.api.client.googleapis.services.abstractgoogleclientrequest.executeUnparsed (AbstractGoogleClientRequest.java:418)
at com.google.api.client.googleapis.services.abstractgoogleclientrequest.executeunparsed (Abstractgoogleclientrequest.java:343)
at com.google.api.client.googleapis.services.abstractgoogleclientrequest.execute (Abstractgoogleclientrequest.java:460)
at rivetest.gdrive.insertfile (gdrive.java:80)
at drivetest.gdrive. Gdrive.java:58)
at drivetest.app.main (app.java:28)
at sun.reflect.nativemethodaccessorimpl.invoke0 (родной метод)
at sun.reflect.nativemethodacccessorimpl.invoke (nativemethodaccessormpl.java :39)
at sun.reflect.delegatingmethodaccsorsimpl.invoke (делегирование methodaccessorimpl.java:25)
at java.lang.reflect.method.invoke (метод. Java:597)
at com.intellij.rt.execution.application.appmain.main (appmain.java:120)
пакет API 'memcache' или вызов 'get ()' не был найден.
< /pre> < Br /> код в значительной степени вырезан и вставлен из сайтов, на которые я ссылался выше: < /p>
Первая линия-это линия, которая вызывает ошибка. < /p>

Код: Выделить всё

File file = service.files().insert(body, mediaContent).execute();
< /code>
package DriveTest;
import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential;
import com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
import com.google.api.client.http.FileContent;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.DriveScopes;
import com.google.api.services.drive.model.File;
import com.google.api.services.drive.model.ParentReference;
import com.google.api.services.drive.model.Permission;

import java.io.IOException;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Arrays;

public class GDrive {

private static GDrive instance=null;
private static Drive drive=null;
private static final String API_KEY = "ourkey";

protected GDrive() {}

public static GDrive getInstance() {
if(instance==null) {
instance=new GDrive();

}
return instance;
}

public void setDriveService() throws GeneralSecurityException,IOException, URISyntaxException {
if(drive==null) {
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
ArrayList scopes=new ArrayList();
scopes.add(DriveScopes.DRIVE);
AppIdentityCredential credential = new AppIdentityCredential.Builder(scopes).build();
GoogleClientRequestInitializer keyInitializer = new CommonGoogleClientRequestInitializer(API_KEY);
drive = new Drive.Builder(httpTransport, jsonFactory, null)
.setHttpRequestInitializer(credential)
.setGoogleClientRequestInitializer(keyInitializer)
.build();
}
}

public void putFile(String filename) throws Exception {
File theFile=this.insertFile(this.drive, "Report", "a report!","","application/vnd.ms-excel",filename);
Permission thePermission=this.setShare(this.drive, theFile.getId(),"someuser@somedomain.com","user","reader");
}

private File insertFile(Drive service, String title, String description,
String parentId, String mimeType, String filename) {
// File's metadata.
File body = new File();
body.setTitle(title);
body.setDescription(description);
body.setMimeType(mimeType);

// Set the parent folder.
if (parentId != null && parentId.length() > 0) {
body.setParents(
Arrays.asList(new ParentReference().setId(parentId)));
}

// File's content.
java.io.File fileContent = new java.io.File(filename);
FileContent mediaContent = new FileContent(mimeType, fileContent);
try {
File file = service.files().insert(body, mediaContent).execute();

// Uncomment the following line to print the File ID.
System.out.println("File ID: %s" + file.getId());

return file;
} catch (IOException e) {
System.out.println("An error occured: " + e);
return null;
}
}

/**
* Insert a new permission.
*
* @param service Drive API service instance.
* @param fileId ID of the file to insert permission for.
* @param value User or group e-mail address, domain name or {@code null}
"default" type.
* @param type The value "user", "group", "domain"  or "default".
* @param role The value "owner", "writer" or "reader".
* @return The inserted permission if successful, {@code null} otherwise.
*/
private Permission setShare(Drive service, String fileId,
String value, String type, String role) throws Exception {

Permission newPermission = new Permission();

newPermission.setValue(value);
newPermission.setType(type);
newPermission.setRole(role);
try {
return service.permissions().insert(fileId, newPermission).execute();
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
return newPermission;
}

}
< /code>
Наконец, я использую Maven для обработки зависимостей: < /p>

4.0.0

DriveTest
DriveTest
1.0-SNAPSHOT
jar

DriveTest
http://maven.apache.org


UTF-8




junit
junit
3.8.1
test


com.google.api-client
google-api-client
1.17.0-rc


com.google.api-client
google-api-client-appengine
1.17.0-rc


com.google.apis
google-api-services-drive
v2-rev105-1.17.0-rc


com.google.http-client
google-http-client-jackson
1.17.0-rc


com.google.appengine
appengine-api-1.0-sdk
1.8.1



Я уверен, что что -то пропустил, но не уверен, что это такое.


Подробнее здесь: https://stackoverflow.com/questions/212 ... -not-found

Вернуться в «JAVA»