Console Plugin

16 votes

5% of Grails users

Dependency :
compile ":console:1.3"

Documentation Source Issues


A web-based Groovy console for interactive runtime application management and debugging


Add a dependency in BuildConfig.groovy:

runtime ':console:1.3'



  • Run your web application using grails run-app, then use a browser to navigate to the /console page of your app - most likely http://localhost:8080/<app-name>/console
  • Type any Groovy commands in the console text area, then press "Execute"
  • Keyboard Shortcuts:
    • Ctrl + Enter - Execute
    • Esc - Clear output
  • The following implicit variables are available:
grailsApplication.domainClasses.each {
   println "There are ${it.clazz.count()} instances of $it.clazz.simpleName"
import groovy.sql.Sql

def dataSource = ctx.dataSource def sql = Sql.newInstance(dataSource) sql.eachRow("select * from information_schema.system_tables", { println it.TABLE_NAME })

session.attributeNames.each { name ->
   println name.padRight(40) + session.getAttribute(name)
def params = ['requestURI', 'requestURL', 'forwardURI']
params.each {
   println it + "\t" + request."$it"
    • config - the current Grails config, e.g.
config.flatten().each { name, value ->
   println name.padRight(40) + value
  • Result Area
    • The results area displays the output of println statements and the return value of the last line executed (in blue).
    • Exceptions are also shown in the results area but with a red background
    • Additionally the execution time of your script is shown along with the output or exception
  • Remembering code
    • If you check the "Remember code" checkbox, the code that is executed is stored in a cookie and re-displayed when you open a new browser, instead of the default usage comments.
  • GSP layout
    • As of version 1.3 the GSP uses a layout, but it doesn't make any changes in the GSP. This is to ensure that a default layout isn't automatically applied which might add unwanted elements to the page. If you want to use a different layout you can specify it in Config.groovy - add the "grails.plugin.console.layout" property with the value of the layout you want to use, e.g.
grails.plugin.console.layout = 'myCoolLayout'


  • The console plugin relies on Groovy Shell. Lookup Groovy Shell documentation for more information.
  • The Groovy Shell uses the Grails classloader, so you can access any class or artifact (e.g. domain classes, services, etc.) just like in your application code.

Security Warning

  • IMPORTANT In the current version, no security feature is implemented and the '/console' path is accessible from anywhere. You're strongly encouraged to guard access to the console using a security plugin, for example Spring Security Core or Shiro.



Questions, issues, etc.

  • If have questions or suggestions about the plugin, ask on the Grails User mailing list. Report bugs in JIRA.


  • Siegfried Puchbauer
  • Mingfai Ma
  • Burt Beckwith
  • Matt Sheehan
  • Mike Hugo