Invalid property 'maximumActive' of bean class - java

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.

Related

Configure Spring Bean using XML through Property other than String (using Properties File)

I have a Spring Bean defined as:
<bean id="loyaltyPointsExpiringJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="name" value="Loyalty Points Expiring Job Trigger" />
<property name="jobDetail" ref="loyaltyPointsExpiringJobDetail" />
<property name="cronExpression" value="${prop.loyalty.expiring.points.job.cron}"/>
<property name="timeZone" value="${prop.loyalty.expiring.points.timezone}"/>
</bean>
However, the property prop.loyalty.expiring.points.timezone is causing TypeMismatchException with the message:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.util.TimeZone' for property 'timeZone'; nested exception is java.lang.IllegalArgumentException: Invalid time zone specification '${prop.loyalty.expiring.points.timezone}'
Please guide.
It is straightforward, you may need to define a bean for your timeZone object, and find out a constructor that uses string, pass the required values.

Reasons of Invalid property 'dao' of bean class

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)

I can not have two datasources configured JPA Spring XML WildFly

Spring config in xml
<jee:jndi-lookup id="datas1" expected-type="javax.sql.DataSource"
jndi-name="java:/jndi1" />
<jee:jndi-lookup id="datas2" expected-type="javax.sql.DataSource"
jndi-name="java:/jndi2" />
<bean id="EntityM"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="datas1" />
<property name="packagesToScan" value="package.persistence.entity" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle12cDialect" />
</bean>
</property>
</bean>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="EntityM" />
</bean>
The Excpetion is:
Context initialization failed: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springSessionJdbcOperations' defined in class path resource [org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'springSessionJdbcOperations' parameter 0: No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: datas1,datas2; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: datas1,jndi2.
I can not have two datasources configured, The first datasource is to the entityManagar and second datasource is to call stored procedure.
The JdbcSessionConfiguration expects a bean of type 'DataSource' with name 'dataSource'.
If this cannot be found, spring tries to use a bean of type 'DataSource', ignoring the name. Because there are two beans of this type, the exception is thrown.
Solution :
Rename the DataSource bean, that you want to use with the EntityManager from
'datas1' to 'dataSource'.
Spring should than be able to create JdbcSessionConfiguration and you can use the 'datas2' for whatever you need.

BeanCreationException hibernate5.LocalSessionFactoryBean Bean property 'EL' is not writable or has an invalid setter method

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.

Invalid property 'connectionProperties' of bean class [org.apache.commons.dbcp.BasicDataSource]

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>

Categories