Results 1 to 3 of 3

Thread: problem using Cactus

  1. #1
    Join Date
    Apr 2005
    Posts
    14

    Default problem using Cactus

    I am having a problem using Cactus with StrutsTestCase and the Spring Struts integration.

    In my web application I have the following in my struts-config.xml:

    <plug-in className="org.springframework.web.struts.ContextL oaderPlugIn"/>

    At first I am not making use of the plugin and simply have normal Struts actions. My actions work correctly when invoked via web browser. However when I try to invoke from a JUnit test class derived from CactusStrutsTestCase, I get the following exception in the webapp container.

    ServletRedirector: null: org.springframework.beans.factory.BeanDefinitionSt oreException: IOException parsing XML document from ServletContext resource [/WEB-INF/ServletRedirector-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/ServletRedirector-servlet.xml]

    java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/ServletRedirector-servlet.xml]

    Why is Spring looking for a configuration file for the ServletRedirector servlet from Cactus? What do I need to configure (I assume in web.xml) to prevent this from appening so that I can move on with testing and then eventually use the Spring/Struts integration?

    Thanks,

    -Alex

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Can you post the Spring/Struts config from your web.xml?
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Jul 2005
    Location
    Maryland
    Posts
    40

    Default

    Solution:

    Cactus runs via a ServletRedirector and then your struts actions are executed server side.

    This means the servletName of the running servlet is "ServletRedirector".

    Spring, by default wants to load the servletName-servlet.xml file and you can see this by looking at ContextLoaderPlugin.getNameSpace() method.

    If you set the namespace to action-servlet then you'll be fine whether in production or testing with cactus. This assumes your action servlet is mapped as 'action' in your web.xml. If it's mapped as 'bob' then it needs to be bob-servlet.xml. Actually, you could just drop the servlet because now you're specifying the namespace. I kept that for convention.

    Code:
    <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
      <set-property property="contextConfigLocation"
          value="/WEB-INF/action-servlet.xml.xml"/>
      <set-property property="namespace" value="action-servlet"/>
    </plug-in>

Similar Threads

  1. Cactus + Spring Integration Tests HOWTO
    By Athrawn17 in forum Web
    Replies: 7
    Last Post: Oct 12th, 2008, 08:45 PM
  2. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  3. pagination and continuation problem in SWF
    By yfmoan in forum Web Flow
    Replies: 6
    Last Post: Jun 29th, 2005, 03:42 AM
  4. Replies: 0
    Last Post: Feb 16th, 2005, 01:45 PM
  5. Lazy Load Problem when Doing UnitTest
    By yoshi in forum Data
    Replies: 7
    Last Post: Sep 29th, 2004, 10:00 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
  •