Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error instantiating a datasource bean

 
amol bakre
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am very new to springs and not really sure if this has been posted earlier.
Anyway, i had to use springs to construct a new application. i was fiddling around with springs and struts 2 for sometime and finally i have gotten a lot of things ironed out. Coming to springs, i needed that it should use a datasource bound to a JNDI name on the application server. I looked around a bit but everywhere the examples contained how to configure a bean to be used as a datasource with all connection configuration in the application.xml..
Anyway finally i found some information on how to lookup / create datasource from JNDI, but that is giving an error..(gave hundreds of errors but now i am finally very close..is what i believe..lol)
I will mention below a sample of code, will appreciate if somebody could help resolve this problem of mine..thanks in advance..

<beans>
..
..
<bean id="DS_Bbytes" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/grovy_name" />
</bean>
...
...
<bean id="someDao" class="com.x.y.z.someDaoImpl" >
<constructor-arg><ref bean="td"/></constructor-arg>
</bean>
..
..
<bean id="td" class="com.x.y.z.TaskDAOImpl">
<property name="Datasource"><ref bean="DS_Bbytes"/></property>
</bean>
..
..
</beans>

somewhere in the TaskDAOImpl
..
..
jdbcTemplate = getJdbcTemplate();
..


The following error is thrown on startup, btw i am using Tomcat5.5 and oracle DB (9i rel2) (odbc14.jar)

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Can't resolve reference to bean 'td' while setting property 'constructor argument'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'td' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'Datasource' of bean class [com.x.y.z.TaskDAOImpl]: Bean property 'Datasource' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'td' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'Datasource' of bean class [com.vodafone.bbytes.spring.TaskDAOImpl]: Bean property 'Datasource' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

org.springframework.beans.NotWritablePropertyException: Invalid property 'Datasource' of bean class [com.vodafone.bbytes.spring.TaskDAOImpl]: Bean property 'Datasource' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?

Is this problem due to kind of missing configuration on the tomcat server, for example something like <writable>false</writeable>
 
Eduardo Bueno
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, next time UseCodeTags.

Change to

Check your setters/getters to see if they match the DAO names. TaskDAOImpl access methods should be named taskDAOImpl. Also, the class someDaoImpl is starting with a lowercase character. That may be a typo; otherwise it is incorrect.



*typos
 
amol bakre
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

Thanks for your reply....

that helped, although it did not work and i had to research a little more and found..that it had much to do with not having the constructors in my case as i was extending the JdbcDaoSupport Class and overriding methods defined there and giving no template errors..

Thanks..
Am
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic