Announcement Announcement Module
No announcement yet.
Unable to return specified BeanFactory instance Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to return specified BeanFactory instance

    Hi All,

    i am getting the the error from index.jsp

    "org.apache.jasper.JasperException: org.springframework.beans.factory.access.Bootstrap Exception: Unable to return specified BeanFactory instance: factory key [beanFactory], from group with resource name [classpath*:beanRefContext.xml]; nested exception is org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'beanFactory' is defined
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(
    org.apache.jasper.servlet.JspServletWrapper.servic e(
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(


    BeanFactoryLocator beanFactoryLoc = ContextSingletonBeanFactoryLocator.getInstance();
    BeanFactoryReference beanFactoryReference = beanFactoryLoc .useBeanFactory("beanFactory");
    BeanFactory beanFactory = beanFactoryReference.getFactory();

    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>



    <bean id="beanFactory" class=" thXmlApplicationContext">
    <value type="java.lang.String">classpath*:springActivitiC ontext.xml</value>

    Can somebody help me out?

    Thanks in advance.


  • #2
    Please use [ code][/code ] tags when posting code.. I suggest a read of the reference guide and javadocs of the classes you use... The way you use those beans isn't the way it is supposed to work.. Next to that you shouldn't need or even want to use a BeanFactory inside your jsps, in general that is a sign your page does to much (it should basically only render the data which is in the model).

    Simply use the ContextLoaderListener to load the springActivitiContext.xml and use the WebApplicationContextUtils to get access to that ApplicationContext (although I still strongly advice against that!).