通过配置单元访问maxmind的GeoIP-country.mmdb数据库时出现异常 [英] Exception while accessing maxmind's GeoIP-country.mmdb database through hive

查看:967
本文介绍了通过配置单元访问maxmind的GeoIP-country.mmdb数据库时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义配置单元UDF来访问通过add file pqr.mmdb添加到配置单元资源的Maxmind的 GeoIP-country.mmdb 数据库。已编译的UDF被添加为add jar abc.jar
当我运行配置单元查询时,在后台Java类尝试访问地理数据库中的数据,并通过抛出以下异常失败。

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)

我尝试了以下两行,但它仍然会引发相同的错误。我的数据库文件和jar都添加到配置单元资源。

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();

有没有人遇到类似的问题?
谢谢!
- Lalith

Has anyone experienced a similar issue ? Thanks ! - Lalith

推荐答案

(将此移至实际答案。)

(Moved this to an actual answer.)

geoip2-0.8.0-with-dependencies.zip文件包含API依赖的所有JAR。 ZIP文件是在GeoIP2构建过程中创建的。所包含的JAR都是 pom.xml文件中列出的依赖关系的依赖关系或依赖关系。该邮件列于发布页面

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.

这篇关于通过配置单元访问maxmind的GeoIP-country.mmdb数据库时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆