Wednesday, December 28, 2011

Grails, Heroku and spring-security-core

This one is going to be quick, but made me spent almost 2 hours to google it...

If you install the spring-security-core plugin and want to deploy your application o Heroku you'll end up with a nasty-looking exception like this:

java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

If you google for No thread-bound request found you'll find some Jira issues that'll tell you pretty much nothing besides that it is a Grails issue.

Among other search results is also this one stating that the actual issue is with the webxml plugin being snatched in the wrong version and that you need to force Grails to use the right one like this:
compile ":webxml:1.4.1"
Just put the line above in your build config and life is good again.

See ya!

Edit 2012-04-05

As of Thu Dec 22 22:35:30 2011 -0500 Burt has upgraded to webxml-1.4.1 so you shouldn't experience this problem anymore.


kenliu said...

Thanks, I ran into exactly the same problem with Heroku!

Blake said...

Indeed, thank you for posting this! You may also want to note that if you don't already have a compile line for webxml you need to add it in the "dependencies" section like this:

dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

// runtime 'mysql:mysql-connector-java:5.1.16'
runtime 'postgresql:postgresql:8.4-702.jdbc3'
compile "org.grails.plugins:webxml:1.4.1"