Divs Divs - 1 year ago 135
Java Question

Unable to launch in GAE

I must be doing something very silly, but would appreciate some help to point it out..

I'm trying to use the codebase to test connect a Google Cloud SQL instance with a GAE Application. I was able to run it successfully in local, but it seems that it gets deployed successfully also in AppEngine, but when I try to access myproject.appspot.com, I get a 404.
Following are the steps I followed (skipping the successful local related steps)

1. Created a project


2. Created a Google Cloud SQL 2nd Generation instance,

2. Created a
user with a password.

3. Used the connection string as indicated in Google Cloud Console

4. appengine-web.xml looks like below

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">

<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
<property name="cloudsql.url" value="jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&amp;password=PASSWORD;"/>
<property name="cloudsql.url.dev" value="jdbc:mysql://localhost/demo?user=root&amp;useSSL=false"/>

5. The following code snippet is embedded in HibernateJPAServlet

if (System.getProperty("com.google.appengine.runtime.version")
.startsWith("Google App Engine/")) {
} <br>

6. I've uploaded the code from my local to default myproject repository


7. I launched the Google Cloud Platform Console from the "Development" view.

8. Successfully ran
mvn clean package
mvn appengine:update
. I cannot perform a
from my local due to firewall/proxy restrctions.

9. So, at this point, my understanding is, I am running a GAE application and GAE Cloud SQL instance for the same project. So
should host the application I uploaded Step 8. But when I access it says
"404" - "The requested URL / was not found on this server."

Just in case the problem is we can't deploy it from Cloud Console, then what other alternative do I have? I absolutely can't change network/proxy rules.

EDITED - I tried running and deploying the application with
mvn gcloud:run
mvn gcloud:deploy
from outside proxy/firewall restrictions. At the end it clearly stated
"Deployed URL: [https://myproject.appspot.com]"
. But the same issue remains when I access the same Url through browser.

EDITED - I am able to see the error trace from App Engine dashboard. It is saying

" org.hibernate.exception.JDBCConnectionException: Could not open connection
Caused by: org.hibernate.exception.JDBCConnectionException: Could not open connection
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.

My Connection string is "jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&password=PASSWD123&"

Answer Source

It was my Bad (also partially Documentation gap and I've given feedback too). Everytime we deploy the app through appengine or gcloud, the newly deployed version should be visible through the "App Engine > Versions" Tab. We should "Split Traffic" and give "100%" (for testing) to the Newly deployed version and then launch "https://myproject.appspot.com" to see the results we want to see.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download