I’ve been starting to learn Struts 2 over the past week or so and have gotten stumped on an example using the TextProvider interface. I have a simple class (TextExampleAction.java) that just returns the SUCCESS string. Here is the source of the action class:
package com.packt.s2wad.ch03.i18n;
import org.apache.log4j.Logger;
import com.opensymphony.xwork2.ActionSupport;
public class TextExampleAction extends ActionSupport implements TextInterface {
private static Logger log = Logger.getLogger(TextExampleAction.class);
public String execute() throws Exception {
log.debug(getText("from.class.props"));
return SUCCESS;
}
}
And here is the source of the JSP file (text-example.jsp):
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<body>
<dl>
<dt>From TextExampleAction.properties via property tag, using getText(...)</dt>
<dd><s:property value="getText('from.class.props')"/></dd>
</dl>
</body>
</html>
My properties file is named the same as my Java class (TextExampleAction.properties) and is located in the same package. Here is the contents of that file:
from.class.props=Hello from TextExample.properties!
When I view the page, here is what is displayed:
From TextExampleAction.properties via property tag, using getText(…)
from.class.props
So I’m just trying to figure out why it’s returning a null value for that property…
EDIT:

I cannot reproduce this issue under Struts 2.3.1.
TextExampleAction(with correct extension).For example, here’s my Maven output:
This works as expected.
Edit after looking at project
Your S2 config file,
struts.xml, isn’t being deployed.Also, as it stands in the repo, you are not running any requests through your own actions, only the default S2 forwarding action–you won’t get any of your packaged I18N files picked up because they don’t exist in the default action’s package.
I really recommend not doing this via Ant, but by using Maven as suggested in the book, although in this case the only thing missing is the
struts.xmlfile. As yourbuild.xmlcurrently stands, putstruts.xmlat the root of your source directory.