NullPointerException 与 Zookeepers getZookeeperClusterKey

发布于 2024-10-26 07:18:36 字数 1368 浏览 1 评论 0原文

连接到 HBase 时,出现以下消息:

 java.lang.NullPointerException
    at java.lang.StringBuilder.<init>(StringBuilder.java:92)
    at org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper.getZookeeperClusterKey(ZooKeeperWrapper.java:956)

配置中似乎存在问题。我没有使用 xml 文件进行配置,但在我的代码中执行此操作。 作为记录,这是我的代码的配置部分:

usersTable = new HTable(config, "users");
config.set("hbase.zookeeper.quorum", "student-serv002.test");

我使用 Spring DM 从 OSGi 应用程序运行它。

编辑:

第 956 行周围的源代码如下:

public static String getZookeeperClusterKey(Configuration conf, String name) {
954     String quorum = conf.get(HConstants.ZOOKEEPER_QUORUM.replaceAll(
955         "[\\t\\n\\x0B\\f\\r]", ""));
956     StringBuilder builder = new StringBuilder(quorum);
957     builder.append(":");
958     builder.append(conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
959     if (name != null && !name.isEmpty()) {
960       builder.append(",");
961       builder.append(name);
962     }
963     return builder.toString();
964   }

显然,仲裁值不会被读取。然而,在常规的非 OSGi 应用程序中使用相同的代码并不是问题。

编辑:使用不同的方式提供配置似乎产生了效果。我现在收到以下错误:

java.lang.NullPointerException
    at org.apache.hadoop.hbase.client.HConnectionManager$ClientZKWatcher.getZooKeeperWrapper(HConnectionManager.java:231)

立即查看源代码。

When connecting to HBase, the following message occurs:

 java.lang.NullPointerException
    at java.lang.StringBuilder.<init>(StringBuilder.java:92)
    at org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper.getZookeeperClusterKey(ZooKeeperWrapper.java:956)

There seems to be a problem in the configuration. I'm not using an xml-file for configuration, but do this in my code.
For the record, this is the configuration part of my code:

usersTable = new HTable(config, "users");
config.set("hbase.zookeeper.quorum", "student-serv002.test");

I'm running this from an OSGi application using Spring DM.

EDIT:

the source code around line 956 is the following:

public static String getZookeeperClusterKey(Configuration conf, String name) {
954     String quorum = conf.get(HConstants.ZOOKEEPER_QUORUM.replaceAll(
955         "[\\t\\n\\x0B\\f\\r]", ""));
956     StringBuilder builder = new StringBuilder(quorum);
957     builder.append(":");
958     builder.append(conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
959     if (name != null && !name.isEmpty()) {
960       builder.append(",");
961       builder.append(name);
962     }
963     return builder.toString();
964   }

Obviously the value for quorum does not get read. Using the same code in a regular, non-OSGi application was not a problem however.

EDIT: using a different way of supplying the configuration seems to have had an effect. I now get the following error:

java.lang.NullPointerException
    at org.apache.hadoop.hbase.client.HConnectionManager$ClientZKWatcher.getZooKeeperWrapper(HConnectionManager.java:231)

Looking into the source right now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文