问题描述
java.sql.SQLException: java.lang.reflect.InvocationTargetException
at org.apache.phoenix.parse.FunctionParseNode.create(FunctionParseNode.java:280)
at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:336)
at org.apache.phoenix.compile.ProjectionCompiler$SelectClauseVisitor.visitLeave(ProjectionCompiler.java:700)
at org.apache.phoenix.compile.ProjectionCompiler$SelectClauseVisitor.visitLeave(ProjectionCompiler.java:585)
at org.apache.phoenix.parse.FunctionParseNode.accept(FunctionParseNode.java:86)
at org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:412)
at org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:561)
at org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:507)
at org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:193)
at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:153)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:490)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:456)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:302)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:291)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:290)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:283)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1830)
at sqlline.Commands.execute(Commands.java:822)
at sqlline.Commands.sql(Commands.java:732)
at sqlline.SqlLine.dispatch(SqlLine.java:813)
at sqlline.SqlLine.begin(SqlLine.java:686)
at sqlline.SqlLine.start(SqlLine.java:398)
at sqlline.SqlLine.main(SqlLine.java:291)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.phoenix.parse.FunctionParseNode.create(FunctionParseNode.java:268)
... 23 more
Caused by: java.lang.RuntimeException: java.lang.SecurityException: Loading jars from hdfs://192.168.75.200:9000/hbase/lib/hidataUdf-0.0.1.jar is not allowed. The only location that is allowed is hdfs://node1:9009/hbase/lib
at org.apache.phoenix.expression.function.UDFExpression.constructUDFFunction(UDFExpression.java:170)
at org.apache.phoenix.expression.function.UDFExpression.<init>(UDFExpression.java:72)
... 28 more
Caused by: java.lang.SecurityException: Loading jars from hdfs://192.168.75.200:9000/hbase/lib/hidataUdf-0.0.1.jar is not allowed. The only location that is allowed is hdfs://node1:9009/hbase/lib
at org.apache.phoenix.expression.function.UDFExpression.getClassLoader(UDFExpression.java:201)
at org.apache.phoenix.expression.function.UDFExpression.constructUDFFunction(UDFExpression.java:163)
... 29 more
出现这个问题的原因是由于,定义UDF函数的时候,指定的jar包路径和hdfs-site.xml中配置的路径不一致
解决方案
将路径更改为一致
注:1.使用ticket client方式需要将hdfs-site.xml放在类路径下面,否则会读取默认的hdfs-site.xml文件,导致执行UDF函数失败。
可参考这个帖子:https://blog.csdn.net/gucapg/article/details/85999067