我正在尝试创建Vertica UDx
通过
生成JARjavac -classpath /opt/vertica/bin/VerticaSDK.jar BuildInfo.java TestFactory.java Test.java -d output/
jar -cvf TestLib.jar BuildInfo.class output/*.class
通过
加载到数据库中CREATE LIBRARY TestFunctions AS '/home/dbadmin/test/TestLib.jar' LANGUAGE 'JAVA';
获取错误
SQL Error [2175] [55000]: [Vertica][VJDBC](2175) ROLLBACK: An error occurred when loading library file on node v_test_node0002, message: Failure in UDx RPC call InvokeCheckLibrary(): Error in User Defined Object [], error code: 0 Error happened in loading jar file, the user library might be built with a new version of JDK
[Vertica][VJDBC](2175) ROLLBACK: An error occurred when loading library file on node v_test_node0002, message: Failure in UDx RPC call InvokeCheckLibrary(): Error in User Defined Object [], error code: 0 Error happened in loading jar file, the user library might be built with a new version of JDK
com.vertica.util.ServerException: [Vertica][VJDBC](2175) ROLLBACK: An error occurred when loading library file on node vtest_node0002, message: Failure in UDx RPC call InvokeCheckLibrary(): Error in User Defined Object [], error code: 0 Error happened in loading jar file, the user library might be built with a new version of JDK
本地&远程服务器的JDK版本是相同的1.8.0_131
Vertica版本8.0.1
JAR tree
├── com
│ └── vertica
│ ├── JavaLibs
│ │ ├── Test.class
│ │ └── TestFactory.class
│ └── sdk
│ └── BuildInfo.class
VERTICA_BUILD_ID_Brand_Version = "v8.0.1-5";
答案 0 :(得分:3)
通过在服务器上编译来解决此问题
使这个答案更具信息性:
$ ls
TestFactory.java Test.java
# compile all java files with VerticaSDK & BuildInfo
$ javac -classpath /opt/vertica/bin/VerticaSDK.jar /opt/vertica/sdk/BuildInfo.java *.java -d .
# show compiled files
$ find . -type f
./com/vertica/sdk/BuildInfo.class ./com/vertica/JavaLibs/TestFactory.class ./com/vertica/JavaLibs/Test.class ./TestFactory.java ./Test.java
# combine compiled classes into single jar
$ jar -cvf TestLib.jar com/vertica/sdk/BuildInfo.class com/vertica/JavaLibs/*.class
added manifest adding: com/vertica/sdk/BuildInfo.class(in = 1315) (out= 749)(deflated 43%) adding: com/vertica/JavaLibs/Test.class(in = 1238) (out= 717)(deflated 42%) adding: com/vertica/JavaLibs/TestFactory.class(in = 916) (out= 435)(deflated 52%)
$ ls
com TestFactory.java Test.java TestLib.jar
load&使用功能
CREATE LIBRARY TestFunctions AS '/path/TestLib.jar' LANGUAGE 'JAVA';
CREATE ANALYTIC FUNCTION a_test AS LANGUAGE 'java' NAME 'com.vertica.JavaLibs.TestFactory' LIBRARY TestFunctions;
SELECT a_test(col, args) OVER (ORDER BY col2) FROM ...