I’ve been having the weirdest issue with Grails 2.0M1 (nee 1.4M1). My application ran fine with “grails run-app”, but would fail when did a “grails tomcat deploy” and deployed to either Tomcat 6 or Tomcat 7. The error I was getting was…

ERROR  initWebApplicationContext, Context initialization failed
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; 
nested exception is java.lang.IllegalStateException: 
Cannot locate GORM API implementation. You either don't have a GORM implementation installed (such as the Hibernate plugin) 
or you are running Grails code outside the context of a Grails application.

Opening up the .war file, I could tell the hibernate plugin wasn’t being included, and having a look at /WEB-INF/grails.xml there was no trace of the line that I was expecting:

<plugin>HibernateGrailsPlugin</plugin>

So… who stripped away my HibernateGrailsPlugin?!?

After much mucking about, I found the source of the problem. It was deep inside  _GrailsWar.groovy. Somewhere around line 209 it filters out plugins based on their dependency tree (to make sure unnecessary testing/runtime plugins don’t live on inside your war). In particular, something in the Hibernate 1.4.0M1 plugin’s dependency graph results in the dependency.isSupportInConfiguration(it) returning “false”, and it getting stripped from the war file.

So it looks like the problem is inside the dependency tree for the Hibernate 1.4.0M1 plugin. A temporary workaround is to hack in a special case inside _GrailsWar.groovy until things are fixed up (insert the second line from the extract below below somewhere around line 209-ish of _GrailsWar.groovy)

def i = configs.any { descriptor.isSupportedInConfiguration(it) }
if (false == i && info.name == "hibernate") i = true
i != null ? i : true

Rerun “grails war” and you’ll see that the hibernate plugin gets package and your grails.xml file reflects that it’s a starter.

I’ll create up a JIRA for this on Monday when I’m back online since I’d like to include the exact steps to replicate since this only seems to affect a few people (if that’s you, I guess you’re just lucky!).

&nbsp;