{"id":4953,"date":"2014-03-30T17:12:01","date_gmt":"2014-03-30T17:12:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/sts-3-0-0-with-spring-roo-1-2-2-cannot-deploy-to-cloudfoundry-with-mongodb-service-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:12:01","modified_gmt":"2014-03-30T17:12:01","slug":"sts-3-0-0-with-spring-roo-1-2-2-cannot-deploy-to-cloudfoundry-with-mongodb-service-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/sts-3-0-0-with-spring-roo-1-2-2-cannot-deploy-to-cloudfoundry-with-mongodb-service-collection-of-common-programming-errors\/","title":{"rendered":"STS 3.0.0 with Spring Roo 1.2.2 cannot deploy to CloudFoundry with MongoDB service-Collection of common programming errors"},"content":{"rendered":"<p>I downloaded STS 3.0.0 and have been trying to get a simple spring app onto CloudFoundry using Roo.<\/p>\n<p><strong>STEP 1: This is my roo script<\/strong><\/p>\n<pre><code>\/\/ Spring Roo 1.2.2.RELEASE [rev 7d75659] log opened at 2012-08-26 22:36:52\nproject --topLevelPackage com.nroots.tracker\nmongo setup --cloudFoundry true\nentity mongo --class ~.domain.Trackable --testAutomatically \nfield string --fieldName name --notNull --sizeMin 3 \nfield date --fieldName datetime --type java.util.Date --dateTimeFormatPattern yyyyMMddHHmmssSSS \nrepository mongo --interface ~.repository.TrackableRepository --entity ~.domain.Trackable \nservice --interface ~.service.TrackableService --entity ~.domain.Trackable \nweb mvc setup \nweb mvc all --package ~.web \nlogging setup --level DEBUG --package ROOT\nlogging setup --level DEBUG --package PROJECT \nperform eclipse \n<\/code><\/pre>\n<p><strong>STEP 2: Import the project into STS<\/strong> I get a dialog asking me if I want to convert the legacy STS project and I select yes. The project gets imported and builds successfully.<\/p>\n<p><strong>STEP 3:<\/strong> With the roo shell still running, I modify the Trackable domain class and add a double[] array to hold gps coordinates. And then in the Package Explorer View, I do a Refactor &gt; Push In The project builds successfully again.<\/p>\n<p><strong>STEP 4: Deploy to CloudFoundry<\/strong> Using the STS CloudFoundry extension, I created a new VMware CloudFoundry server and add my application and bind it to a MongoDB service&#8230;<\/p>\n<p>However, I get these exceptions in the Console View during deployment:<\/p>\n<pre><code>2012-08-26 18:05:41,367 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed\norg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trackableServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.nroots.tracker.repository.TrackableRepository com.nroots.tracker.service.TrackableServiceImpl.trackableRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trackableRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in file [\/var\/vcap\/data\/dea\/apps\/tracker-0-36d30b53f85ac47671b723302407a7ec\/tomcat\/webapps\/ROOT\/WEB-INF\/classes\/META-INF\/spring\/applicationContext-mongo.xml]: Cannot resolve reference to bean 'mongoDbFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found 0\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)\n    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)\n    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)\n    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)\n    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)\n    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)\n    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)\n    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)\n    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)\n    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)\n    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)\n    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)\n    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)\n    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)\n    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)\n    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)\n    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)\n    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)\n    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)\n    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)\n    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)\n    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)\n    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)\n    at org.apache.catalina.core.StandardService.start(StandardService.java:525)\n    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)\n    at org.apache.catalina.startup.Catalina.start(Catalina.java:595)\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\n    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\n    at java.lang.reflect.Method.invoke(Method.java:597)\n    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)\n    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)\nCaused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.nroots.tracker.repository.TrackableRepository com.nroots.tracker.service.TrackableServiceImpl.trackableRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trackableRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in file [\/var\/vcap\/data\/dea\/apps\/tracker-0-36d30b53f85ac47671b723302407a7ec\/tomcat\/webapps\/ROOT\/WEB-INF\/classes\/META-INF\/spring\/applicationContext-mongo.xml]: Cannot resolve reference to bean 'mongoDbFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found 0\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)\n    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)\n    ... 37 more\nCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trackableRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'template'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in file [\/var\/vcap\/data\/dea\/apps\/tracker-0-36d30b53f85ac47671b723302407a7ec\/tomcat\/webapps\/ROOT\/WEB-INF\/classes\/META-INF\/spring\/applicationContext-mongo.xml]: Cannot resolve reference to bean 'mongoDbFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found 0\n    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)\n    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)\n    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)\n    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)\n    ... 39 more\nCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in file [\/var\/vcap\/data\/dea\/apps\/tracker-0-36d30b53f85ac47671b723302407a7ec\/tomcat\/webapps\/ROOT\/WEB-INF\/classes\/META-INF\/spring\/applicationContext-mongo.xml]: Cannot resolve reference to bean 'mongoDbFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found 0\n    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)\n    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)\n    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)\n    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)\n    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)\n    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)\n    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)\n    ... 52 more\nCaused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDbFactory': Invocation of init method failed; nested exception is org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found 0\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)\n    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)\n    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)\n    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)\n    ... 64 more\nCaused by: org.cloudfoundry.runtime.env.CloudServiceException: Expected 1 service of class org.cloudfoundry.runtime.env.MongoServiceInfo type, but found 0\n    at org.cloudfoundry.runtime.service.AbstractServiceCreator.createSingletonService(AbstractServiceCreator.java:53)\n    at org.cloudfoundry.runtime.service.AbstractCloudServiceFactory.createInstance(AbstractCloudServiceFactory.java:46)\n    at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:130)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)\n    ... 71 more\nStopping Tomcat because the context stopped.\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I downloaded STS 3.0.0 and have been trying to get a simple spring app onto CloudFoundry using Roo. STEP 1: This is my roo script \/\/ Spring Roo 1.2.2.RELEASE [rev 7d75659] log opened at 2012-08-26 22:36:52 project &#8211;topLevelPackage com.nroots.tracker mongo setup &#8211;cloudFoundry true entity mongo &#8211;class ~.domain.Trackable &#8211;testAutomatically field string &#8211;fieldName name &#8211;notNull &#8211;sizeMin 3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4953","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4953"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4953\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}