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

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

    Hi,

    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 org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)

  • #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.

    Comment

    Working...
    X