Friday Repost: Making Grails work behind an proxy server

The Friday Repost series are copies from my earlier writings. Since I don’t want to loose them, and they might prove useful to others, I’m reposting them on this blog.

Making Grails work behind an NTLM firewall (or using Grails without Internet)

Currently, I’m in the process of taking over an existing Grails project and migrating it to a different location. This location has been setup by me, so I have full control over it, except for one tiny detail: the Proxy Server.

The application used to work great, and installing plugins was a breeze: just do a good old ‘grails install-plugin fitnesse’, and the plugin would be installed. However, since this Proxy Server is not just any Proxy Server, but a Microsoft NTLM Proxy Server, we tried quite hard to make Java work with it, but at the moment the score is 1-0 for the Proxy Server. This gives us the following problems:

1) Our dependencies cannot be downloaded
2) Our plugins cannot be be downloaded
3) Some plugins cannot be installed anymore

Downloading dependencies
In our BuildConfig.groovy, we specified some dependencies like joda time and xstream. These dependencies are normally downloaded, but due to our Proxy issue, that doesn’t work.

Our solution to this is to use Nexus. Nexus is able to pass the firewall, and can download our dependencies. It serves as a transparent Maven proxy, which can also be used by Ivy, and solves our problem nicely. Besides, it’s a good idea to install a local Maven proxy anyway, mostly because of reliability, but also because of speed and making sure everyone uses the same dependencies.

Downloading plugins
Unfortunately, the Grails plugins are not in a Maven repository. However, a solution to this is to download the plugin zip (eg, rename it (to, put it in the lib directory (even though I’m really not a fan of putting binaries in version control systems), and register it in the and BuildConfig.groovy.

The BuildConfig.groovy should look like this:

grails.project.dependency.resolution = {
    inherits "global" // inherit Grails' default dependencies
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    repositories {
        mavenRepo "" // nexus repo
    dependencies {
        compile ('com.thoughtworks.xstream:xstream:1.3.1') {
            excludes "stax","stax-api"

    plugins {
        runtime ':hibernate:1.3.2'
        runtime ':tomcat:1.3.2'
        runtime ':fitnesse:0.2'

As you can see, everything is configured here: the dependencies are here, the location to nexus is configured, and there’s a plugin closure. This “plugins” closure defines the plugins, and allows you to place them in the ‘lib’ directory. Be sure to rename the plugin zip to remove the ‘grails’ part, else it doesn’t work. Maybe these zips are also available from a Maven repository, which would solve the issue of putting binaries in our source control system, but I haven’t been able to find them yet.

Plugin installation
Some plugins, like the jQuery plugin, but also like my own plugin, the syntax-highlighter, download resources from the Internet when installing them. I haven’t been able to work around that yet, but my current solution is to just not use those plugins. I downloaded the jQuery javascript libraries and attached them to the project myself, and since we only use jQuery which does that, this solution is also an adequate fix.

So, as you can see, with some effort, it’s possible to make Grails work behind a Proxy Server, or without internet at all. This is a good solution for build servers, so you can have reproducible builds without the need for an Internet connection.

Erik Pragt
Erik Pragt
Erik Pragt is a passionate software developer with a broad range of experience in both static dynamic (Java, Scala) languages. Having worked as a consultant for a broad range of customers mostly in the Telecom, ISP, and banking sector, Erik is now an independent freelance consultant. In the limited time he's not sitting behind the computer he can be found in the gym, riding his motorcycle or diving, always looking for new inspiration.
Recommended Posts
Showing 8 comments
  • Gethin James

    I download the Grails pluglins, then manually install them in our local Maven repo – in your case Nexus. Then you don’t need to mess about with putting things in the lib directory.

    Also “inherit false” works better for BuildConfig.groovy

  • Gethin James

    Also @pledbrook tweeted today that:

    “an –offline option has been added to #grails HEAD. I’ll be testing it soon.”


    • Erik Pragt

      Based on the tweet, it’s a bit hard to say what it does. Do you have more information? Does it mean that no dependency resolution would be done? Cause that would be a nice improvement in startup time.

  • Leo

    We are also behind corporate proxy server but common grails proxy settings work fine in our case. We have something like the following in ProxySettings.groovy

    myproxy=[“http.proxyHost”:”companyproxyserver”, “http.proxyPort”:”8080″, “http.proxyUserName”:”myuser”, “http.proxyPassword”:”mypassword”]

    Have you tried similar config in your case?

    • Erik Pragt

      Hi Leo,

      We’ve tried that, but it didn’t work with our proxy server. Did you also use a Microsoft NTLM proxy server?


    • Siva

      Could you please let me know if you how to use .pac file for proxy for grails?

      • Erik Pragt

        Hi Siva, I’m sorry, but I have no experience with .pac files. I know you can open them, they are just txt files, and with a bit luck, depending on the complexity of the pac, you might be able to find the correct configuration there.

  • Sami Mäkelä


    We are using Artifactory as a local Maven provy and it works great.
    It speeds up building Grails apps (when it’s downloading th whole internet)

Start typing and press Enter to search