I am attempting to read from Google Bigtable in my Java application. I am using the libraries-bom to manage both bigtable, as well as google-aiplatform. I am getting the following error when hitting my graphql endpoint to trigger Bigtable.
[c.i.p.s.r.f.CommonServiceLogFilter]-[339]-Error occurred in filter jakarta.servlet.ServletException: Request processing failed: java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: 'com.google.protobuf.Internal$ProtobufList com.google.bigtable.v2.RowSet.emptyList(java.lang.Class)'
package com.example.demo;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.api.gax.rpc.NotFoundException;
import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
import com.google.cloud.bigtable.data.v2.models.Row;
import com.google.cloud.bigtable.data.v2.models.RowCell;
import com.google.cloud.bigtable.data.v2.models.TableId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Bigtable {
private static final Logger logger = LoggerFactory.getLogger(Bigtable.class);
@Autowired
private AuthToken authToken;
public String queryByRowKey(String projectId, String instanceId, String tableId, String key) throws Exception {
String accessToken = authToken.makeCredential();
GoogleCredentials credentials = GoogleCredentials.create(new AccessToken(accessToken, null));
FixedCredentialsProvider credentialsProvider = FixedCredentialsProvider.create(credentials);
BigtableDataSettings settings =
BigtableDataSettings.newBuilder()
.setProjectId(projectId)
.setInstanceId(instanceId)
.setCredentialsProvider(credentialsProvider)
.build();
BigtableDataClient dataClient = BigtableDataClient.create(settings);
try {
System.out.println("nReading a single row by row key");
Row row = dataClient.readRow(TableId.of(tableId), key);
System.out.println("Row: " + row.getKey().toStringUtf8());
for (RowCell cell : row.getCells()) {
System.out.printf(
"Family: %s Qualifier: %s Value: %s%n",
cell.getFamily(), cell.getQualifier().toStringUtf8(), cell.getValue().toStringUtf8());
}
return row.toString();
} catch (NotFoundException e) {
System.err.println("Failed to read from a non-existent table: " + e.getMessage());
return null;
}
}
}
Here is my pom.xml file.
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-aiplatform</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable</artifactId>
<version>2.39.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.38.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
The service account being used here has the correct permissions to read from the table, and I’ve successfully been able to use Bigtable studio to query for a row key to get results. However, instead of a returned value I get the exception above.
I’ve tried pinning Bigtable to a specific version (2.39.0
) as I thought it’s possible there is a version conflict. Has anybody experienced this before and is able to provide guidance or steps on how to diagnose the root cause?
Johnny Bravo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.