0

I am following an example that does take serviceAccount , Application works fine when it is run locally. But when I try to deploy this application in Google Cloud Run ( gcloud run deploy --source . ) , it error out

The file firebase-adminsdk.json is present in src\main\resources application.properties list it as

firebase.credential.resource-path=firebase-adminsdk.json

The error is

nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [void]: Factory method 'firebaseInitialization' threw exception; nested exception is java.io.FileNotFoundException: class path resource firebase-adminsdk.json] cannot be resolved to absolute file path because it does not reside in the file system:

Full Error is

logName: "projects/projectXYZ/logs/run.googleapis.com%2Fstdout" receiveTimestamp: "2022-02-21T00:40:05.574893045Z" resource: {2} severity: "ERROR" textPayload: "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'firebaseInitialization' defined in com.example.helloworld.HelloworldApplication: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [void]: Factory method 'firebaseInitialization' threw exception; nested exception is java.io.FileNotFoundException: class path resource [firebase-adminsdk.json] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/workspace/target/helloworld-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/firebase-adminsdk.json at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:483) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.3.RELEASE.jar!/:2.3.3.RELEASE] at com.example.helloworld.HelloworldApplication.main(HelloworldApplication.java:26) ~[classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[helloworld-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) ~[helloworld-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[helloworld-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[helloworld-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [void]: Factory method 'firebaseInitialization' threw exception; nested exception is java.io.FileNotFoundException: class path resource [firebase-adminsdk.json] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/workspace/target/helloworld-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/firebase-adminsdk.json at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] ... 28 common frames omitted Caused by: java.io.FileNotFoundException: class path resource [firebase-adminsdk.json] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/workspace/target/helloworld-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/firebase-adminsdk.json at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:217) ~[spring-core-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:154) ~[spring-core-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at com.example.helloworld.HelloworldApplication.firebaseInitialization(HelloworldApplication.java:33) ~[classes!/:0.0.1-SNAPSHOT] at com.example.helloworld.HelloworldApplication$$EnhancerBySpringCGLIB$$b82b9488.CGLIB$firebaseInitialization$0() ~[classes!/:0.0.1-SNAPSHOT] at com.example.helloworld.HelloworldApplication$$EnhancerBySpringCGLIB$$b82b9488$$FastClassBySpringCGLIB$$75044087.invoke() ~[classes!/:0.0.1-SNAPSHOT] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] at com.example.helloworld.HelloworldApplication$$EnhancerBySpringCGLIB$$b82b9488.firebaseInitialization() ~[classes!/:0.0.1-SNAPSHOT] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar!/:5.2.8.RELEASE] ... 29 common frames omitted" timestamp: "2022-02-21T00:40:05.466235Z" }

puzzled
  • 509
  • 1
  • 5
  • 18

0 Answers0