Reputation: 3055
I'm trying to create a Vertica UDx
JAR is generated via
javac -classpath /opt/vertica/bin/VerticaSDK.jar BuildInfo.java TestFactory.java Test.java -d output/
jar -cvf TestLib.jar BuildInfo.class output/*.class
Loading into DB via
CREATE LIBRARY TestFunctions AS '/home/dbadmin/test/TestLib.jar' LANGUAGE 'JAVA';
Getting the error
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
Local & remote server's JDK version are the same 1.8.0_131
Vertica version 8.0.1
JAR tree
├── com
│ └── vertica
│ ├── JavaLibs
│ │ ├── Test.class
│ │ └── TestFactory.class
│ └── sdk
│ └── BuildInfo.class
VERTICA_BUILD_ID_Brand_Version = "v8.0.1-5";
Upvotes: 1
Views: 470
Reputation: 3055
Solved this issue by compiling it on the server
to make this answer more informative :
$ 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 & use function
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 ...
Upvotes: 3