Closed
Description
In which file did you encounter the issue?
java-docs-samples/appengine-java8/cloudsql
Did you change the file? If so, how?
No changes.
Describe the issue
I run the demo locally with
mvn clean appengine:run -DINSTANCE_CONNECTION_NAME=_<my-instance-name>_ -Duser=root -Dpassword=_<my-root-password>_ -Ddatabase=database1
I get exception as below:
javax.servlet.ServletException: Unable to connect to Cloud SQL
at com.example.appengine.cloudsql.CloudSqlServlet.init(CloudSqlServlet.java:116)
..........
... 65 more
Caused by: java.lang.RuntimeException: Unable to retrieve information about Cloud SQL instance [shamalk:us-central1:db-1]
at com.google.cloud.sql.core.SslSocketFactory.obtainInstanceMetadata(SslSocketFactory.java:411)
.............
... 78 more
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
{
"code" : 401,
"errors" : [ {
"domain" : "global",
"location" : "Authorization",
"locationType" : "header",
"message" : "Invalid Credentials",
"reason" : "authError"
} ],
"message" : "Invalid Credentials"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
..............
... 86 more
I have allowed 0.0.0.0/0 for my DB instance.
And I'm able to connect using gcloud sql connect db-1 --user=root
without any issues.
Metadata
Metadata
Assignees
Labels
No labels