16

How to avoid the following error? I am implementing Spring-Security on Struts2, the application runs perfectly but the following message will be shown on server log.

 WARNING!!!                            
 FilterDispatcher <<< is deprecated! Please use the new filters!                                                                      
      This can be a source of unpredictable problems!                                                                  
         Please refer to the docs for more details!                           
         http://struts.apache.org/2.x/docs/webxml.html            
Roman C
  • 49,761
  • 33
  • 66
  • 176
J888
  • 1,944
  • 8
  • 42
  • 76

3 Answers3

37

I'd recommend following the link and doing what it says:

<filter>
    <filter-name>struts2</filter-name>

    <filter-class>
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    </filter-class>
</filter>
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • The link provided with the warning doesn't work anymore, unfortunately. At least not for me. – S. Buda Feb 11 '15 at 22:10
  • @S.Buda Good point; I'll see if that was changed in later releases. – Dave Newton Feb 11 '15 at 22:15
  • I'm using struts 2.3.20 (the latest version) and the link provided there didn't work. I think it was the same url. Actually, I've been having a lot of troubles with links to struts documentation not working lately. – S. Buda Feb 11 '15 at 22:18
  • @S.Buda Until Google deals with the new Struts site it's going to be like that, I'm afraid--I don't think we did enough to deal with that, mostly for lack of tools to do so. Your best bet is to just link to the current docs. – Dave Newton Feb 11 '15 at 22:19
  • Honestly, your post was enough to get me where I needed to go. I just thought I should mention it for posterities sake. However, here is a link to the current struts docs. http://struts.apache.org/maven/struts2-core/apidocs/index.html – S. Buda Feb 11 '15 at 22:38
  • Sorry do inconvenience, the docs were moved here http://struts.apache.org/docs/home.html and this one is here http://struts.apache.org/docs/webxml.html – Lukasz Lenart Feb 12 '15 at 05:59
  • I have added a redirect and it should work now, enjoy :) – Lukasz Lenart Feb 12 '15 at 06:51
0

The FilterDispatcher (org.apache.struts2.dispatcher.FilterDispatcher) is used in the early Struts2 development, and it’s deprecated since Struts 2.1.3.

If you are using Struts version >= 2.1.3, it’s always recommended to upgrade the new filter class – StrutsPrepareAndExecuteFilter (org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter).

for references

FilterDispatcher documentation

StrutsPrepareAndExecuteFilter documentation

Paresh3489227
  • 845
  • 11
  • 22
0

Since Struts 2.1.3, an addition method call is used in doFilter () method of FilterDispatcher to display the warning message.

showDeprecatedWarning() prints the message on the console. It just a System.out.println().

 public void doFilter(....){
  showDeprecatedWarning();
    ........
 }

 private void showDeprecatedWarning() {
    String msg =
            "\n\n" +
            "***********************************************************************\n" +
            "*                               WARNING!!!                            *\n" +
            "*                                                                     *\n" +
            "* >>> FilterDispatcher <<< is deprecated! Please use the new filters! *\n" +
            "*                                                                     *\n" +
            "*           This can be a source of unpredictable problems!           *\n" +
            "*                                                                     *\n" +
            "*              Please refer to the docs for more details!             *\n" +
            "*            http://struts.apache.org/2.x/docs/webxml.html            *\n" +
            "*                                                                     *\n" +
            "***********************************************************************\n\n";
    System.out.println(msg);
}

But Struts2 recommends to use org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter instead of org.apache.struts2.dispatcher.FilterDispatcher.

web.xml configuration

<filter>
     <filter-name>struts2</filter-name>
     <filter-class>
         org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
     </filter-class>
</filter>
Dave Newton
  • 158,873
  • 26
  • 254
  • 302
zumit
  • 189
  • 1
  • 9
  • Your answer is essentially a more extended version of the already accepted one. I don't see a point in this post. – rayryeng Jul 11 '14 at 05:27
  • 2
    I have to tried to answer this point "the application runs perfectly but the following message will be shown on server log". – zumit Jul 11 '14 at 06:50