Archive for December, 2012

This Week in Grails (2012-51)

Thursday, December 27th, 2012

There were a few Groovy and Grails releases this week. Grails 2.2 was released and there are many new features but the big one is that it uses Groovy 2.0. Grails 2.1.3 was also released and includes fixes for the 2.1.x line.

Groovy 2.0.6 was released with several fixes and improvements, and the first beta of Groovy 2.1 was released. It looks like 2.1 will have some very interesting new features.

Also, GPars 1.0 was released this week.

There were a few writeups about the Groovy & Grails Exchange last week:

and a few more interesting tweets:

I forgot to mention when discussing GGX last week that Yu Sudo took some great photos during the conference. While the rest of us were using our cell phones to take mediocre shots (and often making them worse with Instagram filters) he was using a real camera. I didn’t know people still used real cameras 🙂 Check out his stuff on Flickr.

I updated my old Spring MVC plugin this week and wrote up why you would use it here. I also released a new plugin that adds support for Logback.

If you want to keep up with these “This Week in Grails” posts you can access them directly via their category link or in an RSS reader with the feed for just these posts.

Translations of this post:


There were 4 new plugins released:

  • crash version 1.2.0-cr3-p1. Integrates the Common Reusable SHell (CRaSH – )
  • logback version 0.1.1. Replaces Log4j with Logback for logging
  • miniprofiler version 0.1. Shows timing and SQL query information in a head-up display in a web page; useful for debugging database and other performance problems
  • grails-remote-methods version 0.2. Allow controller methods to call from JS without any code

and 15 updated plugins:

  • aws-sdk version 1.3.26. Use the Amazon Web Services infrastructure services
  • codenarc version 0.18. Static code analysis for Groovy
  • cucumber version 0.7.0. Test your Grails apps with Cucumber
  • facebook-sdk version 0.4.7. Allows your application to use the Facebook Platform and develop Facebook apps on or on web sites (with Facebook Connect)
  • jasper-response version 1.0.1. Render JasperReports as PDF or HTML
  • kickstart-with-bootstrap version 0.8.9. Start your project with a good looking frontend, with adapted scaffolding templates for standard CRUD pages using Twitter Bootstrap
  • mongodb version 1.1.0.GA. Aims to provide an object-mapping layer on top of MongoDB
  • oauth version 2.2.1. Provides easy interaction with OAuth service providers
  • quartz version 1.0-RC3. Schedules jobs to be executed with a specified interval or cron expression using the Quartz Enterprise Job Scheduler
  • sendgrid version 1.1. Allows the sending of Email via SendGrid’s services
  • spring-security-facebook version 0.10.2. Plugin for Facebook Authentication, as extension to Grails Spring Security Core plugin
  • spring-security-twitter version 0.4.4. Twitter authentication as extension to the Spring Security Core plugin
  • springmvc version 0.2. Enables the use of Spring MVC controllers
  • vaadin version 1.7.0-beta11. Adds Vaadin ( integration
  • zkui version Seamlessly integrates ZK with Grails’ infrastructures; uses the Grails’ infrastructures such as GSP, controllers rather than zk’s zul as in ZKGrails plugin

Interesting Tweets

User groups and Conferences

This Week in Grails (2012-50)

Wednesday, December 19th, 2012

The big news of this week was the 2012 Groovy & Grails Exchange in London. Lots of great content this year, and attendance was up 40% from last year. It’s always a great conference thanks to the fine folks at Skills Matter who run the conference and many other events throughout the year. They’re great about getting videos of the talks online quickly and you can check them out at the conference schedule – click through each talk to the full description. There was a lot of Twitter activity – search on the #ggx hashtag. Here are several of the more interesting ones, including several links to presentations and sample code:

In addition, Grails 2.1.2 was released with some fixes for the 2.1.x line (note that the distribution is now ~120MB since it includes source and Javadoc), and Grails 2.2.0 RC4 was released. This will be the final RC release before the 2.2 GA release and it includes Groovy 2.0, so you should definitely check it out and start looking now at upgrading.

The Spring Loaded JVM agent that we use in Grails 2.0+ for code reloading was open-sourced this week.

The folks at Canoo released Open Dolphin which integrates Enterprise applications with Java Desktop applications.

I released a new plugin, the tcpmon plugin. It provides the TCPMon proxy tool which can help with debugging web services and rest APIs.

If you want to keep up with these “This Week in Grails” posts you can access them directly via their category link or in an RSS reader with the feed for just these posts.

Translations of this post:


There were 8 new plugins released:

  • dynamic-themes version 0.1.0. Load and render your pages with your own theme (folders with GSP templates and css) dynamically outside the scope of a web request
  • envers version 0.4.4. Integrates with Hibernate Envers
  • extra-runtime-validation version 0.1. Adds validate method to domain objects to perform additional validations at runtime
  • improx version 0.1. Use interactive mode from other process via TCP
  • jasper-response version 1.0. Render JasperReports as PDF or HTML
  • mongodb-compound-index-attributes version 1.1. Add attributes to MongoDB’s compound index
  • raven version 0.5.2. Sentry Client for Grails
  • tcpmon version 0.1. Provides the TCPMon web service monitoring tool

and 33 updated plugins:

  • asynchronous-mail version 0.9. Send email asynchronously by storing them in the database and sending with a Quartz job
  • auto-test version 1.0.2. Monitors the project directory and attempts to run only the subset of tests affected by what changed
  • bootstrap-theme version 1.0.RC3. Provides a basic Platform UI Theme based on Twitter Bootstrap
  • bootstrap-ui version 1.0.RC4. Twitter Bootstrap based UI Set for plugin platform
  • cloud-bees version 0.6.2. Adds scripts to integrate with the CloudBees client API
  • cookie version 0.4. Provides a service and taglib to get, set, and delete cookies
  • cxf version 1.0.8. Expose Grails services as SOAP web services via CXF
  • cxf-client version 1.4.8. Use existing (or new) Apache CXF wsdl2java generated content to invoke SOAP services
  • database-migration version 1.2.2. Official Grails plugin for database migrations
  • dojo version Integrates the Dojo javascript toolkit
  • easygrid version 1.0.0. Provides a convenient and agile way of defining Data Grids
  • facebook-sdk version 0.4.6. Allows your application to use the Facebook Platform and develop Facebook apps on or on web sites (with Facebook Connect)
  • feature-switch version 0.4. Allows turning on and off of features
  • flash-helper version 0.9.4. Simplifies and standardizes the process of adding/reading messages in the flash scope
  • font-awesome-resources version 2.0.4. Integrates the Font Awesome icon set
  • force-response-download version 0.1.4. Forces the browser to open a dialog for downloading content produced within controller actions
  • handlebars version 1.1.0. Server side rendering of Handlebars.js templates
  • handlebars-resources version 0.3.3. Supports using Handlebars.js templates with the Grails Resources Plugin
  • jmx version 0.8. Adds JMX support and provides the ability to expose services and other Spring beans as MBeans
  • localizations version Store i18n strings in a database
  • nerderg-form-tags version 2.1.3. Bringing Readability, Convention, Consistency and CSS to form design
  • page-resources version 0.2.3. Enhances the resources plugin by allowing for creation of ‘page’ resource modules using convention over configuration
  • platform-core version 1.0.RC2. Provides functionality for plugins to use to achieve greater integration with each other and with applications
  • platform-ui version 1.0.RC3. Abstracted UI elements and theming for plugin/application interoperability
  • rabbitmq-tasks version 0.5.4. Run background tasks using RabbitMQ to queue them
  • release version 2.2.0. Publishes Grails plugins either to a public or private repository
  • resources version 1.2.RC3. A resource management and processing framework
  • rest-client-builder version 1.0.3. Provides an alternative REST client implementation based on Spring’s RestTemplate that is not tied to commons-http-client
  • sendgrid version 1.0. Allows the sending of Email via SendGrid’s services
  • simpledb version 0.5. Integrates the AWS SimpleDB datastore into Grails, providing a GORM API onto it
  • spring-batch version 1.0.RC1. Provides the Spring Batch framework and convention based Jobs
  • twitter-bootstrap version 2.2.2. Twitter Bootstrap CSS framework resource files
  • zkui version 0.5.5. Seamlessly integrates ZK with Grails’ infrastructures; uses the Grails’ infrastructures such as GSP, controllers rather than zk’s zul as in ZKGrails plugin

Interesting Tweets


User groups and Conferences

Grails plugin dependencies

Wednesday, December 19th, 2012

If you need a jar library in a Grails plugin, the best approach is to add a dependency in BuildConfig.groovy from a Maven repository so you (and your users) only download it once and use it for each project that needs it. This works well as long as the jar is in Maven Central or some other repo, but some smaller projects don’t publish to Maven repos, so sometimes you are stuck with jar files in the lib directory. Using dependency management is convenient, especially since you can override the version in the application later if a newer jar version is released.

The standard syntax is simple, for example

dependencies {
   compile 'com.atomikos:transactions-jms:3.8.0'

This is great, but due to the way Maven works this can result in far more than just that one jar file since all of its dependencies and transitive dependencies will also be downloaded and added to the project’s classpath. That’s what you want most of the time, but often I’ve found that there are unneccessary depdendencies, or dependencies that are already provided by Grails or another plugin but with a different version. So I tend to list out all of the dependencies that I actually want to end up with, adding the necessary exclusions to the dependency declarations. For example here are the two that the spring-security-core plugin defines:

compile('') {
   excludes 'spring-expression', 'spring-core', 'spring-context', 'spring-tx',
            'spring-aop', 'spring-jdbc', 'spring-web', 'spring-test', 'aspectjrt',
            'aspectjweaver', 'cglib-nodep', 'ehcache', 'commons-collections',
            'hsqldb', 'jsr250-api', 'log4j', 'junit', 'mockito-core', 'jmock-junit4'

compile('') {
   excludes 'spring-security-core', 'spring-web', 'spring-jdbc', 'spring-test',
            'commons-codec', 'hsqldb', 'servlet-api', 'junit', 'mockito-core', 'jmock-junit4'

I could have cheated and just used transitive = false:

compile('') {
   transitive = false

compile('') {
   transitive = false

but this is really only appropriate for applications; in plugins it’s better to avoid this so the pom files are correct.

This usually isn’t that hard to do; it’s just a matter of reading pom.xml files and copy/pasting the relevant bits. But it can be tedious and I realized recently that this was an excellent use case for a Groovy script.

If you’ve installed the release plugin (it should be there since it’s added to the plugin’s BuildConfig.groovy by default) then you can run the generate-pom and it will generate target/pom.xml.

The process that I use is iterative. The first step is to use the transitive = false attribute that I said not to use earlier. This will generate a pom.xml with all of the dependencies and transitive dependencies enumerated for you for each of your specified dependencies. Then run this script in a Grails or Groovy console and it will build the proper syntax for each declaration:

String xml = new File('/path/to/pom.xml').text
for (dependency in new XmlSlurper().parseText(xml).dependencies.dependency) {
   String scope = dependency.scope ?: 'compile'
   Set exclusions = []
   for (exclusion in dependency.exclusions.exclusion) {
      String groupId = exclusion.groupId
      String artifactId = exclusion.artifactId

      if ( (groupId == 'xml-apis' && artifactId == 'xml-apis') ||
           (groupId == 'xml-apis' && artifactId == 'xmlParserAPIs') ||
           (groupId == 'xerces' && artifactId == 'xmlParserAPIs') ) {

      exclusions << "'$artifactId'"

   String combined = dependency.groupId.text() + ':' +
       dependency.artifactId.text() + ':' +
   if (exclusions) {
      println "\t$scope('$combined') {"
      println "\t\texcludes ${exclusions.sort().join(', ')}"
      println "\t}\n"
   else {
      println "\t$scope '$combined'\n"

Replace transitive = false with the output from the script. If this is sufficient then you’re done, but if you’ve excluded a jar file that you will need, then add it as an explicit dependency with transitive = false and run the script again. Repeat the process until all of the important jar files are listed, and all of their dependencies are properly excluded. Keep in mind that you don’t have to list everything, just what you need to get your plugin working. If a user needs another related jar that you excluded, it can always be added to the application’s BuildConfig.groovy.

For a more extensive example, see the db-reverse-engineer plugin’s BuildConfig.groovy. I could have just defined a dependency for the Hibernate Tools jar, but to do it correctly I ended up with six dependency declarations.

An updated Grails Spring MVC Plugin

Tuesday, December 18th, 2012

The springmvc plugin was one of the first that I wrote. At the time it wasn’t possible to create controllers in Java, so the plugin added the feature as a way to migrate existing controllers from traditional Spring applications, or to use Java if Groovy performance is an issue. But direct support for annotated controllers was added in Grails 1.2 so that made the plugin redundant.

But I found when describing this feature for the Spring chapter of Programming Grails that all URLs end up with a .dispatch suffix. This has a workaround since you can re-map the URLs in UrlMappings.groovy but it’s not DRY since it has to be done for each URL. I saw this question on Stack Overflow and thought it’d be good to update the plugin since it allows the flexibility of using any URL suffix.

So I updated the plugin to work with Grails 2.0 and higher. See the plugin documentation for installation and configuration information. We’ll get the issues that the plugin addresses fixed in Grails, but that won’t happen until 2.3, so use this until then. You can download a sample application here.

For information on the history of the plugin, see the original post and the plugin announcement.

This Week in Grails (2012-48)

Tuesday, December 04th, 2012

The 2012 Groovy & Grails Exchange is next week – better get your tickets before they sell out.

The early bird price for the Greach conference has been extended until December 12, so grab a ticket before the price goes up.

Peter Ledbrook left VMware last week. It’s obviously a big loss for us, but potentially your gain since you can now hire him as a consultant 🙂

I released a new plugin this week, app-info-hibernate and wrote a blog post about it and the updated db-reverse-engineer plugin.

If you want to keep up with these “This Week in Grails” posts you can access them directly via their category link or in an RSS reader with the feed for just these posts.

Translations of this post:


There were 5 new plugins released:

  • app-info-hibernate version 0.2. Add-on for the app-info plugin, adds extensive HIbernate information and graphs
  • fresh-security version 1.0.2.RC1. Security that “just works”, backed by Spring Security
  • funky-test-load version 0.3.9. Enables functional tests to be used as light load tests
  • localhome-config version 0.2. Configure the external configuration in ~/.grails/appName/files(Config.groovy,grails-app/i18n,web-app/)
  • mail-on-exception version 0.1. Allows one to specify an email address where all frontend exceptions will be sent

and 15 updated plugins:

  • airbrake version 0.9.1. Notifier plugin for integrating apps with Airbrake
  • akka version 0.6. Akka actors integration from Groovy and Java, in a Servlet 3.x environment
  • cassandra-astyanax version 0.3.2. Exposes the Astyanax Cassandra client as a Grails service and adds dynamic methods
  • cassandra-orm version 0.3.2. Provides GORM-like dynamic methods for persisting Groovy objects into Cassandra (but does not implement the GORM API)
  • cloud-bees version 0.6.1. Adds scripts to integrate with the CloudBees client API
  • cookie-session version 2.0.2. Allows you to store session data in a cookie
  • database-migration version 1.2.1. Official Grails plugin for database migrations
  • db-reverse-engineer version 0.5. Reverse-engineers a database to Grails domain classes.
  • functional-test version 2.0.RC1. Functional web testing using HtmlUnit to simulate the client browser
  • handlebars-resources version 0.3.2. Supports using Handlebars.js templates with the Grails Resources Plugin
  • jesque version 0.5.1. Groovier approach to using jesque
  • rabbitmq version 1.0.0. Integrates with Rabbit MQ messaging
  • rabbitmq-tasks version 0.5.3. Run background tasks using RabbitMQ to queue them
  • simple-captcha version 0.9.2. Creates simple image CAPTCHAs that protect against automated completion and submission of HTML forms
  • vaadin version 1.7.0-beta10. Adds Vaadin ( integration

Interesting Tweets

User groups and Conferences

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.