I have a simple project based on Spring Data and MongoDB. When I deploy this project to the cloud with the following Spring context:
<?xml version="1.0" encoding="UTF-8"?>
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
<context:property-placeholder location="classpath:services.properties" />
<context:annotation-config />
<bean id="gadgetizerApplication" class="it.ids.gadgetizer.GadgetizerApplication">
</bean>
<bean id="gadgetizerService" class="it.ids.gadgetizer.service.impl.GadgetServiceImpl">
<property name="mongoTemplate" ref="mongoTemplate" />
<property name="mailSender" ref="mailSender"/>
<property name="velocityEngine" ref="velocityEngine"/>
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongoDbFactory" />
</bean>
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="mail.xxx.xxx" />
<property name="username" value="xxx"/>
<property name="password" value="xxx"/>
<property name="port" value="2525"/>
</bean>
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</value>
</property>
<beans profile="development">
<mongo:db-factory id="mongoDbFactory" dbname="${mongo.dbname}" host="${mongo.host}" port="${mongo.port}" />
</beans>
<beans profile="cloud">
<cloud:mongo-db-factory id="mongoDbFactory" service-name="${mongo.cloud.service_name}" />
</beans>
It fails with:
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]: Constructor threw exception; nested exception is java.lan
.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
... 68 more
Caused by: java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.util.Assert.notNull(Assert.java:123)
at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:196)
at org.springframework.data.mongodb.core.MongoTemplate.(MongoTemplate.java:185)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
... 70 more
Stopping Tomcat because the context stopped.
It was working one month ago. What's changed in API?
Thanks
Your issue seem to be the runtime jar. Please try to use the latest cloudfoundry-runtime.