Podkicker Pro: An Awesome Google Listen Replacement for Podcasts

With Google Listen hitting end of life, it’s time to hunt around for a decent alternative Podcasting app to replace it. I’ve had a look at a few, but found one that I really like, Podkicker Pro. If you’re in the market for a Podcasting app, it’s $3 well spent!

What’s to love? First of all, it will slurp in your existing Google Listen feed directly from Google Reader. Loving that already.

Secondly, it handles the “new episodes” problem as an integrated timeline. This is just awesome for me. I’ve always hated going into each channel to see the new episodes, I’d rather just see what’s new in the last few days and pick and choose what I want from there.

Links change colour based on whether they have been downloaded/played, so it gives you a really great quick view of what’s likely to interest you.

The third reason I really love it is that the “Car Mode” is perfect for my common use case (steering whell icon in the top right). I can put in on the in the car on the way to work and get quick access to progress, jump back and forward 30 seconds, all with a giant interface that you can’t miss.

 

On top of all that is offers the standard download feature (only download when on wifi, always download these eps, etc).

So there’s plenty to love. I’ve been giving it a workout over the last couple of weeks and I remain a massive fan. If you’ve after a lean and mean podcasting app that runs fast with an intuitive UI, this is the one to bet on!

[Read More]

Nexus Play Weirdness: Error retrieving information from server. [RPC: AEC:0]

My Nexus has recently started displaying weird errors when doing automated and manual updates. Whenever it tries to update an application I get a:

SomeApp could not be downloaded due to an error. (Error retrieving information from server. [RPC: AEC:0])

The recommendations around the web covered hardcore things like re-installing/sideloading play store apps and whatnot. I tried the standard reboot story, no joy. Clearing the Play store cache in /Settings/Apps/Google Play Store/Clear Cache

Turns out there is a great discussion of the problem on the XDA developer forums.

The easy solution to the problem was just to remove my google account from /Settings/Accounts & Sync/. Then re-add it straight back. And all is now well! Thanks XDA folk!

Just thought I would write it up so that I can Google myself if I run into the problem again.

Happy Androiding!

 

[Read More]

Grails In Action 2.0 - The Great Spock Update

Heaps of people have been tweeting me about the status of Grails In Action 2.0 - so it’s time to blog up a bit about how things are progressing.

How are things tracking?

We have about five chapters in bed so far (including a reworked Groovy introduction, a new chapter on Scaffolding, and the several of the original “intro” chapters from Part I and II of the book. Our current plan is to square off a few more chapters in Part II then set it free to the Manning MEAP programme.  We’re keen to get some good value in place before we unleash it on you all. Not being perfectionists, just making sure that when you get it it was worth the wait!

The good news is that Peter and I are presently sinking a good amount of time into writing and the pace of things is definitely picking up now! I would expect you’d see a MEAP sometime in August.

One of the things that has pleased me about the update process is that I”ve definitely improved as a Grails programmer in the last few years! There’s stuff in First Ed that was probably a bit hacky, and I’ll do my best to tidy that stuff up as I rework the chapters. I remember listening to a great keynote by David Heinemeier Hansson on “Legacy Code and Code Rot” - (can’t find the MP3 link, but it might be this one) and him saying that it’s not that your code rots, it’s that you’re a different person than when you wrote it! Great concept! I’m noticing it a lot in the update.

Some Spocktacular Updates

We’ve made the move to Spock for this version of the book - starting from Chapter 3 - and you’re gonna love it! Peter and I work in it exclusively now, and asking around twitter it seems a lot of working Grails devs have made the switch too. IMHO it makes our examples much clearer to the beginner too. Take our chapter 3 Listing 3.3 example explaining how to test property updates. Here’s the before and after (JUnit vs Spock):

void testSaveAndUpdate() {
    def user = new User(userId: 'joe', password: 'secret',
        homepage: 'http://www.grailsinaction.com')
    assertNotNull user.save()
    def foundUser = User.get(user.id)
    foundUser.password = 'sesame'                   
    foundUser.save()              
    def editedUser = User.get(user.id)
    assertEquals 'sesame', editedUser.password            
}

Which is replaced by:

    def "Updating a saved user changes its properties"() {

        given: "An existing user"
        def existingUser = new User(userId: 'joe', password: 'secret',
            homepage: 'http://www.grailsinaction.com').save(failOnError: true)

        when: "A property is changed"
        def foundUser = User.get(existingUser.id)    
        foundUser.password = 'sesame'                   
        foundUser.save()              

        then: "The change is reflected in the database"
        User.get(existingUser.id).password == 'sesame'

    }
[Read More]

Seriously Offline Grails: Going Totally Sans-Internet with Nexus

It’s one thing to be hacking on your Grails project when you’re offline on a plane/train/public transport. You have grails -offline for that challenge. It’s another thing when you journey into a client that has no internet access. That’s a new level of challenge.

It might be that your client is on an air-gapped Network (for tender evaluation, security, etc), or it might be that the internet access is blocked for maven central, grails central, or some other key artifact site (don’t laugh… I could tell you stories about one particular client who’s stateful-inspecting proxy modified jar files as they were download and inserted its own .class files to catch any Main-Class META-INF entries. Eeek!).

Step 1: How To Catch and Cache Those Dependencies

If you’re writing a Grails app, you’ll want to use plugins. But with Grails plugin dependencies management, getting the plugin’s zip file is only half the story. You’ll also need those artifacts that the plugin itself needs to pull down. You could muck around with your ~/.grails and ~/.ivy directories until the cows come home, but still end up with something that doesn’t work once you setup your CI server inside the client site, or worse.

What you’re really after is an Artifact proxy. Some kind of service that you can point Grails at and get it to push all its jar and plugin requests through. That way, you can point your CI build, and all your other dev workstations to one box and get everything slurped down just as it should be.

There are two popular options for such beasts: Artifactory and Nexus. Grails folk seem to have adopted Artifactory as their preferred repo manager. I’ve never really understood why (perhaps you could enlighten me in the comments?).  I have always preferred Nexus myself, since it stores all the artifacts on the filesystem in the native Maven repo format (which makes them easy to navigate and copy), and I’ve found the UI more approachable (of course, as in all things personal prefs, YMMV).

Step 2: Installing Nexus and Getting It Configured for Plugins

After you’ve installed Nexus, you’ll want to setup a new Proxy Repo that points to http://plugins.grails.org/ and  also a Spring Framework Repo that point to their Enterprise Repo (screenshot of the plugins.grails.org setup below, rinse and repeat for the Enterprise Repo URL).

 

[Read More]

HipWall: HipChat for Plasma-sized team walls

This Friday, our little team is getting together for a “Learn Android” Hackathon. As it turns out, we’ve also recently had a spin evaluating HipChat. You can see the synergies developing right?

So, given that HipChat has a rockin REST API, I thought I’d put together a little bit of JavaScript that ties up all the loose ends and gives me a nice mile-high display for displaying HipChat messages on the team plasma. And thus HipWall is born!

In the pic about I’ve connecting the HDMI port on an Acer A501 Android Tablet to display my little HipWall page on the big screen.

Useful Tools for RESTful Tinkering

I’ve been looking for a good Chrome plugin to test out RESTful services and I’ve found one that I love - Postman REST. This little tool lets you easily plugin in URL params and headers, and looks after pretty printing and history management to boot. Really sweet. Saved me a ton of time tinkering with the HipChat API.

 

Mocking out those AJAX calls

I’ve been getting into QUnit for my JavaScript unit testing, and I’m having a ball. One thing I’ve never explored, however, was mocking out RESTful services. Enter MockJax - an awesome jQuery plugin for handling mocking of RESTful calls (good tutorial here).

[Read More]

Net Disconnect: Taking your Dev machine offline for productivity

After recently reading “The Shallows: What the Internet is doing to our brains“, I’ve been a bit provoked about how much time I waste online when getting things done. Chasing hyperlinks to all kinds of content, checking twitter, get distracted by mail. Major context switching!

So I’m experimenting with a new workflow where I disable the network card on my PC , and just come online every few hours to clear the mailbox.  It’s been quite a liberating experience so far.

Tooling Up

Initially I had a good surf around for tools that might fit the bill to help with my new disconnected life. There’s some nice Windows tools like Cold Turkey to keep you off social networking sites, and Freedom to keep you off the web altogether, but I was really just after something lightweight to turn off my Windows 7 network card!

Scripting a Win

Turns out that the easiest way is to script up the netsh.exe tool that comes with Windows. With this bad boy, nicely discussed on this blog, I was up and running with a quick “online.bat” and “offline.bat” and was living the disconnected life. That magic shell command you need to disable your adaptor is:

netsh interface set interface "Local Area Connection" DISABLED

And of course, you’re back online with:

netsh interface set interface "Local Area Connection" ENABLED

Looking forward to reporting on my productivity wins with this new less-connected life!

[Read More]

Making Grails Apps Native in a Microsoft Environment

It’s a little-known fact that I’m a part-owner of one of the most uncool Grails startups in the known world. We don’t have Webscale issues, we don’t have staff beanbags,  in fact we don’t even offer a cloud-based solution. We install Grails-based software on hosts inside corporate environments. We do compliance software. Like Health and Safety and IT Security stuff. Nerdy in the extreme. But also very fun to work on, and, shock-horror, a sustainable business from year one!

Lots of our customers are “Microsoft Shops” from soup to nuts - SQL Server, Active Directory, Internet Explorer - you know the drill. So we’ve been working hard to make our Grails-based offering run just lovely alongside existing Enterprise apps.

Grails and SQL Server

First things first, we’ll need a SQL Server JDBC driver so we can play nice with common SQL Server versions (viz. 2005/2008R2). We evaluated a couple of Microsoft SQL Drivers including: the Microsoft One, and the jTDS one. Both worked fine, but we ended up going with the jTDS one since it seemed faster in our smoke testing. And it was in a Maven repo.

jTDS DataSource Configuration

We experimented for this for for quite some time to get everything just so, so I’d thought I’d take some notes for you to to lean on. First of all, if you’re going dataSource config, you’ll want something like this:

dataSource {
    pooled = true
    dialect = org.hibernate.dialect.SQLServer2008Dialect
    driverClassName = "net.sourceforge.jtds.jdbcx.JtdsDataSource"
    url = "jdbc:jtds:sqlserver://yourhost:1433/GMARC;useNTLMv2=true;domain=yourDomain"
    dbCreate = "none"
}

There are some excellent docs on the URL Formats for jTDS but I found the useNTLMv2 switch was essential in the client’s environment. Apparently v1 (the default) is full of security holes, and there are standard NT group policies that disable NTLMv1 entirely. I also found that the domain switch needed to be provided otherwise we were hosed.

Going Managed

If you’re walking the Tomcat-managed DataSource, you’ll need to use the matching context.xml version of the above:

[Read More]

Some Personal Tech Goals for 2012

Building on last year’s effort, I’ve been spending some time with the Pragmatic Thinking and Learning book to start thinking about my knowledge portfolio for the year ahead. I’m still not entirely clear on the fine print, but there are some themes that are really starting to run in my thinking, so I figure I should get accountable and blog it up.

Here’s my stab at the tech areas I’m interested in getting across in 2012:

  • Grails 2.0 Deep Dive. Grails In Action has a completed TOC and a slated release schedule for 2nd Edition. So I guess most of the hard work is already done :-) No doubt there will be many adventures posted here in the days to come.

  • GUI Applications. I know everyone is giddy with mobile at the moment and I spent plenty of time building mobile apps for every possible device on a project last year. This year I’ve ended up with a couple of major Swing gigs on the timeline, so this is a great chance to catch up on Frankenstein GUI skills (for all platforms, not just Swing). Native Android might be a good experiment area here too. And Griffon goes without saying. It’s much harder when you don’t have a “Twitter Bootstrap” for Native GUIs!

  • Integration Testing. I’ve flirted with Geb after Luke’s sessions at 2GX, and I’m also keen to explore more native Web-centric tools (like FuncUnit) to explore what kinds of tools are productive for me.  I went live with my first major piece of Grails Commercial Software late last year, but my biggest snags have been browser-specific issues! I’m hoping some functional testing will help.

  • JBoss. Ok this one is definitely a little left of centre. But I live in a (mostly) Websphere town and I’m really tired of dealing with the insanity and wastefulness of that platform. I’d really love to have a full-stack alternative (SOA is big in Canberra) that I could offer clients as a migration strategy. I think JBoss is worth exploring here for that reason alone.

  • MongoDB. Of all the NoSQL options, Mongo looks the most interesting to me. I own a couple of books, and the Grails support for NoSQL is pretty rocking right now. I think the trickiest part here is actually getting a feel for NoSQL Schema design in document stores. It’s not like there’s an easy “Third Normal Form“ type refactoring to apply.

    And the softer non-software stuff?
  • Training Skills. A lot of the ideas in Pragmatic Thinking and Learning apply specifically to how to train and mentor people. I really want to experiment with this over the course of the year by running some experimental training sessions and see how people cope with alternate presentation/learning courseware. Should have a good impact on the book too!

  • Leadership. I’m now serving on the leadership board of several for-profit and non-for-profit organisations. I bring plenty of technical horsepower, but don’t really contribute much in vision casting, strategic planning and people development. All my non-tech reading this year is going to be along the lines of “developing people” but in a Glen-kinda-way rather than just a John-Maxwell-regurgitate kinda way. Honestly there is so much junk written about leadership that is passed on unprocessed…But that’s for another <rant/>

  • Minimalism. I’ve actually been applying a bunch of the ideas from “The Joy of Less“ that I’ve found really helpful in building a much more conducive living and working space. Think of it as “Eliminate Waste” but applied to your whole life rather than just your code! Lots to learn here, and lots of habits to unlearn to.
    Well that should keep me busy for a while…. At least for 2012…

&nbsp;

[Read More]

Reviewing Personal Tech Goals for 2011

I went through a tech goal-setting process last year, and found it pretty help, so I’m lining up for another Tech Goals plan in 2012. I commend the process to you!

First let’s review last year’s list:

  • JavaScript - Yup! I can certainly tick this one off. Did several pieces of hardcore JavaScript work for clients (some without framework support), learned enough QUnit to be dangerous, and even did a bit of Backbone.js.
  • Android/HTML5/CSS3 - Check. I’m bundling these together since I ended up doing a major PhoneGap project for a client this year. Had a chance to building a HTML5/CSS3 app for them on iPhone/iPad/Android/Blackberry/WinPhone7. If nothing else, I’m now pretty solid on CSS3 media queries and device toolkits!
  • Grails Testing - Check (but lots more work to do). Spent a lot more time writing Spock tests this year and I’m definitely further along the road towards productivity here. Actually, the most useful TDD resource I came across this year was the PragProg screencasts of Kent Beck doing TDD. So practical and non-preachy. Really great. Went ahead and read the original TDD book and found that helpful too!
  • Graphic Design. Well. I’ve discovered that I’m fighting city hall on this one. I’ve put too much energy into this for very little result. What I did discover this year was that I can happily customise templates to my cause (Twitter Bootstrap, anyone?) and it’s more productive to outsource the rest!
    Also had  chance to do several Grails talks this year including a Grails Code Camp in New Zealand, SpringOne2GX in Chicago, and GR8Conf/OSDC in Canberra.

So what’s on the agenda for 2012? That’s the topic for the next post…

[Read More]

Grails, PhoneGap and Fun @ OSDC2011

I’ve had a great couple of days at OSDC 2011! Tuesday I was hanging out at the First Ever Australian GR8 Conference, spent Tuesday night with the CJUG boys, then have been presenting today on PhoneGap to the broader OSDC conference. Great times!

Interesting this is definitely one of the hardest core developer communities I have hung out with. Hardly any Macbooks/iPhones in sight and Linux laptops and Android phones everywhere! People are really committed to the Open Source way here.

The First Ever GR8 Conf in .au

It was great to hang out with a bunch of the awesome team from the local Groovy and Grails community. I gave a shortened version of my SpringOne talk on Grails UI refactors. The slides are up on SlideShare if you missed it:

Does my DIV look big in this?

View more [presentations](http://www.slideshare.net/) from [glen_a_smith](http://www.slideshare.net/glen_a_smith)
After a fantastic day of talks from a bunch of great speakers, we had a  chance to kick back with Paul King, Steve Dalton, Craig Aspinall, Peter McNeil, Dean Macaulay, Paul Kilpatrick, James Swann and a bunch of CJUGers at the local watering hole.

Hacking PhoneGap for Fun and Profit

Earlier today I had great fun presenting to an enthusiastic crowd of mobile developers on the joy of PhoneGap. Again, the slides are on SlideShare.

**[Fake Your Way as a Mobile Developer Rockstar with PhoneGap](http://www.slideshare.net/glen_a_smith/fake-your-way-as-a-mobile-developer-rockstar-with-phonegap-10179146 "Fake Your Way as a Mobile Developer Rockstar with PhoneGap")**
View more [presentations](http://www.slideshare.net/) from [glen_a_smith](http://www.slideshare.net/glen_a_smith)
One of the great facilities they had at the conference centre was an old-school data projector. We put it to good use showing off the deployment of [our little conference app](http://blogs.bytecode.com.au/glen/2011/11/08/osdc2011-phonegap-and-google-spreadsheet-hacking.html) to my actual Android phone. Ever though a few of the demos snagged, it was all part of the fun of deploying to real devices!

   

[Read More]

OSDC2011, PhoneGap and Google Spreadsheet Hacking

I’m really looking forward to hanging out with the crew at osdc2011 next week in Canberra, and have been busy working on my sample code for my talks.

I’ll be giving a talk titled, “Fake Your Way as a Mobile Developer Rockstar with PhoneGap“ where I’ll be talking a little about a recent client project I was working on developing for iPhone,iPad,Android (phone + tablet), Blackberry, Playbook and WinPhone7. It was a true “write once, test everywhere” experience!

Anyways, to show off a few of the key ideas, I spent a few hours yesterday morning whipping up a “Conference Schedule” app. The conf organisers kindly flicked me a schedule spreadsheet to use for the demo, which I prompted published as a Google Spreadsheet. All the data for the app is sourced from there, so Google Spreadsheets becomes my CMS for Schedule changes!

   

This session is going to be all about “faking it”, so while my graphic design skills are pretty rubbish, the amount you can get done using jQueryMobile, jQuery, Handlebars.js, PhoneGap and a few JavaScript libraries in a few hours is pretty sensational.

To do all the Google Spreadsheet parsing, I’m using a nice little library called Google-Spreadsheet-Javascript which has been perfect for the purpose of turning a spreadsheet into JSON! Based on the samples that come with the library (try one here), pulling data from a published spreadsheet is as simple as:

      var osdc_url = "https://spreadsheets.google.com/pub?key=0AsIKXTGzbbNtdDYwZGF3NGtFeVZCRGJDTzhLLTI1YWc&hl=en&output=html";
      var googleSpreadsheet = new GoogleSpreadsheet();
      googleSpreadsheet.url(osdc_url);
      googleSpreadsheet.load(function(result) {
          alert("Remote OSDC Schedule Sync'd");
          osdcData = result;
      });

The trickiest part was finding the “Publish to Web” option in the Google Spreadsheet itself (which is buried under the File menu rather than the normal Share menu). Now if only I can get Google Spreadsheets to present the dates in the right order I’ll be ready to roll…

See you there next week! (Oh, and all the source code for the app is up on Github).

&nbsp;

[Read More]

SpringOne2GX 2011 was one Groovy Show!

What a fantastic time we all had at SpringOne 2GX in Chicago over the last week. My head is jam packed full of information and I have so many new things to add to my list of cool Groovy tech to explore! If you’ve never made it to one (this was my first), I can highly recommend it!

First things First: Relationships trump everything

The absolute best part of these events is the chance to hang out with our awesome Groovy community making new friends and catching up with old ones. Just have a scan of the Wed night Groovy and Grails BOF (click picture for a closeup) to get a feel for how fantastic our community is (somewhere in this picture are heaps of the names you’ve run across Scott Davis, Graeme Rocher, Burt Beckwith, Guillaume Laforge, Dierk Koenig, Paul King, Colin Harringon, Bobby Warner, Dave Klein, Jim Shingler and many more). The audio will be up on grailspodcast.com shortly.

&nbsp;

Friends Old and New

There’s nothing better than catching up with old friends from the Grails community: Andres, Dierk, Scott, Graeme, Jeff, James, Paul, Peter, Luke, Dave & Ken. And it was doubly wonderful to make a whole bunch new friends: Colin Harrington (Grails Testing Guru), Tim Berglund (of the Tim & Matt Git Video fame), Peter Niederwieser (Spock author), Andy Clement (STS Grails IDE support and Agent Reloading) and Jim Shingler (thanks for the insights on Grails in the large!).

And then there is seeing all the great guys from the community including Bob Rullo, Bryan, Jeff Gortatowsky, and too many others to name. So great to see you all!

Grails In Action, 2nd Edition

[Read More]

DRYer Grails views? Learn less.css, backbone.js, twitter bootstrap and more @ 2GX

I’m just putting the final demo together for one of my sessions at SpringOne 2GX called “Does my DIV look big in this?“ This talk brings together a whole bunch of technologies that I’ve been experimenting with for a while that help keep your view tier DRYer, namely:

  • Grails Resources (for shrinking your dependencies)
  • Various Grails and non-Grails DRY view technologies (including bean-fields, navigation, validation and other jQuery related goodness)
  • Less.css for keeping your CSS nice and DRY
  • Twitter Bootstrap (for gridding and standardised layouts)
  • Backbone.js for giving some rigor to my JavaScript views (and painless REST sync)
    If any of those technologies are on your radar, make sure you come along! I’m really keen to hear your views on what has worked for you and how we can move towards more low friction Grails views.

We’ll be taking a noisy and loveless default UI:

[![](http://blogs.bytecode.com.au/glen/wp-content/uploads/2011/10/seefooddiet_before.gif "See Food Diet Before Makeover")](http://blogs.bytecode.com.au/glen/wp-content/uploads/2011/10/seefooddiet_before.gif)
And giving it a solid makeover for markup, layout and behaviour:
[![](http://blogs.bytecode.com.au/glen/wp-content/uploads/2011/10/seefooddiet_after.gif "See Food Diet After Makeover")](http://blogs.bytecode.com.au/glen/wp-content/uploads/2011/10/seefooddiet_after.gif)
It's gonna be a blast! See you in Chicago!
[Read More]

Patching bean-fields on 2.0.0.M2

If you’re having troubles with the Bean-Fields plugin on Grails 2.0.0.M2, there’s a quick workaround to get up and running. So if you see something like…

Caused by GrailsTagException: Error executing tag <bean:form>: Cannot get property 'class' on null object

You know you’ve tripped the issue.

I’ve logged the issue in GPBEANFIELDS-40 but the root cause is actually not beanfields at all. It’s a breaking change introduced in Grails 2.0.0-M2 for performance improvements (GRAILS-8001). The change has since been made backward compatible for RC1, so the break only occurs on 2.0.0-M2.

Line 922 of BeanFieldsTagLib needs a mod… Comment it out and replace with the mod below

//attrs._BEAN.bean = attrs.remove('bean') ?: pageScope.variables[attrs._BEAN.beanName]
attrs._BEAN.bean = attrs.remove('bean') ?: pageScope.getVariable(attrs._BEAN.beanName)

And you’re in business!

Remember, this ONLY applies to 2.0.0-M2, all will be well in RC1!

Enjoy those DRY forms… And go buy Marc Palmer a nice wine next time you’re in the UK. I plan on it.

&nbsp;

[Read More]

Grails Hacker Triage: When Bad Code happens to Good Developers

We’ve all been there. Maybe you were in a rush to get your latest Grails app out the door, or maybe it was a hobby project you were doing in your spare time and things just got out of hand. Hack code, click refresh, hack code, click refresh, (pause to complain about why Grails needs a restart), hack code, click refresh. You know the drill. Refresh-driven development (RDD).

Either way you find yourself with a steaming pile of Grails application, and you dread updating the thing because of the carefully crafted house of cards that it’s become.

I know you wouldn’t do that. But I would. In a heartbeat. But I’m repenting. And changing. I hope.

I’m starting a blog series cataloguing the biggest and shamless Grails hacks that have slowed me down, and I’d like you to join in the conversation. The end result is going to be a talk at SpringOne 2GX in October called Grails Hacker Triage, where we’ll talk about some strategies for treating these shameless hacks.

So, over the next few weeks, I’m hoping to write about my personal “Top 5 Hacks of Shame”:

  1. The Fat Controller: who needs any other artefact when you have this Golden Hammer! Use implicit transactions, generate markup, do querying. What can’t it do when you get creative?
  2. The Skinny Model:  You wouldn’t want to clutter up your domain classes with domain logic right?
  3. The Nosey Magic Service:  it turns an untyped params object into all kinds of business magic, and has Dr Phil-style  co-dependency problems.
  4. The TagLib that ate Tokyo:  it lives and breathes embedded html with a rich tapestry of business logic for good measure. And does a little querying to stay holistic.
  5. The 100KLOC view:  With so many logic taglibs built into Grails, why not use them all? And let’s get polyglot by embedding a bunch of JavaScript and CSS FTW.
    I suspect I have good examples of all of these pattern in my personal Grails app archive, so I’m off to do some painful researching and personal contemplation.

Look forward to your input on some great personal hacks and remediations along the way!

[Read More]

Grails Code Camp: Wellington - where Yaks were kept hairy (mostly)

I’m just back from a fantastic time in Wellington, New Zealand, where I was doing some Grails training and speaking duties for Asia/Pacific User Group of SunGardHE. Wellington is a very beautiful place (albeit a little cold - and I live in a cold place!) and the local hosting team of Andrew/Dale/Keiryn where just fantastic in sorting everything out!

On the first day I had a chance to speak with around 100 managers on the benefits of Grails (it was quite a challenge putting together a Grails talk targetted to a non-technical audience!). We covered off three big ideas:

  1. What is Grails?
  2. Why do people choose Grails? (and who has already moved there)
  3. How do I transition my team to Grails? (in their case, from Oracle PL/SQL)
    Then I couldn’t resist doing a small Grails demo where we built a conference registration app with evolving requirements, then skinned it with the APSUG logo and colours. Even though the crowd was largely non-technical, they were right into the live coding demo! That was a real eye opener. I think people really enjoy things being created before their eyes (whether that’s live painting or live coding!).

The other thing they really resonated with was the whole concept of Yak Shaving. For a lot of them, they relate the whole idea of convention-over-configuration to a reduction in Yak Shaving - something which had a clear mental model for them!

yak shaving

The second day we ran a code camp for around 10 of the university developers from the conference. SunGard had put together some great training materials to work through, which I couldn’t resist tweaking a little for the local crowd!

One of the coolest parts of the day was when Bob Rullo from SunGardHE in the States skyped in and took the students through the actual SunGardHE source code for the commercial Grails app they’ll be customising for their own universities. The students were so jazzed to see the same type of Grails Domain Classes and Services that they’d be tinkering with during the camp.

Big thank you to all the folk who brought me over (particularly Victoria University of Wellington), and the great students in the code camp who had to do a little Yak Shaving around the “perfect storm” of Grails 1.3.7, Java 7 and Gemfire! We even prototyped a “grails yak-shave” command to keep us focussed!

Oh. And if you even get to Wellington, make sure you head over to Wellington Zoo to catch the Kiwi Hut and the extremely cute brown kiwis. Those Kiwis are a really awesome and distinctive native animal!

Oh. And I also had a great time catching up with NZ Grails champs @pragmaticgeek @wakaleo @nigel_charman. Looks like we might get a few of the NZ boys over for the GR8 conf that looks like happening in Canberra on Nov 14. Can’t wait!

[Read More]

Grails 1.3.7 and the dreaded SAXParseException

I’ve run into this one a few times on Grails 1.3.x, and every time I have to go googling to sort it out - it’s time to write it down to speed up my Google searches!

The error I end up with is typically something like:

java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name “org/xml/sax/SAXParseException”

If you get this on a project after installing a new Grails plugin, this is probably some xml-api clash that the plugin has introduced. The workaround is nicely documented here. Just a matter of excluding xml-api in your BuildConfig and you’re away.

But what if you get this error when running a “grails create-app”? It’s too early to exclude anything - you haven’t even created the project!

To save you reinstalling your JDK/Grails/Groovy distros, it’s time to just blow away your IVY cache - (%USERPROFILE%/.ivy2/cache on Windows) and move on with your life! There’s a nice discussion on the Grails list about tracking down the offending jars using the JAVA_OPS=-verbose option and seeing exactly what is loading those XML classes!

Just wanted to write this down so I can find it later.

[Read More]

Using the Groovy and Grails Textmate bundles on Windows

I mostly use IntelliJ for all my Grails dev work, but every now and then I end up doing some quick work with  the Groovy and Grails TextMate bundles on Windows. The e text editor for Windows can read Textmate bundles, so I can enjoy all the handle snippets and colouring that the bundles provide.

The recent copies of the bundles hit a snag on Windows, however, since they use Windows reserved filename characters like <g:>. You can’t git clone the bundles because of the filename, but you can download the zip from github and mangle the filenames later to make them windows-friendly. WinZip will tell you it’s a malformed zip, though 7zip does the right thing and will let you inspect and rename each dodgy filename. But there are dozens and dozens of them! There must be a better way!

In order to fix it up, I whipped up a little script that reads in the zip, fixes all the filesname, then writes out an win-friendly zip that you can use in for you e bundle. Here’s the magic for your groovyConsole-ing:

import java.util.zip.*

String infile = "/temp/textmate-groovy-grails.tmbundle.zip"
String outfile = "/temp/textmate-groovy-grails.tmbundle.win32.zip"

ZipInputStream inzip = new ZipInputStream(new FileInputStream(infile))
ZipOutputStream outzip = new ZipOutputStream(new FileOutputStream(outfile))

ZipEntry nextFile

while(nextFile = inzip.getNextEntry()) { 

    def winFriendlyName = nextFile.name.replaceAll(/[:<>"]/, "_")
    println "${nextFile.name} -> ${winFriendlyName}"
    outzip.putNextEntry(new ZipEntry(winFriendlyName))
    int nextByte
    while ((nextByte = inzip.read()) != -1) {
        outzip.write(nextByte);
    }
    outzip.flush()
    outzip.closeEntry()

}
outzip.flush()
outzip.close()

&nbsp;

I should be using Buffered versions of all those streams for performance, but the files are so tiny I couldn’t handle doing any more battle with the java.io.zip javadocs.

Once you have the new zip file, unzip it into %APPDATA%\e\Bundles and make sure the directory ends in .tmbundle (rather than the tmbundle.abdeadbeef git signature you’ll get) otherwise e will not load the bundle.

Happy Bundling!

&nbsp;

UPDATE: You don’t need all of the above pain! You can just download the latest Win-friendly-named version from this mirror on github.

[Read More]

Yes I can locate a GORM API implementation!

I’ve been having the weirdest issue with Grails 2.0M1 (nee 1.4M1). My application ran fine with “grails run-app”, but would fail when did a “grails tomcat deploy” and deployed to either Tomcat 6 or Tomcat 7. The error I was getting was…

ERROR  initWebApplicationContext, Context initialization failed
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; 
nested exception is java.lang.IllegalStateException: 
Cannot locate GORM API implementation. You either don't have a GORM implementation installed (such as the Hibernate plugin) 
or you are running Grails code outside the context of a Grails application.

Opening up the .war file, I could tell the hibernate plugin wasn’t being included, and having a look at /WEB-INF/grails.xml there was no trace of the line that I was expecting:

<plugin>HibernateGrailsPlugin</plugin>

So… who stripped away my HibernateGrailsPlugin?!?

After much mucking about, I found the source of the problem. It was deep inside  _GrailsWar.groovy. Somewhere around line 209 it filters out plugins based on their dependency tree (to make sure unnecessary testing/runtime plugins don’t live on inside your war). In particular, something in the Hibernate 1.4.0M1 plugin’s dependency graph results in the dependency.isSupportInConfiguration(it) returning “false”, and it getting stripped from the war file.

So it looks like the problem is inside the dependency tree for the Hibernate 1.4.0M1 plugin. A temporary workaround is to hack in a special case inside _GrailsWar.groovy until things are fixed up (insert the second line from the extract below below somewhere around line 209-ish of _GrailsWar.groovy)

def i = configs.any { descriptor.isSupportedInConfiguration(it) }
if (false == i && info.name == "hibernate") i = true
i != null ? i : true

Rerun “grails war” and you’ll see that the hibernate plugin gets package and your grails.xml file reflects that it’s a starter.

I’ll create up a JIRA for this on Monday when I’m back online since I’d like to include the exact steps to replicate since this only seems to affect a few people (if that’s you, I guess you’re just lucky!).

[Read More]

Eliminating annoying flicker transitions with jQuery Mobile on Android

I’ve been using PhoneGap along with jQuery Mobile to do some protoyping work for a client on a range of mobile devices.  When testing on Android 2.2 (HTC Desire in my case), I noticed a nasty flicker on the CSS swipe transition. Seems others have seen this too. On my device it seems to occur once at the start of the transition, and once at the end.

Anyways, after much googling, the stackoverflow magic that fixes it seems to be to do with the -webkit-backface-visibility tag. After I added the magic CSS to my jQuery Mobile page tags life was flicker-free again. Here’s the magic sauce I had to add to my CSS when using PhoneGap 0.9.6 and jQuery Mobile 1.0 beta 1:

.ui-page {
    -webkit-backface-visibility: hidden;
}

And say goodnight to the dreaded Android flicker!

[Read More]

Using Grails links from JavaScript: a micropattern

You want to include a link to one of your Grails actions (say an AJAX target link) in one of your JavaScript files. What to do?

Well you could just inline your JavaScript in your GSP file, right? Then you can just access all the GSP tags you like and the problem just goes away, right?

<r:script>
console.log("Now hacking on ${assessment.id}");
$.ajax({
       type: 'GET',
       url: "${g.createLink(action: 'addThreat')}",
       data: { assessmentId : "${assessment.id}" },
       /* more JS magic here */
});
</r:script>

Well, yes, but then you have other problems (like wanting to take advantage of JavaScript compression and caching, and not to mention the general mental clutter of having all this magic happening in the same file).

I’m not sure how other people handle this situation, but I figure I’d document one pattern for tackling this problem in case you find yourself running up against it.

In my scenario, I have a workspace.gsp file for all the Grails-ey stuff and a workspace.js file which hosts all my jQuery code.

1. Use a JS Hash in your GSP file to save what matters

The general pattern I use is to create a namespaced JavaScript object in my GSP file which hosts all the links that I want to consume. This part I actually do inline, but there’s not a lot that could be compressed/cached, so I don’t stress about it. So my workspace.gsp file looks like this:

.. Normal GSP stuff here ..  

<!-- We inline the values (ids, action links, resource links) we want to use in our JS file -->
<r:script>

var GMARC = {
    assessmentId : '${assessment.id}',
    threatUrl: '${g.createLink(action: "getThreats")}',
    addThreatUrl: '${g.createLink(action: "addThreat")}',
    categoryIcon: '${g.resource(dir: 'images/icons', file: 'folder.png')}',
    assetIcon: '${g.resource(dir: 'images/icons', file: 'television.png')}'

  }

</r:script>
<!-- Next we pull in our JS file, and can reference GMARC.assessmentId, GMARC.assetIcon, etc -->
<g:javascript src="workspace.js"/>

2. Consume that JS hash in your JavaScript file to get what you need

[Read More]

Getting Windows 7 to recognise your OCZ Agility SSD

I’ve just installed a brand new OCZ Agility 3 Solid State Drive (SSD) into my ASUS UL80JT ASUS Laptop. The BIOS saw the drive immediately, so I figured I was in the clear.

Sadly Windows 7 said it couldn’t find any devices to install on! Yikes!

I discovered in this thread that other people have faced this problem too, and they had worked out some fixes.

And (for me at least), there was a very easy solution.

  1. From the Windows DVD Boot, head off into the recovery mode
  2. Start a Windows Command Prompt
  3. Run “diskpart”
  4. Type “list disk” and confirm that you can see your SSD
  5. Type “select disk 0” to select your SSD (or whatever number it is)
  6. Type “clean”
  7. Exit diskpart and reboot your computer!
    With those steps in place, Windows 7 could find my SSD and I’m enjoying that amazing speedup that SSDs have brought to my world!

&nbsp;

[Read More]

Getting Controller Reloading Happening on Win7 with Grails 1.4M1

I’ve been totally loving the Grails 1.4M1 experience. In particular, the unit testing support has been a God-send. The one pain point for me has been class reloading has been broken on Windows 7 (I know, I know, spare your jests).

Anyways, Burt has posted an updated startGrails.bat that gets controller loading happening again! Awesome!

If you’re backporting to M1, you’ll need to change the references in the posted script from “BUILD-SNAPSHOT” to “M1”, or just grab an updated script off my dropbox. It still throws a few errors in the Agent reload, but at least the reloading is now working! Giddy up!

Thanks for posting, Burt!

[Read More]

Hacking Grails Scripts with run-script

I’ve been using Wordpress for some client integration jobs recently and have really fallen in love with the easy of use and extensive plugins that Wordpress brings to the content management space.

So I’ve taken the bold move of moving all my data out of Gravl, my long-dead Grails based blogging system, and onto Wordpress. The only problem was getting the data out!

First though: write a little user script and get Grails to run it. The only caveat is that I’ve mucked around with Grails scripting system before, but often ended up fighting a lot harder than I needed to make all the right events have fired to ensure everything was sparked up.

Enter Ted Nalied’s little “grails run-script“ command! It’s even bundled with Grails 1.3.6+, so there’s no excuse to not love it completely! (I even grabbed the source and dropped it into my Grails 1.2.3 app so I didn’t have to worry about upgrading).

This little bad boy lets you write user scripts that are run once the entire Grails system is up and running (think: copy and paste from “grails console” and save yourself a script you can use over and over).

grails run-script exportcsv.groovy

And say goodbye to nasty Gant hacks to get all the dependencies right! The contents of exportcsv.groovy are executed with a full Grails stack in play, so just go ahead and call stuff:

List be = BlogEntry.findAllWhere(status: "published")
be.each { entry ->
    List line = []
    line << entry.title
    line << entry.body
    line << (entry.tags*.name).join(",") // normal GORM relationships are fine
    line << entry.title.encodeAsNiceTitle() // codecs work too!
    // tons of other "go crazy" export code here
}

Add a little opencsv to the mix, and install the Wordpress CSV import plugin, and you have yourself 281 posts, and 781 comments all nicely imported.

Fantastic stuff. I’m going to make good use of this on my next project following Ted’s little idea of prototyping in Grails Console, then saving away the script for later.

[Read More]