Google app-engine for application that doesn't use app-engine - google-app-engine

As an experiment I attempted do deploy my "regular" (=vanilla create-application) grails-app to google app-engine.
Even though I have removed my repo locally, re-cloned to different folders etc I still get this message when I do a clean, or run-app or anything for that matter.
No Google AppEngine SDK specified. Either set APPENGINE_HOME in your environment or specify google.appengine.sdk in your grails-app/conf/BuildConfig.groovy file
Any ideas how to solve this?

I may have spoken too soon, I changed my app.name in application.properties and that solved it, I can't verify it but I guessing ivy-related (just a guess)

Related

Downloading App Engine source code

So it seems from a few SO questions I've seen that this is a problem among other users. Recently one of our head dev's left and I inherited a lot of his projects. One of which, is a website that what seems like lives on an app engine from google cloud platforms. From the App Engine documentation, to download source code you use the appcfg.py download_app command. Which I did, however the only results I get back from that call is:
Fetching file list...
Fetching files...
And then it just ends. No error message or any kind of message at all, and of course, it did not download the source code into the output dir I specified.
Scratching my head and looking at various SO posts, someone mentioned something about going into the google cloud vm directly and doing the same command, and to my surprise finding the same exact behavior that I did in my local terminal.
This made me realize it must be something else at play. I took a look at my versions tab in the App Engine dashboard on GCP. I see my instance running, it correctly says Serving and if I click the link it brings me to the website which loads fine. However, under Size it says 0 B which made me think perhaps this is why the download_app isn't downloading anything, because the version is 0 B?
What I'm trying to figure out is why it says 0 B for the version, when clearly the site runs fine and how I can get the source code for this. Here's a screenshot for reference
And screenshot of my terminal (local). Obviously I omitted the -A and -V flags, but they are correctly set and if I purposely make them incorrect I do indeed get an error message.
EDIT
Just so everyone is aware, I also made sure my user had the correct permissions. Owner, App Engine Owner... and some others. I don't think that's the problem.
When you deploy an App Engine Flexible application, the source code is uploaded to Cloud Storage on your project in a bucket named staging.<project-id>.appspot.com. You can navigate in this bucket and download the source code for a specific version as a .tar file.
Alternatively, you can find the exact Cloud Storage URL for your source code by going to Dev Console > Container Registry > Build History and select the build for your version. You'll find the link to your source code under Build Information.
One thing to note however is that the staging... bucket is created by default with a Lifecycle rule that deletes files older than 15 days automatically. You can delete this rule if you want so that all versions' source code is kept indefinitely.
In your case I believe that may not have helped since files may have been deleted already but it's worth knowing you can get the source code from there (source code isn't pushed to Source Repository by default, your developer had to configure it manually).
Posting this since none of the listed methods on the web didn't take me to the code (by June 2021)
Note: appcfg.py is deprecated by Google
You could try accessing your source code through;
Google Cloud Platform > Debugger > choosing the version of the
Application from combo at top.
This will list the files of that version on the left pane. There is no way to download code automatically but you can copy-paste the code.
Advice: Push your code to a Git repository to avoid this hassle next time.
Hope you will find this helpful.
In the developer console you can select the respective project and check:
on the Services page - which services, AKA modules - as they used to be (and still are) called in various places, you app has deployed
on the Versions page - which versions for each of the services are deployed
This information is what appcfg.py download_app expects. See also:
the various appcfg.py options using its --help flag
How do I download a specific service's source code off of AppEngine?
You can also access the deployed source code live (if everything else fails it could still be a last resort method to get the code, but tedious), see my answer to Google Cloud DataStore automatic indexing
Update:
I just now noticed in your screenshot that it's a flexible environment app. The appcfg.py docs are in the standard environment section, I suspect it's not applicable to the flexible environment, for which what's deployed is actually a docker image built during the deployment operation. From Deploying your application:
Deploy your app to App Engine using the gcloud app deploy
command. This command automatically builds a container image by using
the Container Builder service and then deploys that image to the
App Engine flexible environment. The container will include any local
modifications that you've made to the runtime image.
It might be possible to access the code on the actual GCE instance running the app, by connecting to the running instance and starting a shell in your app container, see Connecting to the instance

Cannot delete local datastore

I feel foolish asking this question, but I cannot seem to get my local datastore to clear for a project using GAE. I've consulted the following SE questions:
How to delete all datastore in Google App Engine?
GAE - I can't clear datastore and the datastore is corrupted I believe
Google App Engine Launcher delete datastore
I've also looked at the docs, and the command seems very clear among them all. I can navigate to the folder where dev_appserver.py is located and then run
dev_appserver.py --clear_datastore=yes <myappname>
Yet, I keep getting an error stating No such file or directory for my app.
I'm certain I'm entering the right name for my app, because it matches the name in my app.yaml file, it matches the folder my project is in locally, and it matches the name of the project on the GAE Launcher.
My app's local files are in a directory that is completely separate from the GAE install location, if that makes any difference. I tried running the command in my app's directory and it gives me the same error.
The name contains dashes, could that be causing a problem? I realize that this is not a verifiable example, but I'm out of ideas.
Thanks to Dan for his help. As he pointed out, the dev_appserver.py --help command explains that the .yaml file should be put in the position of the app's name. This is the final command that worked for me (run from the same directory as the .yaml file) was
dev_appserver.py --clear_datastore=yes app.yaml
Also, it appears that this command has cleared the local datastore for all of my GAE projects. That was not a problem for me but, if someone else needs to preserve a project on the local datastore while clearing another one, then a slightly different command may be required.

Google Contacts, Google Drive on Google App Engine 1.7.5 JAVA

using
gdata-contacts-3.0.jar,
google-api-services-drive-v2-rev43-1.12.0-beta.jar,
guava-13.0.1.jar
Google Drive works but not Google Contacts. (i tried all kinds of solutions but never got both working together on Google App Engine where as it works in local devmode.)
calling: ContactsService gservice = new ContactsService("...");
Caused by: java.lang.NoSuchMethodError:
com.google.common.collect.ImmutableSet.copyOf([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
at
com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
at
com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
at com.google.gdata.wireformats.AltFormat.(AltFormat.java:49)
at com.google.gdata.client.Service.(Service.java:558)
I had the same issue in my project, but it was solved when I used gdata 1.47.1. It can be found at http://code.google.com/p/gdata-java-client/downloads/detail?name=gdata-samples.java-1.47.1.zip
As I am using Maven, I uploaded it to my Nexus. Added dependency in pom.xml and it was started working.
One more thing to notice, I am using guava 13.0. If it helps you.
OK now it works. Nobody was able to see that i used to
Add Google APIs from the Eclipse Plugin.
This does not only just add new jars that do not work in combination but also leaves all those old ones in a subfolder in my project ".google_apis...". Somehow those made it to Google App Engine and the odyssey started.
After removing those ... everything works fine. So again and, as everywhere mentioned, i was using a mixed guava version bulk which human nature does not expect to being activated.

Google App Engine not updating deployed files

I'm getting some strange issues with google app engine serving old versions of files. I have included some logging in one of my servlets and deployed to google app engine several times over the last 24 hours. However, instead of seeing the logging i added, I'm seeing logs from a previous version of the file every time the servlet runs.
I've tried changing versions and redeploying but this doesnt seem to fix the problem.
I'm using Eclipse Juno with the app engine plugin if that makes a difference.
Any ideas what I can try or what I might be doing wrong?
I had a similar problem recently, and that I fixed by logging into appengine.google.com>MyAppIdentifier>(Main)>Versions and selecting the current version as the default.
This should not only serve your latest version, but also use the latest version for log viewing and other administrative tasks.
In the logs, make sure that you're checking the correct version:
Otherwise redeploy to a brand new version and check that version explicitly directly from the version url that can be found under the Versions section.
Make sure that before redeploying your APP after making changes you Remove Launch and Remove All Terminated launches by pressing the double cross buttons next to the "clear console" buttons on the console window in Eclipse...I hope this solve your problem.
December 2020 Answer
Not sure if this is an account or billing specific setting, but I found that App Engine started not updating to my latest app deploy once I reached 50 Versions in my App Engine list.
After deleting a bunch of old versions (taking down to 30) on next deploy it picked up my latest changes immediately.
It could be due to caching issue. Try reloading the website by adding a query parameter . Eg <website-url>?q=1 and see if changes are reflected
Open the url -> latest-version-number-dot-website-url . Latest version number can be obtained by clicking on version menu item on the side bar as seen below
If you have app.yaml file in your source code. Try removing headers related to caching and deploy and check to confirm its a caching issue. Caching headers could be of below form
Cache-Control: public, max-age=604800, immutable
Also make sure your project compiles correctly and doesn't contain any errors. I had this problem basically because I was deploying old compiled code, while it gave me an error "you have errors in your project, are you sure you want to deploy?"
I tried all the suggestions on SO, but ultimately, I found the best fix.
Because I transferred domain names and web hosting, I neglected to change my Domain's Resource Records. After making sure my code worked properly with the application (appname.appspot.com), I created a Custom Domain found in Console menu > App Engine > Settings > Custom domains
After you add the custom domain, make sure you change your Domain setting's CNAME www alias to the prescribed value (for me it was ghs.googlehosted.com).
Since changing that CNAME value, all of my subsequent deploys updated immediately. Hope this works for you and all others. Happy coding!
The gcloud (at list in python) has problem with line 'skip_files' in app.yaml,
So you can try the old method of deploying app with app engine,
use appcfg.py instead of gcloud.
see how in https://cloud.google.com/appengine/docs/standard/python/tools/uploadinganapp

possible to eliminate JDO/JPA-related JARs from GAE project if using Twig/Objectify/etc?

In my Google App Engine project, I'm currently using Twig for accessing the Datastore (but I suspect my question would be relevant for other 3rd party libs like SimpleDS, Objectify, etc.).
I was thinking that I should be able to delete some or all of the following JARs from my WEB-INF/lib folder:
datanucleus-appengine-[...].jar
datanucleus-core-[...].jar
datanucleus-jpa-[...].jar
geronimo-jpa_[...].jar
geronimo-jta_[...].jar
jdo2-api-[...].jar
But when I do, I get errors from Eclipse complaining that "The App Engine SDK JAR is missing in the WEB-INF/lib directory".
Is it really necessary to retain all these (unused) JARs?
If you're using the Google Plugin for Eclipse you can delete these JARs and then open the Properties for your Google Web Application project and open the Google > App Engine and then uncheck the Use datanucleus JDO/JPA to access the datastore. In fact, unchecking this box actually deletes these JARs for you.
I don't think you can delete them from the project (as you have said, eclipse starts to complain), but I've heard you don't have to upload them to your app, as long as you upload from the command line. This has the advantage that at startup your app won't have to load them up.
There are some details of uploading to app engine via the command line here and confirmation that you can do this here
If you manage to do this I would appreciate it it if you post links to the instructions you followed or post what you needed to do, as I have this on my todo list as well, but only got as far as seeing if it was possible. Thanks!

Resources