You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Activity
jabubake commentedon Jun 28, 2018
Hi @shamal , sorry for the late response here. It seems like you may not have configured authentication correctly.
https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine-java8/cloudsql
Please see the setup instructions in the README.md regarding authentication:
If you're still running into issues, feel free to reopen.
chore(main): release 0.124.11-SNAPSHOT (#955)
chore(main): release 0.124.11-SNAPSHOT (#955)
chore(main): release 0.124.11-SNAPSHOT (#955)
deps: update dependency com.google.cloud:google-cloud-core to v2.8.6 (#…
chore(deps): update dependency com.google.cloud:libraries-bom to v23.…
chore(deps): update dependency com.google.cloud:libraries-bom to v23.…
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
samples: migrate code from googleapis/java-vision (#7428)
chore(deps): update dependency com.google.cloud:libraries-bom to v23.…
chore(deps): update dependency com.google.cloud:libraries-bom to v24.…
samples: migrate code from googleapis/java-vision (#7428)
deps: update dependency com.google.cloud:google-cloud-pubsub to v1.12…
chore(main): release 3.6.6 (#956)