Results 1 to 2 of 2

Thread: Unable to return specified BeanFactory instance

Hybrid View

  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Default 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(JspServletWrapper.java:515)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:411)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:322)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:249)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:96)
    "

    [index.jsp]

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

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

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:beanRefContext.xml</param-value>
    </context-param>

    [beanRefContext.xml]

    <bean id="beanFactory" class="org.springframework.context.support.ClassPa thXmlApplicationContext">
    <constructor-arg>
    <list>
    <value type="java.lang.String">classpath*:springActivitiC ontext.xml</value>
    </list>
    </constructor-arg>
    </bean>
    </beans>

    Can somebody help me out?

    Thanks in advance.

    kt

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,630

    Default

    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!).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •