无法为Storm的JdbcInsertBolt加载Phoenix JDBC驱动程序

时间:2018-10-11 09:56:00

标签: java hbase apache-storm phoenix

在Apache的Storm JdbcInsertBolt初始化期间,出现错误

java.lang.ClassCastException: 
  Cannot cast org.apache.phoenix.jdbc.PhoenixDriver to javax.sql.DataSource
at com.zaxxer.hikari.util.UtilityElf.createInstance(UtilityElf.java:90)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:292)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:84)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:102)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:71)
at org.apache.storm.jdbc.common.HikariCPConnectionProvider.prepare(HikariCPConnectionProvider.java:53)
at org.apache.storm.jdbc.mapper.SimpleJdbcMapper.<init>(SimpleJdbcMapper.java:43)

来自基础HikariCPConnectionProvider。怎么了?

我正在关注http://storm.apache.org/releases/1.1.2/storm-jdbc.html,基于此,我正在做的事情:

我喜欢通过Phoenix将数据从Apache Storm拓扑写入HBase表。为此,我从群集服务器下载了驱动程序文件(phoenix-4.7.0.2.6.5.3003-25-client.jar),并将其添加到本地maven存储库中:

mvn install:install-file 
  -Dfile=lib\phoenix-4.7.0.2.6.5.3003-25-client.jar 
  -DgroupId=org.apache.phoenix 
  -DartifactId=phoenix-jdbc -Dversion=4.7.0 -Dpackaging=jar

此后,我更新了.pom

<dependency>
    <groupId>org.apache.phoenix</groupId>
    <artifactId>phoenix-jdbc</artifactId>
    <version>4.7.0</version>
</dependency>

现在添加Storm的JDBC-Bolt:

<dependency>
    <groupId>org.apache.storm</groupId>
    <artifactId>storm-jdbc</artifactId>
    <version>1.2.2</version>
    <scope>provided</scope>
</dependency>

然后我准备使用螺栓。首先:设置连接提供程序:

Map hikariConfigMap = new HashMap();
hikariConfigMap.put("dataSourceClassName", "org.apache.phoenix.jdbc.PhoenixDriver");
hikariConfigMap.put("dataSource.url", "<zookeeperQuorumURI>:2181:/hbase-unsecure");
this.connectionProvider = new HikariCPConnectionProvider(hikariConfigMap);

现在将元组值初始化为db-columns-mapper

this.simpleJdbcMapper = new SimpleJdbcMapper(this.tablename, connectionProvider);

在此期间,发生上述错误。

仅出于完整性考虑:JdbcInsertBolt的创建方式如下:

new JdbcInsertBolt(this.connectionProvider, this.simpleJdbcMapper)
        .withTableName(this.tablename)
        .withQueryTimeoutSecs(30);

1 个答案:

答案 0 :(得分:1)

您是否尝试设置:

driverClassName -> org.apache.phoenix.jdbc.PhoenixDriver。当前代码似乎已经设置了dataSourceClassName,我猜这是不同的

引用this