I just upgraded my application from spring 2 -> 3 and since than I get a error related to Pub/Sub and the Credentials. I have tried to add a service account during the image build but that also doesn’t work.
#pubsub
spring.cloud.gcp.project-id=qzf-product-play-13cf
spring.cloud.gcp.pubsub.emulator-host=localhost:8681
spring.cloud.gcp.credentials.location=classpath:test.json
spring.cloud.gcp.project-id=local-project
I then see if it is picking up the file in the main method, which it is
public static void main(final String[] args) {
String credentialsLocation = "classpath:test.json";
System.out.println("Trying to load credentials from: " + credentialsLocation);
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
<version>3.5.4</version>
</dependency>
error
{"timestamp":"2024-05-14T06:21:54.56208905Z","@version":"1","msg":"Could not create publisher.","logger_name":"product.tt.serviceconfig.pubsub.AbstractEntityPublisher","thread_name":"main","severity":"ERROR","level_value":40000,"stack_trace":"java.io.IOException: Your default credentials were not found. To set up Application Default Credentials for your environment, see https://cloud.google.com/docs/authentication/external/set-up-adc.ntat com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:127)ntat com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:129)ntat com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:101)ntat com.google.api.gax.core.GoogleCredentialsProvider.getCredentials(GoogleCredentialsProvider.java:70)ntat com.google.api.gax.rpc.ClientContext.create(ClientContext.java:168)ntat com.google.cloud.pubsub.v1.stub.GrpcPublisherStub.create(GrpcPublisherStub.java:203)ntat com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:201)ntat com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:91)ntat com.google.cloud.pubsub.v1.Publisher$Builder.build(Publisher.java:881)
I am not sure what else to try. I have been at this for four days and cannot get passed this error.
Any advice would be greatly appreciated.
I don’t think your current version of spring-cloud-gcp-starter-pubsub is compatible with Spring 3 : https://googlecloudplatform.github.io/spring-cloud-gcp/5.2.1/reference/html/index.html#compatibility-with-spring-project-versions
Maybe upgrade it and see if that solves the issue.