0

"grails cf-push" results in errors listed below. Is there a way using the cloudfoundry plugin to "start fresh". I would prefer not to lose my test data in a MySQL database and a MongoDB database.

May 18, 2012 6:31:26 PM org.apache.catalina.core.StandardContext start

SEVERE: Error listenerStart May 18, 2012 6:31:26 PM org.apache.catalina.core.StandardContext start SEVERE: Context [] startup failed due to previous errors May 18, 2012 6:31:26 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap SEVERE: The web application [] created a ThreadLocal with key of type [org.codehaus.groovy.reflection.ClassInfo.ThreadLocalMapHandler] (value [org.codehaus.groovy.reflection.ClassInfo$ThreadLocalMapHandler@6434d75f]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference@4927d15e]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak. 2012-05-18 18:31:26,379 [main] ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:66) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager at java.lang.Class.forName(Class.java:169) at java.lang.Class.forName(Class.java:247) Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.ClientConnectionManager ... 2 more Stopping Tomcat because the context stopped.

stderr.log is : May 18, 2012 6:41:00 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-31903 May 18, 2012 6:41:00 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 403 ms May 18, 2012 6:41:00 PM org.apache.catalina.realm.JAASRealm setContainer INFO: Set JAAS app name Catalina May 18, 2012 6:41:00 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina May 18, 2012 6:41:00 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.35 May 18, 2012 6:41:00 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory ROOT May 18, 2012 6:41:02 PM org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart May 18, 2012 6:41:02 PM org.apache.catalina.core.StandardContext start SEVERE: Context [] startup failed due to previous errors May 18, 2012 6:41:02 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap SEVERE: The web application [] created a ThreadLocal with key of type [org.codehaus.groovy.reflection.ClassInfo.ThreadLocalMapHandler] (value org.codehaus.groovy.reflection.ClassInfo$ThreadLocalMapHandler@6d1576d7]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference@1c2d5534]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

Mark D
  • 61
  • 6

2 Answers2

0

If you do cf-update or delete the app and re-run cf-push, it will ask you if you want to use the existing MySQL and Mongo services. If you do there isn't any data loss - just don't delete the services along with the app before re-running cf-push.

Make sure you're using 'grails prod cf-push' since that will use the production configuration - there is a warning displayed if you run 'grails cf-push' to that effect.

The root cause is a CNFE from the HttpClient library. See if you can get it working locally and it should work fine on Cloud Foundry since you're just pushing a war file.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
  • Burt, the app runs with no errors in my dev machine. I am using cf-push without a environment specified. I will try it with prod. I deleted the app using STS and was able to keep my dbs – Mark D May 18 '12 at 21:26
  • I'm looking at \WEB-INF\applicationContext.xml and the bean definition for grailsApplication has a reference to /WEB-INF/grails.xml The grails.xml has plugins that I have uninstalled. Could this be causing the problem? If so, aren't these files generated? I have run 'grails clean' and the plugin refs are still there. I'm using grails 2.0.1 on my windows workstation. – Mark D May 18 '12 at 23:03
  • Try removing the `grails.project.class.dir`, `grails.project.test.class.dir`, and `grails.project.test.reports.dir` properties from BuildConfig.groovy and adding `grails.project.work.dir = 'target'`. This puts everything under the target folder, and then fully cleaning the app is as simple as deleting the target folder and re-running `grails compile`. If you do this, run `grails compile` before running `grails prod cf-push` and the war should be good. – Burt Beckwith May 18 '12 at 23:09
  • no change. Same error. I'm going to dinner. I'll try more later. Thanks for the help. – Mark D May 18 '12 at 23:23
  • Are you using `grails ininstall-plugin` for plugins listed in BuildConfig? That doesn't work, you need to remove them from BuildConfig otherwise they'll get reinstalled. – Burt Beckwith May 19 '12 at 00:03
  • I have no plugins listed in BuildConfig. Used grails uninstall-plugin Went to .grails directory and deleted it there and everywhere I could find it. The plugin is runtime-logging. I can't get it uninstalled! However, I don't think it is the cause of the problem. I was able to deploy a WAR from 10 days ago, I'm comparing it with the one that fails. – Mark D May 19 '12 at 02:06
  • I think that I have found the issue. I created a service which I believe I did by just creating a groovy class file. When I eliminate this file (and the references to it), my app will deploy on cloudfoundry. I cannot find any references to the service in the WAR configuration files, so it seems strange that it would cause the deployment to fail. – Mark D May 21 '12 at 05:56
0

I found the problem. I added a service that used an external jar from a third party package. The third party package shipped with 2 jars: one with dependencies and one without dependencies. I extracted the 3rd party zip into my classpath, but only included the one without dependencies in my lib directory. When I switched to using the jar with dependencies, the app deployed.

The following things made this simple problem difficult to resolve:

  1. the error logs simply stated that there was a problem with 'grailsApplication' and there was a class not found
  2. the app ran on my workstation using run-app,
  3. the app doesn't run on my workstation using run-war (regardless of whether the correct jars are supplied),
  4. lack of sleep!

On to the next issue!

Mark D
  • 61
  • 6