I am trying to deploy a restful spring app that connects to a MySQL database. I am deploying it in gcp appengine and the database is also a gcp sql instance. I have tested the my code locally on my machine and the application connects perfectly to the sql instance. However when I try and run the application in the appengine I get a FileNotFoundException. I have already made the necessary additions to my pom file. The full error is
2020-05-18 17:33:03 default[1] 2020-05-18 17:33:03.364 INFO 10 --- [onnection adder] c.google.cloud.sql.mysql.SocketFactory : Using GAE Unix Sockets
2020-05-18 17:33:05 default[1] 2020-05-18 17:33:05.153 INFO 10 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJt
aPlatform]
2020-05-18 17:33:05 default[1] 2020-05-18 17:33:05.179 INFO 10 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-05-18 17:33:06 default[1] 2020-05-18 17:33:06.703 INFO 10 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.117 WARN 10 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.bea
ns.factory.BeanCreationException: Error creating bean with name 'googleCredentials' defined in class path resource [org/springframework/cloud/gcp/autoconfigure/core/GcpContextAutoConfiguration.class]: Bean instantiation via factory met
hod failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.api.gax.core.CredentialsProvider]: Factory method 'googleCredentials' threw exception; nested exception is java.io.
FileNotFoundException: src/main/resources/pigeon-276916-a62807e029a3.json (No such file or directory)
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.118 INFO 10 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.121 INFO 10 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.127 INFO 10 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.167 INFO 10 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.176 INFO 10 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.204 INFO 10 --- [ main] ConditionEvaluationReportLoggingListener :
2020-05-18 17:33:07 default[1]
2020-05-18 17:33:07 default[1] Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-05-18 17:33:07 default[1] 2020-05-18 17:33:07.218 ERROR 10 --- [ main] o.s.boot.SpringApplication : Application run failed
2020-05-18 17:33:07 default[1]
2020-05-18 17:33:07 default[1] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'googleCredentials' defined in class path resource [org/springframework/cloud/gcp/autoconfigure/core/GcpContextAutoC
onfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.google.api.gax.core.CredentialsProvider]: Factory method 'googleCre
dentials' threw exception; nested exception is java.io.FileNotFoundException: src/main/resources/pigeon-276916-a62807e029a3.json (No such file or directory) at org.springframework.beans.factory.support.ConstructorResolver.instantiat
e(ConstructorResolver.java:656) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484) ~[spring-beans-5.2.6.R
ELEASE.jar!/:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEAS
E] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.bean
s.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapabl
eBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
I have made double sure that pigeon-276916-a62807e029a3.json does exist in location spring-backend/src/main/resources/pigeon-276916-a62807e029a3.json and is referenced in my application.properties file as spring.cloud.gcp.credentials.location=file:src/main/resources/pigeon-276916-a62807e029a3.json
Thank you for that. I found that simply commenting out the spring.cloud.gcp.credentials... solved the issue. It was only needed to run locally on my dev machine. I am working with cloud computing for the very first time so I have no clue how all the configurations work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With