While I was deploying my google app engine project (Java) using gradle appengineDeploy
my internet connection was interrupted.
I re-deployed the project. Although the console said BUILD SUCCESSFUL
, the app engine instance no longer works. No matter how many times I re-deploy or update my application, the logs show nothing but errors:
java.lang.NoClassDefFoundError: com/google/appengine/api/ThreadManager at com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter.createClient (GoogleAppEngineControlFilter.java:61) at com.google.api.control.ControlFilter.init (ControlFilter.java:141) at org.eclipse.jetty.servlet.FilterHolder.initialize (FilterHolder.java:139) at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:873) at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:349) at org.eclipse.jetty.webapp.WebAppContext.startWebapp (WebAppContext.java:1406) at com.google.apphosting.runtime.jetty9.AppEngineWebAppContext.startWebapp (AppEngineWebAppContext.java:175) at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1368) at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:778) at org.eclipse.jetty.servlet.ServletContextHandler.doStart (ServletContextHandler.java:262) at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:522) at com.google.apphosting.runtime.jetty9.AppEngineWebAppContext.doStart (AppEngineWebAppContext.java:120) at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68) at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler (AppVersionHandlerMap.java:240) at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler (AppVersionHandlerMap.java:178) at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest (JettyServletEngineAdapter.java:120) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest (JavaRuntime.java:747) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest (JavaRuntime.java:710) at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run (JavaRuntime.java:680) at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run (JavaRuntime.java:872) at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run (ThreadGroupPool.java:270) at java.lang.Thread.run (Thread.java:748) Caused by: java.lang.ClassNotFoundException: com.google.appengine.api.ThreadManager at java.net.URLClassLoader.findClass (URLClassLoader.java:381) at com.google.apphosting.runtime.ApplicationClassLoader.findClass (ApplicationClassLoader.java:135) at java.lang.ClassLoader.loadClass (ClassLoader.java:424) at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
Is there some way for me to clear out the partial build (or whatever there may be) in google app engine?
I tried deleting all versions and instances (you cannot delete them all, it won't let you delete the serving one).
I tried increasing the version number in appengine-web.xml.
I tried gradle clean.
I tried disabling and enabling the application in the google cloud console.
No luck.
One idea I have is maybe if I can somehow force all the files for the app to be uploaded again? Because with gradle appengineDeploy
only the changed files get uploaded.
EDIT:
I managed to fix one part of this by upgrading classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0'
in my gradle to the latest version. (Felt kind of hackish to do that and not reliable in the future if this happens again.) Maybe this flushed whatever was in app engine or something by doing that. I still have one problem remaining:
I am using the firebase admin SDK to send firebase cloud messages (authenticated with a .json credentials file) like this:
FirebaseMessaging.getInstance().send(msg);
When I do I am getting this error:
com.google.firebase.messaging.FirebaseMessagingException: Unexpected HTTP response with status: 401; body: null
Which is strange because other parts of the firebase admin SDK are working (like writing/reading from firestore).
So there is still something weird going on and I think it has to do with the fact that as I was uploading my google app engine project the connection was interrupted.
EDIT 2:
Here is something interesting: When I deploy my application using gcloud app deploy appengine-web.xml
the application again will not work. Deploying with gradle appengineDeploy
does though. I also noticed that the size of the application is shown as much smaller in the GCP console when deploying with gcloud app deploy appengine-web.xml
. So something is messed up here. I tried looking up some sort of gcloud
command to clear cache? Or something like that but no luck.
EDIT 3: Additional Info: My app was already deployed and working before the failed attempt. I changed one small piece of code in a function and upon uploading the app, the connection was interrupted because the internet went out.
I am on app engine standard environment. I am deploying my application from the macOS terminal and using android studio to develop.
I have tried the stopPreviousVersion
promote
and version
configs in gradle (actually the first two are true by default and version
gets auto-generated if you do not set it).
Running gcloud app deploy appengine-web.xml --verbosity=debug
shows a lot of sensitive information but one thing I am seeing is all the files in WEB-INF
are being skipped:
DEBUG: Skipping upload of [WEB-INF/....
INFO: Incremental upload skipped 100.0% of data
DEBUG: Uploading 0 files to Google Cloud Storage
DEBUG: Using [16] threads
So perhaps files are not all being uploaded? This SO post raises a similar problem but has no solution: stackoverflow.com/q/42137452/3075340
It's weird but when I do gcloud app deploy
, the app won't work at all. There are run-time errors all over the place. Doing gradle appengineDeploy
fixes that but I still am having the firebase-admin
issue.