hive udf, tried to access method org.bouncycastle.math.ec.ECPoint$AbstractFp

在hive中添加加密udf,测试报错:

select encrypt_sm2("aa","04AD9356466C7A505B3B2E18F2484E1F096108FA19C0F61C707A808EDF7C132BC3CE33E63D2CC6D77FB0A172004F8F5282CEADE22ED9628A02FE8FD85AF1EFE8B3");
Error: Error while compiling statement: FAILED: SemanticException [Error 10014]: Line 1:7 Wrong arguments '"04AD9356466C7A505B3B2E18F2484E1F096108FA19C0F61C707A808EDF7C132BC3CE33E63D2CC6D77FB0A172004F8F5282CEADE22ED9628A02FE8FD85AF1EFE8B3"': org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public java.lang.String com.hive.data.encrypt.sm2.EncryptSm2.evaluate(java.lang.String,java.lang.String):tried to access method org.bouncycastle.math.ec.ECPoint$AbstractFp.<init>(Lorg/bouncycastle/math/ec/ECCurve;Lorg/bouncycastle/math/ec/ECFieldElement;Lorg/bouncycastle/math/ec/ECFieldElement;)V from class com.hive.data.encrypt.sm2.SM2 (state=42000,code=10014)

加密算法包版本:

<dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
            <version>1.57</version>
        </dependency>

根据异常,发现方法调用没权限,本地测试是正常的,猜测应该是包冲突了;

linux上查看是否有其他jar包:

locate bcprov

 

发现hadoop lib里有该jar包,版本不一致,变更版本后,有些方法不兼容了,遂查询了下是否兼容两个包的方法;

找了下,可以变更下包名,兼容加载:

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-shade-plugin</artifactId>
			 <version>3.2.1</version>
			 <configuration>
             <!-- 改为true -->  
			 <createDependencyReducedPom>true</createDependencyReducedPom>
			 </configuration>
			 <executions>
				 <execution>
					 <!-- Maven 的生命周期 -->
					 <phase>package</phase>
					 <goals>
					 <!-- 插件目标 -->
					 <goal>shade</goal>
					 </goals>
		    <configuration>
				<!-- <minimizeJar>true</minimizeJar>-->
				 <!-- 配置多版本 jar 包中类路径的重命名
 					-->
			 <relocations>
				 <relocation>
					 <pattern>org.bouncycastle</pattern>
					 <shadedPattern>org.new.bouncycastle</shadedPattern>
				 </relocation>
			 </relocations>
			 <filters>
				 <filter>
					 <artifact>*:*</artifact>
				 <excludes>
				 <exclude>META-INF/*.SF</exclude>
				 <exclude>META-INF/*.DSA</exclude>
				 <exclude>META-INF/*.RSA</exclude>
				 </excludes>
				 </filter>
				 </filters>
 				</configuration>
		 </execution>
		</executions>
 </plugin>

参考:

【复盘】记录一次加解密包遇到的坑,tried to access method org.bouncycastle.math_ecpoint.fp 1.68版本_qxlxi的博客-CSDN博客

https://qxlxi.blog.csdn.net/article/details/123342190?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1.pc_relevant_default&utm_relevant_index=2

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值