Chapter 6. Integration

Working with Java Enterprise Edition (JEE) techologies in Grails is very similar to using them in traditional Spring applications. For the most part, you can use them directly, writing classes in Java or reusing existing shared code and JAR files. Often it can be easier to take advantage of an existing Grails plugin that configures the necessary dependencies for you, and often adds convenience methods, services, or DSLs to hide some of the complexity and boilerplate.

Of course, like in Spring applications, you often have easier ways to implement features than using JEE techologies. GORM is a lot easier to use than JPA, Grails services behave much like EJB stateless session beans, and you can use services like EJB stateful session beans by setting their scope to “session” so each user gets a separate instance and the life cycle is automatically tied to HTTP session creation and destruction. Integrate whatever existing functionality you have, especially if it’s tested and working, because it often doesn’t help to rewrite for the sake of doing everything the “Grails way,” but when adding new functionality, be sure to see if there’s already a solution in Grails or in a plugin.


Messaging with the Java Message Service (JMS) is very straightforward in Grails. As with many technologies, “there’s a plugin for that”—in this case, the jms plugin. It doesn’t provide an implementation, just the core functionality, leaving the actual JMS implementation ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.