Common Struts Errors and Causes
This page's URI: http://sites.google.com/site/dustinmarx/home/struts_errors-html
This page contains errors and exceptions commonly encountered during web application development using Struts. Along with the exception or error messages themselves, potential causes of these errors are often listed along with links to additional resources.
To most easily find the error you're looking for, use your browser's Find or Search capability and input a few words that you are seeing in your error message.
Note that this page was formerly hosted on GeoCities at http://www.geocities.com/Colosseum/Field/7217/SW/struts/errors.html and at http://www.geocities.com/dustinmarx/SW/struts/errors.html until that hosting service was discontinued on 26 October 2009. A former GeoCities version of this page has been (mostly) shared at http://www.docstoc.com/docs/3535031/Struts-Common-Errors.
Cannot retrieve mapping for action
Exception: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /Login
Probable Cause: No action defined in struts-config.xml to match that specified in the JSP's <html:form action="Login.do".
Cannot retrieve definition for form bean null
Exception: org.apache.jasper.JasperException: Cannot retrieve definition for form bean null
Probable Cause: This exception typically occurs because Struts cannot find the form bean it expects for a specific action according to the mapping in the struts-config.xml file. Most often, this is probably because the name given to the form in the name attribute of the form-bean element does not match the name attribute of the associated action's action element. In other words, the action and form should each have a name attribute that matches exactly, including case. It has been reported that this error has been seen when no name attribute is associated with the action. If there is no name attribute in an action element, no form is associated with the action. Others have reported this error as merely a symptom of something completely unrelated (all too common), but the mismatch of name attributes in the form-bean and action elements in the struts-config.xml file is the usual culprit.
Must specify type attribute if name is specified
Exception: Must specify type attribute if name is specified
Probable Cause: This error is seen in conjunction with the Struts' HTML FORM tag. As the error message points out, the "name" attribute was used in the Struts HTML FORM tag (<html:form>), but the "type" attribute was not specified for this HTML FORM custom tag.
There are two easy ways to get around this:
No action instance for path /xxxx could be created
Exception: No action instance for path /xxxx could be created
Probable Causes:
Special Note: Because so many different things can cause this error, it is recommended that you turn your error logging/debugging levels on your web server to a high level of verbosity to see the underlying problems in trying to instantiate the action class you have written and associated with the specified action xxxx through an action mapping in the struts-config.xml file. Relevant Links: Application's Action classes does not extend Struts-provided Action class Package hierarchy/directory structure specified in <code>struts-config.xml</code> file differs from that hierarchy specified in the actual action class's file using the <code>package</code> keyword -- http://www.mail-archive.com/struts-user@jakarta.apache.org/msg65874.html Action Mapping mistake in struts-config.xml -- http://www.manning.com/ao/readforum.html?forum=siaao&readthread=177 data-sources.xml file? - http://www.caucho.com/quercus/faq/section.xtp?section_id=30 Cannot find bean under name ...
Exception: Cannot find bean under name ...
Probable Cause: This is usually seen in association with a problematic Struts HTML SELECT custom tag. The Struts html:select tag behaves differently depending whether one or both of the name and property attributes is specified for its encompassed <html:options> tags. If the name attribute is specified, whether or not if the property attribute is specified, then a bean matching the specified name will be expected in some scope (such as page, request, session, or application). If the matching bean is not found in any available scope, the error above will be seen.
There are two ways to address this. The first approach is to put a bean in one of the scopes so that the html:options might be associated with it. The second approach is to not specify the name attribute and instead use only the property attribute.
No getter method for property XXXX of bean org.apache.struts.taglib.html.BEAN
Exception: javax.servlet.jsp.JspException: No getter method for property XXXX of bean org.apache.struts.taglib.html.BEAN
Probable Causes: No getXXXX() method defined for form field with name XXXX
This can happen if the JSP/Struts developer forgets that the name of the get method will have the same spelling as the value supplied in the Struts tag's property attribute, but that case will be different and is based on JavaBean specification rules. For example, my form class should have a getUsername() method if my Struts form-related tag has username as the value for its property attribute. Note the difference in case marked with emphasis on the letter "U."
Related Links: Case can trip up the matching between get method's name and name specified in Struts tag -- http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=000163
java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
Error: java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
Probable Causes:
Exception creating bean of class org.apache.struts.action.ActionForm: {1}
Exception: javax.servlet.jsp.JspException: Exception creating bean of class org.apache.struts.action.ActionForm: {1}
Probable Causes:
Cannot find ActionMappings or ActionFormBeans collection
Exception: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
Probable Causes:
Related Links: Explicitly Define <load-on-startup> - http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=50&t=001055 and http://threebit.net/tutorials/ejb/general/
NullPointerException at ... RequestUtils.forwardURL
Exception: java.lang.NullPointerException at org.apache.struts.util.RequestUtils.forwardURL(RequestUtils.java:1223)
Probable Cause: Missing path attribute in the forward subelement of the action element in struts-config.xml
Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Exception: javax.servlet.jsp.JspException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope
Probable Causes: Trying to use Struts form subelement tags outside of the Struts' form tag. Note that this might be because you are using the Struts html tags after the closing </html:form> tag.
Note that if you accidentaly make your opening html:form tag a no-body tag (you put a closing / at the end so that it looks something like <html:form ... />), this may be treated by your web server's parser as a no-body tag and everything after that tag you meant to be an opening tag will be outside of the form tag by default.
Note your prefix may be different than html, but most people seem to use that as their prefix for the Struts HTML tags library.
Related Links: Using form subelements outside of a form tag - http://forum.java.sun.com/thread.jsp?thread=337537&forum=4&message=1384153
Missing message for key xx.xx.xx
Exception: javax.servlet.jsp.JspException: Missing message for key xx.xx.xx
Probable Causes:
Cannot find message resources under key org.apache.struts.action.MESSAGE
Exception: Cannot find message resources under key org.apache.struts.action.MESSAGE
Probable Causes:
Related Links:
Provide Struts with Resource Bundle - http://threebit.net/tutorials/ejb/general/ XML Parser Issues - http://www.mail-archive.com/struts-user@jakarta.apache.org/msg15779.htmlNo input attribute for mapping path /loginAction Error: No input attribute for mapping path /xxxxAction Probable Cause: No input attribute in action mapping in struts-config.xml file for the action with the name specified in the error message. An input attribute is not required if form validation is not performed (either because the validate attribute is set to false or because the validation method in the relevant form class is not implemented. The input attribute specifies the page leading to this action because that page is used to display error messages from the form validation.
Strange Output Characters
Error: Strange and seemingly random characters in HTML and on screen, but not in original JSP or servlet.
Probable Causes:
"Document contained no data" or no data rendered on page
Error: "Document contained no data" in Netscape [no data rendered (completely empty) page in Microsoft Internet Explorer]
Probable Cause: Employing a descendent of the Action class that does not implement the perform() method while using the Struts 1.0 libraries. Struts 1.1 Action child classes started using execute() rather than perform(), but is backwards compatible and supports the perform() method. However, if you write an Action-descended class for Struts 1.1 with an execute() method and try to run it in Struts 1.0, you will get this "Document contained no data" error message in Netscape or a completely empty (no HTML whatsoever) page rendered in Microsoft Internet Explorer.
Related ResourcesOther Works by the AuthorJSP Best Practices - http://www.javaworld.com/javaworld/jw-11-2001/jw-1130-jsp.html More JSP Best Practices - http://www.javaworld.com/javaworld/jw-07-2003/jw-0725-morejsp.htmlJava EE and Flex, Part 1: A Compelling Combination - http://www.javaworld.com/javaworld/jw-01-2009/jw-01-javaee-flex-1.html
Java EE and Flex, Part 2: Can We Talk? - http://www.javaworld.com/javaworld/jw-02-2009/jw-02-javaee-flex-2.html
Add Some Spring to Your Oracle JDBC - http://www.oracle.com/technology/pub/articles/marx_spring.html
Accessorize Oracle Database with Ruby - http://www.oracle.com/technology/pub/articles/marx-ruby.html
Basic Java Persistence API Best Practices - http://www.oracle.com/technology/pub/articles/marx-jpa.html
Visualize Your Oracle Database Data With JFreeChart - http://www.oracle.com/technology/pub/articles/marx-jchart.html
Other Useful Struts Resources
|