Struts Developers - Upgrade To Version 2.3.1.2

In January 2012, the Struts development team released version 2.3.1.2 for general availability. This version fixes a nasty security vulnerability and "all developers are strongly encouraged to update existing Struts 2 applications to Struts 2.3.1.2." (http://struts.apache.org/) The release notes are here: http://struts.apache.org/2.3.1.2/docs/version-notes-2312.html.

I upgraded a medium-sized Struts 2 project to version 2.3.1.2. After the upgrade I had to make these changes to my source code.

1. In pom.xml remove the dependency on javassist as this jar is now a transitive dependency of the Struts 2 core.

2. Change the import path for StringUtils - import org.apache.commons.lang.xwork.StringUtils to import org.apache.commons.lang.StringUtils; we were using a version of StringUtils that was in the xwork-core-2.2.1.jar instead of the one that is part of the commons-lang jar. The new version of xwork (used by Struts 2.3.1.2) no longer has that StringUtils class.

3. Change the getContextConfiguration() method in the JUnit tests of our Action classes from:


@Override
    public String getContextLocations() {
        
        return "applicationContextTest.xml";
        
    }

to:


    @Override
    public String[] getContextLocations() {
        
        return new String [] {"applicationContextTest.xml"};
        
    }

In the 2.3.1.2 version of the Struts JUnit plugin the getContextConfigurations method was changed to return a String array instead of just a String. So when overriding that method to specify the name of your Spring configuration file (which you need to do if it differs from the default name and location) you need to return a String array.

After upgrading the Struts 2 dependencies to version 2.3.1.2, I ran all the project's unit tests and all tests passed, including those that test the Struts 2 Action classes.

There have been a couple of bugs found in version 2.3.1.2 that involve using the Struts Portlet plugin. See: https://issues.apache.org/jira/browse/WW-3733 and https://issues.apache.org/jira/browse/WW-3763

If you do find any issues after upgrading to version 2.3.1.2, be sure to email the Struts 2 user's list (see: http://struts.apache.org/mail.html). You can also read an archive of the Struts 2 mailing list here: http://struts.1045723.n5.nabble.com/.

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner