Google Cloud SQL connection error - google-app-engine

I am new to Google App engine and I have tried to run an demo application called guestbook to connect to Google cloud sql from the Google app engine with app-engine-sdk version 1-7.0. But each time I am getting an error saying "java.lang.IllegalStateException: System property rdbms.driver must be set at com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver.registerDriver(LocalRdbmsServiceLocalDriver.java:80)". I double check my code and every thing looks ok, and I still have no glue where the error coming from.
Below is a snippet of my connection code :
c = DriverManager.getConnection("jdbc:google:rdbms://my_instance/my_database");
and mysql-connector-java-5.1.21-bin is in the class path,
and I have enable Google cloud sql in the Google app engine,
and I have checked the use of Google Cloud instance in the app engine as well with the my instance of the database, database name, login , and password,
and I am using Eclipse Juno.
I think I have missed something important; so would you please help me if you know what I have missed.
Thank you very much in advance,
Minh

Once you are new to GAE I recommend to give a try on the Big Table database. Using it you will not have to setup any database localy. So just the eclipse plugin will be enough for your first test. The Guestbook uses this database so it will be easier to follow the tutorial.

Related

unable to connect cloud sql from app engine

I am new to GCP. I created a cloud-SQL instance (PostgreSQL 14) and tried to connect to it from the app engine.
I am using the following code on github.
https://github.com/GoogleCloudPlatform/python-docs-samples/tree/9d4343d0845d6e20e0b08d1242c38aaaf0d9c075/appengine/standard_python3/cloudsql
main_postgres.py-> as my main file
I updated the connection information in the app.yaml file according to the instance and database I created. I did not make any other changes to the main_postgres.py file.
I deployed app engine in the directory with main_postgres.py
After deploying when I go to the link it says :
I am not able to figure out where I am going wrong. any help is appreciated. thanks!
I managed to replicate the github link you provided. I solved it by renaming the main_postgres.py file to main.py. Here's the screenshot of the output link:
This issue dont seems related to DB but your application configuration.
check errors by running this in cloud shell when you hit appengine url.
gcloud app logs tail

How can we use Google Datastore Objectify remotely?

I am trying to use Google Objectify for Datastore (https://github.com/objectify/objectify). My app is not hosted on GAE, but I still make use of Datastore, so I need to use the remote API. Right now, I use the low level API and connect successfully like this :
DatastoreOptions options = DatastoreOptions.builder()
.projectId("PROJECT_NAME")
.authCredentials(AuthCredentials.createApplicationDefaults()).build();
Datastore client = options.service();
And the library used is http://googlecloudplatform.github.io/gcloud-java/0.2.0/index.html. My application defaults for "AuthCredentials.createApplicationDefaults()" is in my home folder in development as well as on the server.
In the doc I saw for Objectify, I did not see anyway of specifying the connection like above, thus no way of telling to use the credentials file in our home folder. The code I see for Objectify is mostly like this Objectify.ofy(). So I see no way with this method of telling to use the auth credentials defaults.
Thank you very much.
Use the Google App Engine remote api:
https://cloud.google.com/appengine/docs/java/tools/remoteapi
You could try gcloud-java datastore module.
http://googlecloudplatform.github.io/gcloud-java/0.2.0/index.html
But I encounter some performance issues on outside of Google Sandbox (GAE-Compute Engine)

Can't deploy to GAE - the application doesn't exist

Using Eclipse, I am experiencing an error when trying to deploy a rather basic web app with JAX-RS and JAXB. It runs okay locally, but when trying it on the remote servers I get the message shown below...
'Deploying to Google' has encountered a problem / This application does not exist
Below shows my appengine-web.xml
The XML file illustrates that I am using the same name in the xml as what's specified in the project properties...
The output window show...
------------ Deploying frontend ------------
Preparing to deploy:
Created staging directory at: '/var/folders/n8/6by626014jbfc0dwmxnb0ly00000gn/T/appcfg2754901216637807129.tmp'
Scanning for jsp files.
Scanning files on local disk.
Initiating update.
com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=hillingarincident&version=0&
404 Not Found
This application does not exist (app_id=u'hillingarincident').
Debugging information may be found in /private/var/folders/n8/6by626014jbfc0dwmxnb0ly00000gn/T/appengine-deploy447984481661870877.log
The referenced debug logs show...
Unable to update:
com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=hillingarincident&version=0&
404 Not Found
This application does not exist (app_id=u'hillingarincident').
at com.google.appengine.tools.admin.AbstractServerConnection.send1(AbstractServerConnection.java:293)
at com.google.appengine.tools.admin.AbstractServerConnection.send(AbstractServerConnection.java:253)
at com.google.appengine.tools.admin.AbstractServerConnection.post(AbstractServerConnection.java:232)
at com.google.appengine.tools.admin.AppVersionUpload.send(AppVersionUpload.java:644)
at com.google.appengine.tools.admin.AppVersionUpload.beginTransaction(AppVersionUpload.java:449)
at com.google.appengine.tools.admin.AppVersionUpload.doUpload(AppVersionUpload.java:124)
at com.google.appengine.tools.admin.AppAdminImpl.doUpdate(AppAdminImpl.java:371)
at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:53)
at com.google.appengine.eclipse.core.proxy.AppEngineBridgeImpl.deploy(AppEngineBridgeImpl.java:433)
at com.google.appengine.eclipse.core.deploy.DeployProjectJob.runInWorkspace(DeployProjectJob.java:148)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Any answers will be appreciated. At one point my browser was not logged in to the target google account, so I swapped to the correct one a little later, Google does render the application name as expected.
Okay, this was simple in the end! Eclipse performs an auto-login to the Google account, unfortunately I created the Eclipse project whilst being logged in to one Google account and then tried to specify the application name afterwards.
You'll see in the bottom-right (or bottom-left in some versions) a Google icon with the name of the user that you are logged in as. If that's not the account where your application is defined, then simply logout of that account, then login as the correct Google account.
Now there's no error :-)
I know this question is super old but I had this issue all day and finally I found a solution. Maybe it will help someone out in the future.
After you create a project in Google Cloud Platform, you must go to google cloud shell in your project and run the command
gcloud beta app create
After you run this command, you will get prompted to choose a region. Then go back to eclipse and try deploying it. It worked for me.
There are not just 1 way can cause this problem. For me, I have this problem when I create the project using Maven. But I don't have the same issue if I directly create the project from the Google plugin.
There might be another issue, when you register with Google App Engine, you receive email indicating your activation. If you have not received the email yet, this problem could occur too.
Another issue could be to use the gmail account for the Google App Engine to avoid any such errors.

Cannot authorize my google app to access my Cloud SQL instance

I have deployed an application on App Engine. Now I m trying to grant access to this app to be able to access my Cloud SQL instnace. The step is simple and straightforward as described here:
https://developers.google.com/cloud-sql/docs/access_control
However when I fill in the app id and push " save changes" I get the error:
"An unexpected error has occurred. We're looking into it."
Anybody has an idea about that issue?
UPDATE:
After spending some time on the issue I made the following observations:
I m located in the European Union. Therefore I created an Cloud SQL instance in the european Union zone. When I try to add an authorized application to my SQL instance I get the error that posted above:
"An unexpected error has occurred. We're looking into it."
Then I created a new SQL instance in United States. I was then able to authorize application for that instance. However my application was not able to access the US SQL instance since I guess my app is deployed somewhere in European Union.
Could someone from the google support team confirm my observations and explain me how can i solve this issue?
Your GAE app and Cloud SQL instance must be in the same location:
https://developers.google.com/cloud-sql/faq#location
You can currently (Nov 27, 2012) create GAE apps in the EU only if you are a premier customer.
https://developers.google.com/appengine/docs/premier/location
This a known issue with Cloud SQL - currently the app and the Cloud SQL locations must match. Unfortunately you currently can't have a (free) EU app. So its catch 22 if you've chosen an EU Cloud SQL. You need to delete your current SQL instance and add a new one that is in the US.
That doesn't explain your second issue though - if the instance allows you to add the app, then the app must be in the US and you are facing a different issue. Also note that if you have a free app then it is by definition in the US - you can't currently choose app location on the free version.
I am not a Google support btw :D This info is from replies to me from Google people in the google group.

Export from AppEngine database to the local development database?

Is there a way to export the data on my AppEngine database to the development server (for testing purposes etc.) ?
Yes! Check out Google's "Uploading and Downloading Data"
If you'd like to test how your data
works with the app before uploading
it, you can load it into the
development server. Use the --url
option to point the tool at the
development server URL. For example:
appcfg.py upload_data --config_file=album_loader.py --filename=album_data.csv --kind=Album --url=http://localhost:8080/remote_api <app-directory>
The subsection on uploading and downloading all data is also worth looking at.
Not yet it seems
Of course you can go pulling the data yourself, one batch at a time...
Yes we can download all data from google app engine and can upload to datastore but sometimes uploading data to local development server is painfull because of errors. App Engine SDK versioning diffrences occurs this like problems. For example i developed an app 1 year ago. Today, i want update it. I downloaded all data from Google App Engine real servers. But i can't upload its to local development server. You know, we using EntityLoader class for this operation. Entity Class importing db module, but SDK throws, "no module named by db".
I suggest for App Engine lovers that; save your first test data for future. Don't think that i will download all datum for testing future. Save your own test data with Sqlite support. And save your deveopment enviromenment version for future. SDK Version updating sometimes causing painfully times for developers

Resources