groovy

Steve Dalton's picture

Beware "grails set-proxy" and http client call

Just a quick gotcha we found today. Took us a while to work it out and we ended up fixing it on a hunch, so thought we would share here.

We are using Grails 1.2.1 on a client site and had used "grails set-proxy" to allow us to download grails plugins. Our application made a http client connection using the built in groovy new URL(url).openStream() to another web service (also Grails application). Anyway when running the application in dev mode the client application was failing on the openStream() call with a http status code 503. The meaning of this status code is:

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

We had no idea what was going on, the code had worked before. On a hunch we removed the proxy configuration and Voila! it worked again. This confused me a bit as:

1. I thought grails set-proxy was only for the grails runtime and not the internal tomcat server?
2. The 503 message was very confusing - didn't seem to describe what was really happening, although this was possibly the way our Microsoft proxy server was interpreting the request.

Anyone else experienced this. Is this a bug?

Steve Dalton's picture

Twitter Groovy scripts from Podcamp Gold Coast

I had the pleasure of doing a basic intro to Social Media APIs session at the Gold Coast Podcamp on Saturday 20th Feb. I tried to make it as basic as possible, but did include some Groovy code that interacted with the Twitter API. Anyway here's the code for anyone that's interested, for groovyists - it's not very idiomatic Groovy code, but I wanted to keep it pretty simple and not use any external libraries.

Follow another user's friends:

Unfollow all your friends

Follow all users that mention a hashtag (can be modified to do replies or mentions)

Steve Dalton's picture

Grails log4j configuration and custom environments

If like me, you have different appenders depending on the grails environment - you might not have realised that custom environments don't work with the log4j config DSL. So code like this doesn't work:

log4j = {
     appenders {
         development {
             rollingFile name: "mylog",
                     file: 'mylog.log', layout: pattern(conversionPattern: '%d{ISO
         }
         test {
             rollingFile name: "mylog",
                     file: 'mylog.log', layout: pattern(conversionPattern: '%d{ISO
         }
         beta {
             rollingFile name: "mylog",
                     file: '/tmp/mylog-beta.log',
                     layout: pattern(conversionPattern: '%d{ISO8601} [%t] %p %c
         }
         production {
            rollingFile name: "mylog",
                     file: '/tmp/mylog-beta.log',
                     layout: pattern(conversionPattern: '%d{ISO8601} [%t] %p %c
         }
    }

The beta environment won't be picked up and you will get some error in your logs about it for other environments. In any case the configuration doesn't look very DRY to me. Probably better to just have the filename into a separate config param in your Config.groovy, then just refer to it from a single appender

myapp.logLocation = 'mylog.log'

environments {
    production {
        myapp.logLocation = '/tmp/mylog.log'
    }
    beta {
        myapp.logLocation = '/tmp/mylog.log'
    }
}

log4j = {
    appenders {
            rollingFile name: "mylog",
                    file: myapp.logLocation, layout: pattern(conversionPattern: '%d{ISO8601} [%t] %p %c %x - %m%n')
    }

Still not completely very DRY, wish I could do something like

environments {
     production, beta {
         somesharedconfig = 'foo'
     }

Hopefully they'll come up with some way to do this nicely in future grails releases.

Steve Dalton's picture

Groovy around the Globe - Australia & New Zealand

This article is the first in a series that will examine the Groovy/Grails/Griffon community around the world - it first appeared in the November issue of GroovyMag.

We all love the technology, and this series will focus on the people that help to make technology great – colleagues from the farthest flung corners of the globe. This first article focuses on one of the the most remote regions: Australia & New Zealand.

A far-flung land

Tucked away in a oft-forgotten corner of the Southern Pacific are the sparsely-populated countries of Australia and New Zealand. Despite the relative isolation from the rest of the development community (and each other), there's been a long history of innovation and contribution to Open Source projects from the Aussie and Kiwi developers over the years.

Australia in particular is a very urban society: 82% of the citizens live primarily in the eight state and territorial capitals. However, the population of 22 million is spread over an area the size of Europe, which makes face-to-face meetings of the tech community a pretty rare thing. Despite the long and dusty distances separating the capitals, a great sense of community and collaboration prevails. New Zealand has an even smaller population (about two million) and the development community is even more thinly dispersed; however, there is also a surprising amount of activity coming from this remote land.

Conferences

Despite the geographic challenges, in the Open Source area there are two successful annual conferences in the region: Open Source Developers Conference (OSDC), and Linux Conference Australia (LCA).

Steve Dalton's picture

Open Source Developers Conference - Day 1

Well it's that time of the year again, and one of the highlights of my year. Open Source Developers Conference Australia - this year just up the road in Brisbane.

The drive up from Gold Coast pretty slow. It's been a while since I drove up in peak hour. Train is much faster, but we needed the car to get the last few kms to Bardon.

The venue is right in the bush near Mt-Cootha.... nice spot. Bit far from the pubs and civilisation, but I am warming to it.

I set up an OSIA stand for the day - we didn't actually have a stand, but I put up some posters to give a bit of visibility. Gave away a lot of badges that CustomTees did for us - saw a few people wearing them or attached to their lanyards which was good. Everyone really liked my polo shirt I was wearing - so hopefully I am going to get some more made and give one to each member. Lots of people knew about OSIA, lot's didn't - a few people were very interesting in joining - and I have to live up to my promise of activity this year now! Watch this space.

The opening Keynote on Volunteers by Karen Pauley was really really interesting. I sat next to Paul O'Keeffe and had a lot to think about there in relation to Barcamp, Legion of Tech and the various groups we run. I found what she said about leaders so true - there are a lot of groups that rely on 1 person, if that person stops, then the group usually stops. We need to future-proof our groups so that they are sustainable... a lot of good things happening, but we need to keep them going.

Lee Butts's picture

Grails WebTest Plugin 1.2.0 Released

Update: latest version is now 1.2.3 containing some installer improvements and test generation bug fixes

The latest version of the Grails WebTest plugin is now available in the main repository. It is a major update to integrate better with the grails test-app hooks and is built using Grails 1.2-M2 (it is backwards compatible with 1.1+). As such there are some manual upgrade steps required (see release notes below). On the plus side, tests will now run as part of test-app and can also access domain classes and plugin code via the groovy step provided by WebTest

There are some trade-offs between using the old run-webtest script and the new test-app support which are outlined below. Hopefully subsequent releases can move all functionality over to the test-app script. Please raise any issues in JIRA against the webtest plugin component.

Lee Butts's picture

Grails Amazon S3 Plugin 0.6.5 Released

A new version of the Amazon S3 plugin is now available.

The new release contains changes to help the plugin play nicely in a clustered environment:

  • Quartz jobs are now non-volatile and durable to stop them being deleted/recreated when a node is stopped/started
  • S3Asset now contains a hostName property (and hence a new column that you will need to add to the DB) which holds the host name of the server that created the row. This allows the plugin job to only try and upload assets where the local file exists on the server that it is running on.
Lee Butts's picture

Sydney Groovy/Grails User Group

In between meeting all the interesting folk at OSDC, I attended the Sydney Groovy (and Grails) User Group. I presented a short talk on the new features in Grails 1.1 then demoed the Portlets Plugin and new features in the WebTest Plugin 0.6. Dave Cameron then gave a great Intro to Gant talk with comparisons to buildr. Come along next time to hear more from Dave about Gradle :)

The group is organsied by Nick Carrol from Thoughtworks and the venue (in The Rocks near Sydney harbour) was great. If you're ever in the area, get onto the mailing list and see when the next meeting is.

-- Lee

Syndicate content