Hive - 自定义UDF - HttpClient依赖冲突

hive 专栏收录该内容
16 篇文章 1 订阅

1、报错信息:


# FAILED: SemanticException [Error 10014]: 
Line 2:22 Wrong arguments '"蔡徐坤asda EXO"': 
org.apache.hadoop.hive.ql.metadata.HiveException: 
Unable to execute method public static java.lang.String GetStarKeyWord.evaluate(java.lang.String)  
on object GetStarKeyWord@6a937336 of class GetStarKeyWord 
with arguments {蔡徐坤asda EXO:java.lang.String} of size 1

2、排查错误:

网上显示多为 evaluate方法名错误,其实不然;因为没进去方法体,所以无详细信息可查,逐步测试…

3、真实原因:

引用的HttpClienthive-exec还有hadoop-common自带的冲突

4、排除冲突jar

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2.5</version>
        </dependency>


        <dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-exec</artifactId>
            <version>1.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-httpclient</groupId>
                    <artifactId>commons-httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>2.7.1</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-httpclient</groupId>
                    <artifactId>commons-httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

5、httpclient-4.2.5版本Get,Post方法

       //设置连接超时
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, 5 * 1000);
        HttpConnectionParams.setSoTimeout(params, 5 * 1000);


        org.apache.http.client.HttpClient httpclient = new DefaultHttpClient(params);
        HttpGet request = new HttpGet(url);

        HttpResponse response = null;
       try {
            response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
            json_str = EntityUtils.toString(entity, "UTF-8");
            }
        } catch (IOException e) {
            e.printStackTrace();
            LOG.info("连接超时:" + e.getMessage());
        }
  • 0
    点赞
  • 2
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值