使用key' null'找不到HBase配置

时间:2016-04-05 17:33:22

标签: java maven hbase apache-storm

我创建风暴拓扑,使用hbase bolt将元组写入hbase。 但是当我运行拓扑时,它总是显示下面的错误。 有人知道如何解决这个问题吗?

java.lang.IllegalArgumentException: HBase configuration not found using key 'null'
at org.apache.storm.hbase.bolt.AbstractHBaseBolt.prepare(AbstractHBaseBolt.java:60) 

我已经在pom.xml文件中序列化hbase-site.xml,如下所示:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <transformers>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">
                    </transformer>
                </transformers>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>java</executable>
                <includeProjectDependencies>true</includeProjectDependencies>
                <includePluginDependencies>false</includePluginDependencies>
                <classpathScope>compile</classpathScope>
                <mainClass>${storm.topology}</mainClass>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>${basedir}/conf</directory>
            <filtering>false</filtering>
            <includes>
                <include>hbase-site.xml</include>
            </includes>
        </resource>
    </resources>

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

将hbase配置参数传递给拓扑。

for i = 1:length(r)
 a = [a ; cellstr(r{i})]

1)在风暴配置中输入新设置HBASE_CONFIG_KEY。

public static final String HBASE_CONFIG_KEY = "hbase.conf";

2)在Hbase Bolt配置中设置配置密钥HBASE_CONFIG_KEY

Config config = new Config();
String rootDir = topologyConfig.getProperty("hbase.rootdir");
Map<String, Object> hbConf = new HashMap<>();
hbConf.put("hbase.rootdir", rootDir);
config.put(HBASE_CONFIG_KEY, hbConf);
StormSubmitter.submitTopology(topologyName, config, buildTopology());

这对我有用。