Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3647

Adding a jndi-lookup Spring bean breaks ServletActionRedirectResult

    XMLWordPrintableJSON

Details

    Description

      When you add the following bean to a Spring-Struts application:
      <jee:jndi-lookup jndi-name="someName" id="currentEnvironment" default-value="XXXX" />

      Whenever you have an action with a redirectAction type, Struts will try to redirect you to:
      http://localhost:8080/XXXX/index!XXXX.action#XXXX

      This happens because the 3 String argument constructor for ServletActionRedirectResult will set action, method and namespace to whatever value is defined for that bean (XXXX in the example, if you don't have a someName JDNI property).

      This only happens when you let struts manage ServletActionRedirectResult. If you add the following Spring bean:
      <bean id="myRedirect" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"
      scope="prototype" autowire="byName">
      </bean>

      and add a <result-type name="myRedirect" class="myRedirect" /> result type, the problem doesn't appear.

      I've added a testCase for you to confirm.

      Attachments

        1. redirectActionErrorWithJunitTest.zip
          25 kB
          Miguel Almeida
        2. redirectActionErrorTest.zip
          23 kB
          Miguel Almeida

        Activity

          People

            lukaszlenart Lukasz Lenart
            wild_oscar Miguel Almeida
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: