I'm trying to include one of the Maxmind databases in my Java application. The database I am using is the latest version of GeoLite2-City.mmdb
.
When I drop the database file into the project (src/main/resources/GeoLite2-City.mmdb
) and I run the project I am able to use the database via com.maxmind.geoip2.DatabaseReader
and perform lookups of IP addresses.
However once I compile the project and create a jar file containing the database I am unable to read the database in the file, I get the exception:
com.maxmind.db.InvalidDatabaseException: Could not find a MaxMind DB metadata marker in this file (<InputStream>). Is this a valid MaxMind DB file?
Unzipping the .jar file and looking at the mmdb file I can see that the size of the file has changed from 38Mb to 59Mb, which I'm guessing is the reason for the exception being thrown.
Does anyone know of a way of packaging this file in a .jar so that it is usable? I've tried adding the original .gz file into the package, then decompressing that and then loading the database but that doesn't work either.
Thanks