The API package 'file' or call 'Create()' was not found

704 views
Skip to first unread message

Christophe DA COSTA

unread,
May 31, 2015, 1:07:51 PM5/31/15
to google-a...@googlegroups.com

I am trying to use the blobstore API, but I have this error:

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backed method com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'file' or call 'Create()' was not found. at java.lang.Thread.getStackTrace(Thread.java:1589) at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:116) at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:65) at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:590) at com.google.appengine.api.files.FileServiceImpl.create(FileServiceImpl.java:512) at com.google.appengine.api.files.FileServiceImpl.createNewBlobFile(FileServiceImpl.java:111) at com.listecourses.model.ListeModelEndpoint.insertListeModel(ListeModelEndpoint.java:182) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:45) at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359) at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:113) at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:71) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437) at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444) at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:230) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308) at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300) at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441) at java.lang.Thread.run(Thread.java:745)

I using this code:

@ApiMethod(name = "insertListeModel", httpMethod = "POST") public ListeModel insertListeModel(ListeModel listemodel) { EntityManager mgr = getEntityManager(); try { if (containsListeModel(listemodel)) { throw new EntityExistsException("Object already exists"); } FileService fileService = FileServiceFactory.getFileService(); if(listemodel.getImage()!=null && !listemodel.getImage().equals("")) { byte[] data = listemodel.getImage(); String mimeType = "image/png"; // save data to Google App Engine Blobstore listemodel.setImage(null); mgr.persist(listemodel); AppEngineFile file; file = fileService.createNewBlobFile(mimeType,"LM_"+listemodel.getId()); FileWriteChannel writeChannel = fileService.openWriteChannel(file, true); writeChannel.write(java.nio.ByteBuffer.wrap(data)); writeChannel.closeFinally(); // your blobKey to your data in Google App Engine BlobStore BlobKey blobKey = fileService.getBlobKey(file); // THANKS TO BLOBKEY YOU CAN GET FOR EXAMPLE SERVING URL FOR IMAGES // UploadOptions uploadOptions = UploadOptions.Builder // .withGoogleStorageBucketName("photobucket11"); // Get the image serving URL (in https:// format) String imageUrl = ImagesServiceFactory.getImagesService().getServingUrl(ServingUrlOptions.Builder.withBlobKey(blobKey).secureUrl(true)); // ImagesService imagesService = ImagesServiceFactory // .getImagesService(); // ServingUrlOptions servingOptions = ServingUrlOptions.Builder // .withBlobKey(blobKey); // String imageUrl = imagesService.getServingUrl(servingOptions); if(listemodel.getIdBlobkey()!=null) { BlobKey blobKeytmp= new BlobKey(listemodel.getIdBlobkey()); final AppEngineFile f = fileService.getBlobFile(blobKeytmp); if(f.isReadable()) { if(f.hasFinalizedName()) { fileService.delete(f); // Problematic line } } } listemodel.setAvatar(imageUrl); listemodel.setIdBlobkey(blobKey.getKeyString()); } mgr.persist(listemodel); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { mgr.close(); } return listemodel; }

Can you help me?

thanks

Vinny P

unread,
May 31, 2015, 4:11:59 PM5/31/15
to google-a...@googlegroups.com

On Sun, May 31, 2015 at 12:07 PM, Christophe DA COSTA <toto...@gmail.com> wrote:

I am trying to use the blobstore API, but I have this error:

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backed method com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'file' or call 'Create()' was not found. at java.lang.Thread.getStackTrace



Typically that error message means that you're missing the Files API library within your project or path. You might want to check your build setup and make sure the library is available.

However, another more pressing issue is that you're using the Files API. File is deprecated and will soon be removed - see the notice here: https://cloud.google.com/appengine/docs/deprecations/files_api . You'll want to move to using Google Cloud Storage to hold your files: https://cloud.google.com/appengine/docs/java/googlecloudstorageclient/

 
 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com



Alex Martelli

unread,
Jun 1, 2015, 3:47:26 PM6/1/15
to google-a...@googlegroups.com
I think you're being hit by the files API deprecation, see


Alex

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/7b87b420-3259-4551-81e2-dd69e308af7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christophe DA COSTA

unread,
Jun 2, 2015, 6:58:46 AM6/2/15
to google-a...@googlegroups.com
Thanks for yours answers,

I am trying to use the Google Cloud Storage but I have this erreur:

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backed method
java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer
	at com.google.appengine.tools.cloudstorage.oauth.OauthRawGcsServiceFactory.<clinit>(OauthRawGcsServiceFactory.java:31)
	at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createRawGcsService(GcsServiceFactory.java:59)
	at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:44)
	at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:40)
	at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:75)
	at com.listecourses.model.ListeModelEndpoint.insertListeModel(ListeModelEndpoint.java:204)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:45)
	at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
	at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:113)
	at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:71)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
	at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:230)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
	at java.lang.Thread.run(Thread.java:745)

my code is:

GcsFilename fileName = new GcsFilename("my-bucket-name", "someFileName.jpg");
GcsOutputChannel outputChannel = GcsServiceFactory.createGcsService().createOrReplace(fileName, GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(listemodel.getImage()));
outputChannel.close();


I think, I am missing the file API library whitin my project. I join the image of my project's libraries.

Sans titre.png

Ryan (Cloud Platform Support)

unread,
Jun 2, 2015, 10:06:07 AM6/2/15
to google-a...@googlegroups.com, toto...@gmail.com
Salutations Christophe,

If you go to the Migrating from the Files API page you will see that error means you are missing libraries. I would read through the page and see what libraries you are missing.

Christophe DA COSTA

unread,
Jun 3, 2015, 12:03:14 PM6/3/15
to google-a...@googlegroups.com, toto...@gmail.com
I don't find the solution....

I added appengine-testing.jar and appengine-api-stubs.jar but I have the same Error.
I see on thegooglecloudstorageclient getstarted page that I need this lybraries:
  • appengine-gcs-client.jar 
  • guava-15.0.jar
  • joda-time-2.3.jar
  • appengine-testing.jar
  • appengine-api.jar 
  • appengine-api-stubs.jar

So, now I use all this.

Ryan (Cloud Platform Support)

unread,
Jun 3, 2015, 2:29:06 PM6/3/15
to google-a...@googlegroups.com, toto...@gmail.com
Can you provide a screenshot of where the jars are? As well as an updated screenshot showing your classpath?

Christophe DA COSTA

unread,
Jun 3, 2015, 5:34:41 PM6/3/15
to google-a...@googlegroups.com, toto...@gmail.com


Vinny P

unread,
Jun 3, 2015, 10:36:54 PM6/3/15
to google-a...@googlegroups.com
The JAR file "google-http-client-1.20.0.jar" contains the missing class your exception is reporting (com/google/api/client/http/HttpRequestInitializer). I don't see the filename in your build path screenshot - the closest name I see is "google-http-client-appengine" which contains appengine specific services, not the general http library.

Try going to https://developers.google.com/api-client-library/java/google-api-java-client/download, retrieving the ZIP file there, and adding the file named google-http-client-1.20.0.jar to your project.


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.

Christophe DA COSTA

unread,
Jun 5, 2015, 4:01:24 AM6/5/15
to google-a...@googlegroups.com

tx.

I added the .jar, and now I have this error:

Error Code: 400
Reason: badRequest
Message: java.lang.IllegalArgumentException: OBJECT_NOT_FOUND: 
Reply all
Reply to author
Forward
0 new messages