In applicationContext_dao I got bean classNameDao, and now I am trying to create a BUS layer and add to applicationContext_bus two beans.
<bean id="classNameValidator" class="cz.mikros.w4.model.bus.validator.ClassNameValidator">
<property name="dao" ref="classNameDao" />
</bean>
<bean id="classNameBus" class="cz.mikros.w4.model.bus.impl.ClassNameBusImpl">
<property name="dao" ref="classNameDao" />
<property name="validator" ref="classNameValidator" />
</bean>
problem is
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'dao' of bean class [path.model.bus.validator.ClassNameValidator]: Bean property 'dao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Can you navigate me where can be the problem?
Check if your path.model.bus.validator.ClassNameValidator has public setter method on dao. It should be called public void setDao(DAO dao)
Related
I am getting this error when trying to connect to activemq
ConnectException: Invalid property 'maximumActive' of bean class [org.apache.activemq.pool.PooledConnectionFactory]: Bean property 'maximumActive' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Not sure what does it mean . Do I miss something in the bean creation ?
I have this setting :
bean id="llmJmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
<property name="maximumActiveSessionPerConnection" value="20" />
<property name="maxConnections" value="10" />
<property name="connectionFactory" ref="llmJmsConnectionFactoryBase" />
</bean>
Yes, the property is different:
maximumActiveSessionPerConnection
Try that instead in your Spring config.
I am quite new in the world of Spring Framework and trying to initialize an object 'abcListener' through the Spring which contains an instance variable 'algoMediator' and I am getting following exception.
Error creating bean with name 'abcListener' defined in class path resource [eventcreation/integration.xml]: Cannot resolve reference to bean 'liabilityService' while setting bean property 'algoMediator'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'liabilityService' is defined.
In Spring XML I have defined bean as follow.
<bean id="abcListener" class="services.integration.AbcListener">
<property name="algoMediator" ref="liabilityService"/>
</bean>
The Java class is
public class AbcListener
{
private AlgoMediator algoMediator;
public void setAlgoMediator(AlgoMediator algoMediator) {
this.algoMediator = algoMediator;
}
}
I have checked in project at too many places the intsance variabale bean is defined in same way and as 'liabilityService' is defined in different file but it is not accepting my defination.
The liabilityService Spring XML is
http://www.springframework.org/schema/beans/spring-beans.xsd"
default-autowire="byName">
<alias name="liabilityService" alias="algoMediator"/>
<bean id="liabilityService" class="services.liability.impl.AlgoMediator" init-method="init" >
<property name="eventLiabilityMonitoringInterval" value="${liability.eventLiabilityMonitoringInterval}"/>
<property name="fastTrackedSuspensions" value="${ms.fastTrackedSuspensions:false}"/>
<property name="blurInterval" value="${liability.ms.blurInterval}"/>
<property name="publishActualOffTime" value="${ms.publishActualOffTime}"/>
<property name="transactionManager" ref="transactionManager"/>
<property name="liabilityDatasource" ref="liabilityDatasource"/>
<property name="liabilityScaleFactor" value="${liability.scaleFactor:0}"/>
<property name="sportsWithoutMarketAlerts" value="${alerts.sportsWithoutMarketAlerts}"/>
</bean>
Please check that init() method exists in AlgoMediator class else remove the init-method="init" declaration
If you create any new injection, go to integration.xml and add the bean, it should solve the issue.
Example:
public class ExampleClass{
...
#Autowired
ExampleInjection exampleInjection
...
}
Add this in integration.xml
<bean id="exampleInjection"
class="yourPackageName.className">
</bean>
I am migrating from Hibernate 3/Spring 3 to Hibernate 5/Spring 4 and am receiving this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'sessionFactory-ETL' defined in class path resource
[config/context-hm.xml]: Error setting property values; nested
exception is org.springframework.beans.NotWritablePropertyException: Invalid
property 'eL' of bean class
[org.springframework.orm.hibernate5.LocalSessionFactoryBean]: Bean property
'eventListeners' is not writable or has an invalid setter method. Does the
parameter type of the setter match the return type of the getter?
Here is part of the config file:
<bean name="hibernateEventListeners" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap">
<map>
<entry key="pre-update" value-ref="pup" />
<entry key="save-update" value-ref="xSaS" />
<entry key="post-insert" value-ref="xIS" />
<entry key="merge" value-ref="xML" />
<entry key="pre-delete" value-ref="eRUL" />
</map>
</property>
</bean>
<bean id="sessionFactory-ETL"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="eventListeners" ref="hibernateEventListeners" />
Can anyone shed some light on this? I'm not sure if I need to change the type of the hibernateEventListeners to something other than a MapFactoryBean.
I am getting this exception when initializing BasicDataSource. I want to pass Custom connection property to the dataSource.
My config is:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'connectionProperties' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'connectionProperties' 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.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1042)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:902)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1420)
I used this post from spring forum to resolve the issue.
Adding this bean solved my issue.
<bean
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
lazy-init="false">
<property name="targetObject" ref="csdbDataSource" />
<property name="targetMethod" value="addConnectionProperty" />
<property name="arguments">
<list>
<value>defaultRowPrefetch</value>
<value>1</value>
</list>
</property>
</bean>
I have two child classes(PermanentEmployee and ContractEmployee) of Employee class.
I want spring to inject the dependencies under TextEditor1 by type . Along with this i want to inject the PermanentEmployee depndency under TextEditor1.
similarily want to inject the contractEmployee dependency under TextEditor2. Rest should be injected
automatically by type?
<bean id="textEditor1" class="com.TextEditor" autowire="byType">
<property name="employee" ref="permanentEmployee" />
</bean>
<bean id="textEditor2" class="com.TextEditor" autowire="byType">
<property name="employee" ref="contractEmployee" />
</bean>
<bean id="permanentEmployee" class="com.PermanentEmployee" >
</bean>
<bean id="contractEmployee" class="com.ContractEmployee">
</bean>
But i get the error Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: saying two match are found ?
Update :- i also tried below but it didn't work either
<bean id="textEditor1" class="com.TextEditor" autowire="byType">
<qualifier type="permanentEmployee"/>
</bean>
I think that's because those two com.PermanentEmployee and com.ContractEmployee are implementing another interface like com.Employee?
That way, Spring will recognize those same type and can't choose which bean Spring have to auto-wire into the bean.
So you might need to add those byName, not byType in this case.
If you change those injection with #Autowired annotation or #Resource annotation, you can use #Qualifier( for Autowired ) or name property of Resource annotation to specify bean name.