I have a custom hive UDF to access Maxmind's GeoIP-country.mmdb database that is added to the hive resources through "add file pqr.mmdb". The compiled UDF is added as "add jar abc.jar"

When I run a hive query, behind the scenes the java class tries to access the data in geo database and fails by throwing the following exception.

Error: java.lang.ClassNotFoundException: com.maxmind.db.Reader$FileMode

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

at com.maxmind.geoip2.DatabaseReader$Builder.(DatabaseReader.java:68)

I tried the following two lines separately but it still throws the same error. My database file and jar's are all added to hive resources.

reader = new DatabaseReader.Builder(database).fileMode(Reader.FileMode.MEMORY_MAPPED).build();

AND

reader = new DatabaseReader.Builder(database).fileMode(Reader.FileMode.MEMORY).build();

Has anyone experienced a similar issue ?

Thanks !

- Lalith

解决方案

(Moved this to an actual answer.)

The geoip2-0.8.0-with-dependencies.zip file contains all of the JARs that the API depends on. The ZIP file is created during the build of GeoIP2. The included JARs are all dependencies or dependencies of dependencies listed in the pom.xml file. The zip is listed on the releases page.

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐