【发布时间】:2016-04-28 09:55:58
【问题描述】:
我正在尝试在 Google App Engine 上使用 MaxMind GeoIP2。在本地它可以工作,但是当我在 GAE 上部署它时,由于类受限而出现错误
java.lang.NoClassDefFoundError: java.nio.MappedByteBuffer is a restricted class. Please see the Google App Engine developer's guide for more details.
at java.nio.channels.FileChannel.map(FileChannel.java)
at com.maxmind.db.BufferHolder.<init>(BufferHolder.java:31)
at com.maxmind.db.Reader.<init>(Reader.java:116)
at com.maxmind.geoip2.DatabaseReader.<init>(DatabaseReader.java:39)
at com.maxmind.geoip2.DatabaseReader.<init>(DatabaseReader.java:27)
at com.maxmind.geoip2.DatabaseReader$Builder.build(DatabaseReader.java:133)
是否有任何“技巧”,例如使用特定版本的 GeoIP2,不会使用此错误?我通过 gradle 使用 2.7.0 版本
compile group: "com.maxmind.geoip2", name: "geoip2", version: "2.7.0"
有人尝试过旧版 GeoIP 吗?有运气吗?我唯一的目的是了解如何使用这个库,如果可能的话,或者找到一个提供相同功能的替代库(从 IP 获取国家的 ISO 代码)
【问题讨论】:
-
谢谢@sidgate 是的,问题出在哪里很明显(java.nio.MappedByteBuffer 类不能使用)但是因为我想使用 GeoIP 库,所以我问是否有人解决了怎么办已经(如果可能的话)。
标签: java google-app-engine maxmind