Results 1 to 5 of 5

Thread: Reference other context

  1. #1
    Join Date
    Nov 2004
    Location
    Santa Fe - Argentina
    Posts
    5

    Default Reference other context

    Hi, I've seen some of you post a question much like this one, and I've seen the answers but I still can't figure it out.
    I have an ejb-jar archive that loads an application context. I have some session bean that interact with daos, all managed by spring. I also have some business delegates that talk to session beans (facades).
    That context is an applicationContext.xml located in WEB-INF jar folder.

    And I have a struts web application, that will perform its task by calling the business delegates.

    The problem is that when I reference the business delegates from the web tier application context, spring says it can't resolve the reference.

    This is my configuration:

    action-servlet.xml
    Code:
    <beans>
    	<bean name="/totem/doSomething"
    		class="com.genesis.DoSomethingAction" singleton="false">
    		<property name="doSmthBD">
    			<ref bean="doSmthBDelegate" />
    		</property>
    	</bean>
    </beans>
    These are some things in struts-config.xml:
    Code:
     <action attribute="doSmthForm"
    			name="doSmthForm"
    			path="/totem/doSomething" validate="false"
    			scope="session"
    			type="org.springframework.web.struts.DelegatingActionProxy"/>
    			
    	<plug-in
    		className="org.springframework.web.struts.ContextLoaderPlugIn">
    		<set-property property="contextConfigLocation"
    			value="/WEB-INF/action-servlet.xml" />
    	</plug-in>
    In web.xml I load the listener without further reference to anything else:
    Code:
    		<listener>
    			<listener-class>
    				org.springframework.web.context.ContextLoaderListener
    			</listener-class>
    		</listener>
    How do I reference applicationContext.xml from action-servlet.xml so spring glue them all?
    Nicolas Dobler

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

    Default

    In web.xml I load the listener without further reference to anything else:
    Code:
          <listener> 
             <listener-class> 
                org.springframework.web.context.ContextLoaderListener 
             </listener-class> 
          </listener>
    ContextLoaderListener looks by default at /WEB-INF/applicationContext.xml and create the root WebApplicationContext. ContextLoaderPlugIn uses this context, automatically, as the parent of the context it create for action-servlet.xml. This means that beans configured in applicationContext.xml can be referenced by beans in action-servlet.xml.
    How do I reference applicationContext.xml from action-servlet.xml so spring glue them all?
    Can you elaborate more on what happens when you start your server? log, exceptions...
    Omar Irbouh

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

  3. #3
    Join Date
    Nov 2004
    Location
    Santa Fe - Argentina
    Posts
    5

    Default

    Thanks for your answer!

    My server starts ok. I get an exception when I invoke a method on a business delegate that is managed from other context.

    The problem is that, as you said, ContextLoaderListener loads the root WebApplicationContext, and then the pluggin loads the actions context.

    But the problem is that I have a session bean (that extends AbstractStatelessSessionBean) that loads its own context (by seeing the ejb env entry ejb/BeanFactoryPath).

    These two contexts should be related (I think the context loaded by my session beans should be parent of web context, right?), but I don't know how.

    Thanks!
    Nicolas Dobler

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

    Default

    ndobler,

    I think it would be a good idea to separate the two contexts (EJB and Web). You can for instance keep the context loaded by the EJB as is, and configure the business delegates inside the web context.
    Omar Irbouh

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

  5. #5
    Join Date
    Nov 2004
    Posts
    17

    Default

    I think the easiest way to handle this problem is described by Matt Raible at the following link:

    http://www.jroller.com/page/raible?a...g_config_files

Similar Threads

  1. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  2. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. how to reference a context from other context?
    By ndobler in forum Container
    Replies: 4
    Last Post: Nov 17th, 2004, 03:14 PM

Posting Permissions

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