Exception while accessing maxmind's GeoIP-country.mmdb database through hive

半腔热情 提交于 2019-12-04 06:10:26

问题


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.<init>(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


回答1:


(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.



来源:https://stackoverflow.com/questions/25373364/exception-while-accessing-maxminds-geoip-country-mmdb-database-through-hive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!