title: How can I retrieve the Geolocation from an IP address in Grails?
body: <p>I want to retrieve the geolocation from an IP-address in a Grails app. </p>
  
  <p>I tried <a href="http://grails.org/plugin/hostip" rel="nofollow">hostip</a> and <a href="http://grails.org/plugin/geoip" rel="nofollow">geoip</a> both raise exceptions and did not work for me. Is there any other way to get the geolocation?</p>
  
  <p>When I use geoip I have:</p>
  
  <p>config.groovy: </p>
  
  <pre><code>geoip.data.resource= "/WEB-INF/GeoLiteCity.dat"
  geoip.data.cache="GEOIP_STANDARD"
  </code></pre>
  
  <p>In my controller: </p>
  
  <pre><code>GeoIpService geoIpService
  
  index() {
      def location = geoIpService.getLocation("85.176.52.75")
      render location.countryName + " " + location.city       
  }
  </code></pre>
  
  <p>The exception is: </p>
  
  <pre><code>| Error 2013-07-26 14:04:22,236 [http-bio-8090-exec-1] ERROR   
  errors.GrailsExceptionResolver  - NullPointerException occurred when processing request:   [GET] /test/home/index
  Stacktrace follows:
  Message: null
  Line | Method
  -&gt;&gt;  199 | &lt;init&gt;                    in java.util.StringTokenizer
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |    221 | &lt;init&gt;                    in     ''
  |    624 | getLocationwithdnsservice in com.maxmind.geoip.LookupService
  |    593 | getLocation               in     ''
  |     42 | getLocation . . . . . . . in org.grails.geoip.service.GeoIpService
  |     12 | index                     in test.HomeController
  |    195 | doFilter . . . . . . . .  in    
  grails.plugin.cache.web.filter.PageFragmentCachingFilter
  |     63 | doFilter                  in grails.plugin.cache.web.filter.AbstractFilter
  |   1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
  |    615 | run                       in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . . . . . . . . . in java.lang.Thread
  </code></pre>