Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

Error on Inner bean

hi guys

I have a bean defined

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/WEB-INF/config/common/devccc.properties</value>
</list>
</property>  
</bean>

The above bean loads the properties file. then i do this

<bean id="businessService" class="com.services.WorkBusinessService">
<property name="workDao">
<ref bean="workDao" />
</property>
<property name="emailservice" ref="emailservice"/>  --defining an inner bean
</bean>
                        

<bean id="emailservice"  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="emailHost" value="${email.host}"/>      --These are the properties values       
<property name="url" value="${application.url}"/>                        
</bean>

I get an error

0000008 ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
                                 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailservice' defined in class
path resource [WEB-INF/config/app-config.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'emailHost' of bean class [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]: Bean property 'emailHost' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
      at org.springframework.

I have defined a setter method in WorkBusinessService class
public void setEmailHost(String emailHost) {
            this.emailHost = emailHost;
      }
any idea where i am going wrong?

thanks
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jay Roy

ASKER

Any help with my next spring question will be greatly appreciated

https://www.experts-exchange.com/questions/26943158/spring-AOP-with-transactions.html

thanks