I started using Grails in early 2008, about a month before the 1.0 release. Much has changed since then, but many aspects are still very much the same. Grails continues to be the fastest way to develop an application on the JVM and, as an added bonus, is a lot of fun. Grails saves you a tremendous amount of time by handling the plumbing work that you would ordinarily have to do yourself if you were using another framework, and you can save even more time by using some of the hundreds of plugins that are available. Plus, because you are targeting the JVM, the whole JVM ecosystem is available, and you can use any library that isn’t already included by Grails or a plugin.

I have always had a need to know how things work. Open source software makes that possible, because you can read the code, and it is particularly helpful when debugging since you can step into library and framework code from your IDE. But Grails adds a layer of opacity by providing so much dynamic behavior. All that magic is great when everything works, but when you have problems, it can be hard to know where to even start looking. When I started using Grails, I spent many hours exploring the internals, not only to understand how what I was seeing was possible, but also to determine whether the problems I was seeing were Grails issues or problems in my code. That experience was a large part of the motivation behind writing this book; I hope that by shining a light on some of the inner workings and motivations behind Grails features, your path will be easier.

Who This Book Is For

This book is intended for experienced developers. This primarily includes Grails developers who want to dig deeper into the architecture and understand more about how Grails works its magic and how it integrates with Groovy, Spring, Hibernate, and other technologies. Developers with experience in similar frameworks such as Spring MVC, JEE, or Ruby on Rails should find this book useful in understanding how Grails implements features to which they are accustomed.

This should not be your first Grails book, since it presumes a good deal of previous experience and understanding, so be sure to read a more comprehensive Grails book first.

Other Resources

There are many resources available if you would like to find out more about Grails and Groovy.

There is a significant amount of information at the Grails site, in particular the reference documentation. Likewise, the Groovy site has years of collective information available. For a more general overview of Grails, there are two books available that cover Grails 2: The Definitive Guide to Grails 2 by Jeff Brown and Graeme Rocher (Apress), and Grails in Action, Second Edition by Glen Smith and Peter Ledbrook (Manning). Programming Groovy, Second Edition by Venkat Subramaniam (Pragmatic Programmers) is an excellent resource for Groovy, and the second edition covers Groovy 2, and Groovy in Action, Second Edition by Dierk König et al. (Manning), when finished, will be a comprehensive reference for all things Groovy.

There are several conferences around the world that feature Grails and other Groovy-based technologies:

Spring One 2GX
This is the largest and is held in the fall; it includes five tracks on Spring Framework technologies and four Groovy and Grails tracks
Groovy and Grails Exchange
Held in London each year in December
GR8Conf US
Held in Minneapolis each spring
GR8Conf Europe
Held in Copenhagen each spring
Held in Madrid each winter

All of these conferences have a significant amount of content on a wide range of technologies in the Groovy ecosystem, and they attract the top experts in the field as speakers.

Grails also has a strong user community. The User mailing list is quite active and is great place to ask questions. There are dozens of user groups across the globe, and hopefully one near you. See the group list page at for the active groups, and if there isn’t one nearby, create one! Groovy Blogs is a blog aggregator that includes posts about Groovy and Grails technologies. It’s a convenient way to stay aware of what’s going on, and I recommend adding its Atom or RSS feed to your news reader. I write a regular “This Week in Grails” blog series that lists Grails- and Groovy-related blog posts, tweets, job postings, and upcoming conferences and user group meetings each week.

Conventions Used in This Book

The following typographical conventions are used in this book:

Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.


This icon signifies a tip, suggestion, or general note.


This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, if this book includes code examples, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: "Programming Grails by Burt Beckwith (O’Reilly). Copyright 2013 Burt Beckwith, 978-1-44932-393-6.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online


Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at

Find us on Facebook:

Follow us on Twitter:

Watch us on YouTube:


Several people helped to make this book what it is today. Thank you to Peter Ledbrook for suggesting the idea at SpringOne 2GX 2011. My initial response was no, that there was no way that I would have the time to devote to a book. That was true, but I did it anyway, and it seems to have worked out okay. I would also like to thank Mike Loukides for supporting Grails at O’Reilly; I am hopeful this will be the first of many O’Reilly Grails and Groovy books.

I was fortunate having Meghan Blanchette as the book’s editor. Thank you for your patience, advice, and for keeping everything on schedule.

Graeme Rocher and Tomas Lin were the technical reviewers. They carefully read the book and found numerous mistakes and omissions, and made extensive suggestions. Andrew Eisenberg also provided valuable feedback on the AOP chapter. Thank you all for making this a better book than I could have alone.

Many thanks to the Grails, Groovy, and tools teams at SpringSource for creating these amazing technologies.

And, finally, thank you to my wife, Maria. I know it can be hard being married to someone who spends as much time staring at a computer screen as I do. Thank you for your patience and support.

Get Programming Grails now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.