Invalid property 'dbSessionFactory' of bean class

Hello, I am building an OpenMRS Module using JPA annotation and Hibernate. When importing the module into OpenMRS, I get this error:

Message Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gmaoDao' defined in URL [jar:file:/usr/local/tomcat/.OpenMRS/.openmrs-lib-cache/savicsgmao/savicsgmao.jar!/moduleApplicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dbSessionFactory' of bean class [org.openmrs.module.savicsgmao.api.dao.impl.GmaoDaoImpl]: Bean property 'dbSessionFactory' 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 my repository. Could someone can support ?

@anatoleabe could you define this bean in your webAppContex.xml

<bean id="gmaoDao" class="org.openmrs.module.savicsgmao.api.dao.impl.GmaoDaoImpl">
            <property name="dbSessionFactory" ref="dbSessionFactory"></property>
        </bean>

Thank you for you help. I did it, but no change. You can check the last commit.

I fixed the issue by creating the dbSessionFactory in my GmaoDaoImpl with the same name as the property.

@Autowired
DbSessionFactory dbSessionFactory;

public void setDbSessionFactory(DbSessionFactory dbSessionFactory) {
	this.dbSessionFactory = dbSessionFactory;
}
2 Likes