I'm trying to reuse our Spring-JDBC based DAO classes and code in a project which has a traditional Java (controller) servlet (not Spring's Dispatcher servlet). So as shown below, I tried to launch the application-config.xml manually using ClassPathXmlApplicationContext. However, I get the error shown further below.
private static final String CONFIG_PATH = "classpath*:application-config.xml";
private signupDao SignupDao;
ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG_PATH);
signupDao = context.getBean(SignupDao.class);
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.abc.dao.SignupDao] is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:371) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:968)
Earlier, I did not add the following entry to application-config.xml but even after adding it, I still get the same error as above ("No qualifying bean of type is defined").
<bean id="signupDao" class="com.abc.dao.SignupDao"></bean>
Any ideas?
The controller servlet is not my own, I get it from a third party, I'm only trying to extend their handlers which is where I'm trying to use Spring autowiring, JDBC etc.
EDIT:
The only bean I'm able to load is context.getBean(MessageSource.class)
, none of my beans can be loaded. getBeanDefinitionNames
is returning empty array when I tried earlier. Do you think this is a classpath issue?
*
from yourCONFIG_PATH
Caused by: java.io.FileNotFoundException: class path resource [application-config.xml] cannot be opened because it does not exist