Problem
Recently upgraded to Stackato to 3.6.0 (from 3.4.2), pushing grails 2.4.4 app into production produced previously unseen error:
...
[CONTAINER] AutoReconfigurationApplicationContextInitializer INFO Adding cloud service auto-reconfiguration to ApplicationContext
2015-06-29 10:49:23,879 [localhost-startStop-1] ERROR context.ContextLoader - Context initialization failed
...
[CONTAINER] lina.core.ContainerBase.[Catalina].[localhost].[/] SEVERE Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfiguration.<init>(Lorg/springframework/expression/spel/SpelCompilerMode;Ljava/lang/ClassLoader;)V
at org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener.initWebApplicationContext(GrailsContextLoaderListener.java:126)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
...
Solution
Add to grails BuildConfig.groovy
:
dependencies {
compile "org.springframework:spring-context:4.0.4.RELEASE"
compile "org.springframework:spring-tx:4.0.4.RELEASE"
}
Specify the spring version release consistent with grails version.
Note: previous versions required to specifically define buildpack in manifest.yml
:
---
applications:
- name: app
memory: 1024M
instances: 1
path: target/app-1.0.0.war
buildpack: https://github.com/cloudfoundry/java-buildpack.git
stackato:
description: A simple app
buildpack
attribute can now (and should) be removed
Note: this is not a issue with grails 2.5.0
Explanation
New buildpack (v3.0) downloads Spring Auto Reconfiguration 1.7.0_RELEASE
, which has a different spring context version (core) than the current version of grails (in this case 2.4.4
). Specifying context explicitly in grails dependencies fixes the issue.
Buildpack debug:
[staging] 2015-06-29T17:32:09.000Z: -----> Java Buildpack Version: v3.0 | https://github.com/cloudfoundry/java-buildpack.git#3bd15e1
[staging] 2015-06-29T17:32:09.000Z: -----> Downloading Open Jdk JRE 1.8.0_45 from https://download.run.pivotal.io/openjdk/precise/x86_64/openjdk-1.8.0_45.tar.gz
[staging] 2015-06-29T17:32:09.000Z: (found in cache)
[staging] 2015-06-29T17:32:09.000Z: Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre
[staging] 2015-06-29T17:32:10.000Z: (1.0s)
[staging] 2015-06-29T17:32:10.000Z: -----> Downloading Spring Auto Reconfiguration 1.7.0_RELEASE from https://download.run.pivotal.io/auto-reconfiguration/auto-reconfiguration-1.7.0_RELEASE.jar
[staging] 2015-06-29T17:32:10.000Z: (found in cache)
[staging] 2015-06-29T17:32:10.000Z: Modifying /WEB-INF/web.xml for Auto Reconfiguration