Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated dojo and tiles notes
Info
titleAbout the Migration guide

The intent of this page is to provide a list of issue/resolutions as encountered while migrating from This guide describes how to migrate an existing Struts 2.0.x application to Struts 2.1.x. The ultimate aim It is to have a proper migration guide, but as 2.1.x is still evolving, any of the issue/resolutions found in this page may become obsolete any time.
(lightbulb) Feel free to redraft material in this space! (That's why it's here!)intended to be read from top to bottom but you may skip-ahead to known problems and common exceptions. Please edit this page or provide comments if you encounter additional issues.

Content:

Table of Contents
minLevel2
maxLevel2
indent0px

Update Dependencies

Update your project dependences to use struts2-core-2.1.x and the plugins struts2-core-2.1.x.

...

Results and Interceptors have been renamed to use camelCase instead of hyphenated names (eg. now redirectAction instead of redirect-action).
Review all custom interceptor stacks, interceptor refs and results in struts.xml and remove the hyphen.

Interceptors:

...

Migrate plugin configuration

Tiles

...

2

If you use the Tiles 2 plugin, check your tiles.xml file(s) to ensure they contain a DOCTYPE.

Code Block

<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
...
Note

A missing DOCTYPE in your Tiles configuration will prevent your WebApp from starting. The following is a typical stacktrace for an invalid result type.

Code Block

INFO: Initializing Tiles2 container. . .
Nov 22, 2007 11:38:11 AM org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 2 column 19: Document is invalid: no grammar found.
org.xml.sax.SAXParseException: Document is invalid: no grammar found.

Ajax Theme / Dojo

If your WebApp uses the ajax theme bundled with Struts 2.0 (ajax tags), you need to update every pageas the Dojo support has been moved into a separate plugin and tag library.

1. Add the Dojo plugin as a new dependency for your project

Code Block

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-dojo-plugin</artifactId>
        <version>2.1.1</version>
    </dependency>

2. Modify ALL pages that use the ajax theme to reference the additional tag library.

Note

If this is a major task, it is recommended to modify and test or validate each page one at a time.

For each page there are three tasks to complete:

  1. reference the new Dojo tag library
  2. update the head tag
  3. update all ajax themed tags

Reference the new Dojo Tag Library

Reference the new taglib in your JSP or FTL pages.
Before

Code Block

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%> 

After

Code Block

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%> 
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
Note

Many pages will require both the core and dojo tags. The sx: prefix is preferred for the Dojo tags.

Update the head tag

Review the new attributes of the new head tag. You need to decide which values for the cache, compressed, parseContent and extraLocales attributes are appropriate for your application. These settings have major performance implications.

Before:

Code Block

<s:head theme="ajax"/>

After:

Code Block

<sx:head parseContent="true"/>

Update all ajax themed tags

Some tags are available only in the Dojo plugin taglib. It will be immediately obvious from your IDE that these tags need to change to the sx: prefix.
Some tags are available in both the core and Dojo plugin taglibs. Any tag that uses the ajax theme needs to be changed to the sx: prefix.

Before:

Code Block

<s:url id="jobStatus" includeParams="get" value="/RefreshOptimizationJobStatus.action" />
<s:div id="jobStatus" theme="ajax" href="%{jobStatus}" updateFreq="5000" indicator="indicator">
</s:div>
<img id="indicator" src="img/indicator.gif" alt="Loading..." style="display:none"/>

After:

Code Block

<s:url var="jobStatus" includeParams="get" value="/RefreshOptimizationJobStatus.action" />
<sx:div id="jobStatus" href="%{#jobStatus}" updateFreq="5000" autoStart="true" indicator="indicator">
</sx:div>
<img id="indicator" src="img/indicator.gif" alt="Loading..." style="display:none"/>

Sitemesh

No known migration issues

Jasper Reports

No known migration issues

Specific Migration issues and

Dojo

...

resolutions

The issues are listed in the same order as encountered after changing jars over from 2.0.x to 2.1.x. Noteworthy, the migration was done under the following setup: Fedora core 6, JDK 1.6.0_2 and Tomcat 6.0.10 running from MyEclipse plugin.

Result type "redirect-action" was renamed to "redirectAction":

Problem Symptom:

Code Block
SEVERE: Exception starting filter struts2
Unable to load configuration. - action - file:/home/giaz/code/.metadata/.plugins/
            com.genuitec.eclipse.easie.tomcat.myeclipse/tomcat/webapps/webui/WEB-INF/classes/struts.xml:39:98
	at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
	at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:370)
...
Caused by: Error building results for action ScheduleJob in namespace  - action - file:/home/giaz/code/.metadata/.plugins/
             com.genuitec.eclipse.easie.tomcat.myeclipse/tomcat/webapps/webui/WEB-INF/classes/struts.xml:39:98
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:372)
	... 30 more
Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success' - result -
              file:/home/giaz/code/.metadata/.plugins/com.genuitec.eclipse.easie.tomcat.myeclipse/tomcat/webapps/webui/
              WEB-INF/classes/struts.xml:40:50
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:616)
	... 35 more

...

Code Block
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
	"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
	"http://struts.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions/>

<s:head theme="ajax"/> is obsolete, use a different theme:

Problem Symptom: Accessing any page that includes <s:head theme="ajax"/> produces the following error:

Code Block
Nov 22, 2007 1:54:51 PM freemarker.log.JDK14LoggerFactory$JDK14Logger error
SEVERE:

Expression parameters.parseContent is undefined on line 45, column 28 in template/ajax/head.ftl.
The problematic instruction:
----------
==> ${parameters.parseContent?string} [on line 45, column 26 in template/ajax/head.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression parameters.parseContent is undefined on line 45,
            column 28 in template/ajax/head.ftl.
	at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
	at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)

Resolution is to either remove the "<s:head theme="ajax"/>" or use a different theme e.g. <s:head theme="xhtml" />

Ajax UI tags were moved to the new dojo plugin, use /struts-dojo-tags taglib instead of (or in addition to) /struts-tags:

Problem Symptom: Accessing a page containing ajax UI tags through using the struts 2 taglib will produce the following error:

Code Block
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /jsp/list/listOptimizationJobStatus.jsp(6,0) Attribute href invalid for tag div according to TLD
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)

...