java - 无法在 32 位 windows 机器上创建 grpc 连接
问题描述
我正在尝试使用我的 java 代码和 GCP 提供的几个库来访问我的 GCP 项目中的订阅者列表。此代码在我的 64 位 Windows 环境中运行良好,但在 32 位 Windows 环境中无法运行。
我在一些文档中看到,说 netty 在 32 位机器上不支持,如果需要,我们可以构建自己的二进制文件。
https://netty.io/wiki/forked-tomcat-native.html#how-to-build
CredentialsProvider credentialsProvider =
FixedCredentialsProvider.create(
ServiceAccountCredentials.fromStream(new FileInputStream(JSONPath)));
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create(SubscriptionAdminSettings.newBuilder().setCredentialsProvider(credentialsProvider).build())) {
ListSubscriptionsRequest listSubscriptionsRequest =
ListSubscriptionsRequest.newBuilder()
.setProject(ProjectName.of(ProjectId).toString())
.build();
SubscriptionAdminClient.ListSubscriptionsPagedResponse response =
subscriptionAdminClient.listSubscriptions(listSubscriptionsRequest);
logger.log(Level.SEVERE,"response List: "+response.toString());
Iterable<Subscription> subscriptions = response.iterateAll();
for (Subscription subscription : subscriptions) {
if(subscription.getName().equals(SubscriptionId)){
return true;
}
}
[20:02:30:384]|[06-17-2019]|[io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts]|[INFO]|[36]:netty-tcnative 不可用(此可能是正常的)| java.lang.IllegalArgumentException:无法加载任何给定库:[netty_tcnative_windows_x86_32,netty_tcnative_x86_32,netty_tcnative] at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:104) at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:526) 在 io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.(OpenSsl.java: 93)在io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:244)在io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java: 171) 在 io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts。
解决方案
您回答了自己的问题... netty-tcnative-* 不支持 32 位平台,因此您需要自己编译并将其包含在您的类路径中。
推荐阅读
- java - 在视图之间导航后,组件未正确加载
- php - 使用没有数据库的身份验证登录
- node.js - Angular 前端不会立即更新
- java - 在个人资料活动中滚动查看
- html - 下拉菜单在点击前消失
- docker - kube-proxy 问题 - 尝试将 Windows 工作节点添加到 kubernetes 集群
- tomcat8 - Ubuntu 服务器 18.04.2 上的 Tomcat 8.5.39
- java - 如何从 github 的几个页面中获取用户存储库
- php - Laravel 无法使用 DB::getDatabaseName() 获取正确的数据库名称
- typescript - 使用 TaskTimer 每 n 秒调用一次函数