Announcement Announcement Module
No announcement yet.
Error while using applicationContext.getBean("questionDaoImpl") Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error while using applicationContext.getBean("questionDaoImpl")


    I am trying to get the bean injected from the servelet. I am getting this error while doing this. Does anyone know why this error occurs?

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ServletContext context = getServletContext();
    ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContex t(context);
    QuestionDAOImpl qim = (QuestionDAOImpl) applicationContext.getBean("questionDaoImpl");

    nested exception is org.springframework.beans.factory.BeanNotOfRequire dTypeException: Bean named 'questionDaoImpl' must be of type [com.ui.temp.QuestionDAOImpl], but was actually of type [$Proxy417]
    at AutowireCapableBeanFactory.doCreateBean(AbstractAu
    at AutowireCapableBeanFactory.createBean(AbstractAuto

  • #2
    I suggest using the forum search as this question has been answered numerous times before. I also suggest reading the aop chapter of the reference guide especially the part explaining proxies.

    In short cast the the interface instead of the concrete implementation.