I am working on an legacy Spring MVC Project and found issue while deploying to tomcat 8.5
Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'dataSource' is required
However the class has datasource defined .I searched in google and found to add datasource in server-context xml but i don't have any such server-context.xml in my application.
Below is the bean which is throwing error.
<bean id="languageDao"
class="com.test.daoImpl.LanguageDAOImpl"
init-method="init">
<property name="cspLanguageGet" value="csp_LANGUAGE_Get" />
</bean>
LanguageDAOImpl.class:
public class LanguageDAOImpl implements LanguageDAO {
private DataSource dataSource;
private SimpleJdbcCall languageGet;
private String cspLanguageGet;
@Qualifier("template")
@Autowired
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
@Required
public void setCspLanguageGet(String cspLanguageGet) {
this.cspLanguageGet = cspLanguageGet;
}
public void init() {
this.languageGet = new SimpleJdbcCall(dataSource).withProcedureName(cspLanguageGet);
this.languageGet.compile();
}
//functions
Error stack trace:
Property 'dataSource' is required
at org.springframework.jdbc.support.JdbcAccessor.afterPropertiesSet(JdbcAccessor.java:134)
at org.springframework.jdbc.core.JdbcTemplate.<init>(JdbcTemplate.java:165)
at org.springframework.jdbc.core.simple.AbstractJdbcCall.<init>(AbstractJdbcCall.java:87)
at org.springframework.jdbc.core.simple.SimpleJdbcCall.<init>(SimpleJdbcCall.java:69)
at com.aexp.travel.docdelivery.tcapp.daoImpl.LanguageDAOImpl.init(LanguageDAOImpl.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Can anyoone please where it is wrong?