Results 1 to 3 of 3

Thread: Newbie question - Application contexts

  1. #1
    Join Date
    Sep 2004
    Posts
    3

    Default Newbie question - Application contexts

    Hello,
    I have a problem referencing beans between different files. My web.xml file is:

    Code:
     <context-param>
      	<param-name>contextConfigLocation</param-name>
      	<param-value>/WEB-INF/applicationContext.xml</param-value>
      </context-param>
      <!-- Spring Context Loader -->
    
      <servlet>
        <servlet-name>context</servlet-name>
        <servlet-class>org.springframework.web.ContextLoaderServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <!-- Spring Dispatcher -->
    
      <servlet>
        <servlet-name>CultureApp</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
      </servlet>
    my applicationContext.xml file is:

    Code:
    <beans>
    
    	<!-- ========================= BUSINESS DEFINITIONS ========================= -->
    	<bean id="bizData" class="ca.culture.business.CultureBusinessData"/>
    
    
    </beans>
    and my CultureApp-servlet.xml file is

    Code:
    <beans>
    
        <!--  Controller for the initial Culture.ca page -->
        <bean id="CultureAppController" class="ca.culture.spring.CultureAppController">
        	<property name="businessData"><ref bean="bizData"/></property>
        </bean>
    
    
    </beans>
    My problem is that every time I start this with Tomcat 4, I get the error indicating that it cannot resolve [No bean named 'bizData' is defined]. How can beans defined in the application context be referenced in other context (.xml files) ???

    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Your configration seems correct, except for org.springframework.web.ContextLoaderServlet that should be org.springframework.web.context.ContextLoaderServl et.

    ContextLoaderServlet/ContextLoaderListener load applicationContext.xml and register it as the root WebApplicationContext. Then each DispatcherServlet loads its corresponding <servletname>-servlet.xml and binds it to the root WebApplicationContext. This way, your can reference root wac beans in your servlet context.

    jpetstore sample, from Spring distribution, shows this configuration in action.

    Could you provide the error log you receive in tomcat?
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Sep 2004
    Posts
    3

    Default

    Quote Originally Posted by irbouho
    Your configration seems correct, except for org.springframework.web.ContextLoaderServlet that should be org.springframework.web.context.ContextLoaderServl et.
    ...
    Dumb error from my part. This did it. Thanks.

Similar Threads

  1. Replies: 6
    Last Post: Oct 4th, 2010, 01:02 AM
  2. Replies: 11
    Last Post: Jul 23rd, 2007, 02:09 AM
  3. Replies: 5
    Last Post: Oct 8th, 2006, 12:39 PM
  4. newbie question
    By annbc in forum Security
    Replies: 5
    Last Post: Sep 8th, 2005, 12:28 AM
  5. Questioning the core component
    By Martin Kersten in forum Swing
    Replies: 6
    Last Post: Feb 21st, 2005, 03:45 AM

Posting Permissions

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