When FinApp Server is started in a Cloud Shell environment, the following Exception is thrown and it does not start.
According to the doc, when we use a Google Cloud cloud-based development environment such as Cloud Shell or Cloud Code, the applications running on the environment uses the credentials we provided when we logged in, and manages any authorizations required.
However, the grpc-java used by FinApp Server does not take this into account, so an error occurs when FinApp Server is started in a Cloud Shell environment.
As far as I've tried, using grpc-java v1.43.0+ instead of v1.38.0 solved this issue.
Since this application is used as the official Cloud Spanner sample, this fix should help users.
Expected Behavior
$ java -jar server/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar --spanner_project_id=<YOUR_PROJECT> --spanner_instance_id=<YOUR_INSTANCE> --spanner_database_id=finance-db
Dec 09, 2022 3:55:00 PM com.google.finapp.FinAppServer start
INFO: Server started, listening on 8080
Actual Behavior
$ java -jar server/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar --spanner_project_id=<YOUR_PROJECT> --spanner_instance_id=<YOUR_INSTANCE> --spanner_database_id=finance-db
Exception in thread "main" java.lang.NoSuchMethodError: 'io.grpc.alts.GoogleDefaultChannelCredentials$Builder io.grpc.alts.GoogleDefaultChannelCredentials.newBuilder()'
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:326)
at com.google.api.gax.grpc.ChannelPool.<init>(ChannelPool.java:105)
at com.google.api.gax.grpc.ChannelPool.create(ChannelPool.java:83)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:236)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:230)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:201)
at com.google.cloud.spanner.v1.stub.GrpcSpannerStub.create(GrpcSpannerStub.java:231)
at com.google.cloud.spanner.spi.v1.GapicSpannerRpc.<init>(GapicSpannerRpc.java:411)
at com.google.cloud.spanner.spi.v1.GapicSpannerRpc.<init>(GapicSpannerRpc.java:302)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerRpcFactory.create(SpannerOptions.java:469)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerRpcFactory.create(SpannerOptions.java:464)
at com.google.cloud.ServiceOptions.getRpc(ServiceOptions.java:560)
at com.google.cloud.spanner.SpannerOptions.getSpannerRpcV1(SpannerOptions.java:1320)
at com.google.cloud.spanner.SpannerImpl.<init>(SpannerImpl.java:132)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerFactory.create(SpannerOptions.java:459)
at com.google.cloud.spanner.SpannerOptions$DefaultSpannerFactory.create(SpannerOptions.java:454)
at com.google.cloud.ServiceOptions.getService(ServiceOptions.java:540)
at com.google.finapp.ServerMain.getSpannerDao(ServerMain.java:55)
at com.google.finapp.ServerMain.main(ServerMain.java:33)
Steps to Reproduce the Problem
- Open Cloud Shell environment.
- Initialize
finance-db
- Run
java -jar server/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar --spanner_project_id=<YOUR_PROJECT> --spanner_instance_id=<YOUR_INSTANCE> --spanner_database_id=finance-db
Solution
Specifications
When FinApp Server is started in a Cloud Shell environment, the following Exception is thrown and it does not start.
According to the doc, when we use a Google Cloud cloud-based development environment such as Cloud Shell or Cloud Code, the applications running on the environment uses the credentials we provided when we logged in, and manages any authorizations required.
However, the grpc-java used by FinApp Server does not take this into account, so an error occurs when FinApp Server is started in a Cloud Shell environment.
As far as I've tried, using grpc-java v1.43.0+ instead of v1.38.0 solved this issue.
Since this application is used as the official Cloud Spanner sample, this fix should help users.
Expected Behavior
Actual Behavior
Steps to Reproduce the Problem
finance-dbjava -jar server/target/server-1.0-SNAPSHOT-jar-with-dependencies.jar --spanner_project_id=<YOUR_PROJECT> --spanner_instance_id=<YOUR_INSTANCE> --spanner_database_id=finance-dbSolution
Specifications