简体   繁体   中英

The API package 'memcache' or call 'FlushAll()' was not found

I am testing some code locally using Google Apps Engine SDK 1.9.12. I have added a servlet listener to initialize memcache with 2 namespaces. I have added code inside the method contextDestroyed(ServletContextEvent sce) to clear the Memcache entries:

MemcacheServiceFactory.getMemcacheService().clearAll();

This actually throws the following exception and the server is down:

WARNING: EXCEPTION 
com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'memcache' or call 'FlushAll()' was not found.
    at com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:179)
    at com.google.apphosting.api.ApiProxy$1.get(ApiProxy.java:177)
    at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:88)
    at com.google.appengine.api.memcache.MemcacheServiceImpl.quietGet(MemcacheServiceImpl.java:26)
    at com.google.appengine.api.memcache.MemcacheServiceImpl.clearAll(MemcacheServiceImpl.java:170)
    at com.valeo.general.util.BaseCacheManager.clearAll(BaseCacheManager.java:47)
    at com.valeo.general.listeners.BaseCacheListener.contextDestroyed(BaseCacheListener.java:27)
    at org.mortbay.jetty.handler.ContextHandler.doStop(ContextHandler.java:599)
    at org.mortbay.jetty.webapp.WebAppContext.doStop(WebAppContext.java:505)
    at org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
    at org.mortbay.jetty.handler.HandlerWrapper.doStop(HandlerWrapper.java:142)
    at org.mortbay.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:76)
    at com.google.appengine.tools.development.JettyContainerService.reloadWebApp(JettyContainerService.java:393)
    at com.google.appengine.tools.development.JettyContainerService$2.filesChanged(JettyContainerService.java:380)
    at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:486)
    at org.mortbay.util.Scanner.reportDifferences(Scanner.java:352)
    at org.mortbay.util.Scanner.scan(Scanner.java:280)
    at org.mortbay.util.Scanner$1.run(Scanner.java:232)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)

Please help me to resolve this.

By the time the App Engine Java framework calls your code in contextDestroyed(ServletContextEvent) it has already torn down the connection to the backend services, including memcache.

So unfortunately you cannot use a ServletContextListener to perform memcache operations on shutdown.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM