PDA

View Full Version : problem accessing beans from a jar file



jbalcaen
Nov 10th, 2005, 07:55 AM
Hello,

I have a package 'commons' where I define Spring beans.
This package is set in a jar file which is used by webapps.
To access a bean from a jar, I use this code in my webapp :

InputStream fis = this.getClass().getResourceAsStream("/com/cwsoft/commons/spring/resource/springConfig.xml");
InputStreamResource isr = new InputStreamResource(fis);
Vad01Dao vad01Dao = (Vad01Dao)((new XmlBeanFactory(isr))).getBean("vad01Dao");

<!-- Vad01 DAO object: Hibernate implementation -->
<bean id="vad01Dao" class="com.cwsoft.commons.model.dao.hibernate.Vad01DaoHib ernateImpl">
<property name="hibernateTemplate"><ref bean="hibernateTemplate"/></property>
<property name="cwd77Dao"><ref bean="cwd77Dao"/></property>
</bean>

public class Vad01DaoHibernateImpl extends HibernateDaoSupport implements Vad01Dao {

private Cwd77Dao cwd77Dao;
public Cwd77Dao getCwd77Dao() {
return cwd77Dao;
}
public void setCwd77Dao(Cwd77Dao cwd77Dao) {
this.cwd77Dao = cwd77Dao;
}
..........
}

This must return me the vad01Dao bean.

This works fine when I must retrieve the bean from the package 'commons' but it doesn't work from my webapp including the jar file.

I obtain this message :

org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'vad01Dao' defined in resource loaded through InputStream: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'cwd77Dao' of bean class [com.cwsoft.commons.model.dao.hibernate.Vad01DaoHib ernateImpl]: Bean property 'cwd77Dao' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

Also, when I must retrieve a simple bean from my webapp, it works fine :

<!-- Cwd01 DAO Definition: Hibernate implementation -->
<bean id="cwd01Dao" class="com.cwsoft.commons.model.dao.hibernate.Cwd01DaoHib ernateImpl">
<property name="hibernateTemplate"><ref bean="hibernateTemplate"/></property>
</bean>

What is the problem ?

jbalcaen
Nov 10th, 2005, 09:13 AM
Ok, it's resolved.

It was a bad version of Spring