Professional Documents
Culture Documents
Common Errors in Struts
Common Errors in Struts
Common Errors in Struts
http://www.geocities.com/Colosseum/Field/7217/SW/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 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.
• Failure to place compiled .class file for the action in the classpath
(needs to be under WEB-INF/classes with the appropriate directory
structure underneath this that matches the package your Action class
belongs to).
Causes • Package spelling or hierarchy specified in your action class itself (using
the package keyword) does not match the spelling or complete package
hierachy specified for your action class in the class attribute of the
action in struts-config.xml.
Action class specified in the /xxxx action mapping in the struts-config.xml
file (class attribute) does not extend (directly or indirectly) from the Action
class. In other words, your custom Action class does not extend off the Struts-
provided Action class or off of another class that eventually extends the Action
class (such as DispatchAction.
Problem in your classpath, such as web server not being able to find
ApplicationResources.properties files in the WEB-INF/classes/ directory
or specified subdirectory.
Problem in struts-config.xml file with action mapping.
Problem with data-sources.xml file.
• Application's Action classes does not extend Struts-provided Action
class
• Package hierarchy/directory structure specified in struts-config.xml
file differs from that hierarchy specified in the actual action class's file
using the package keyword.
http://www.mail-archive.com/struts-
Relevant
user@jakarta.apache.org/msg65874.html
Links
• 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
java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
Error java.lang.NoClassDefFoundError: org/apache/struts/action/ActionForm
This error occurs typically when the specified Java .class file cannot be located in the
classpath. If this occurs at runtime of a web application (error shows on browser rather
than a rendered page), this typically means that specified class is not in the web server's
classpath (made up primarily of /WEB-INF/classes and /WEB-INF/lib contents).
Note that the NoClassDefFoundError in general typically indicates lack of the
specified class in the relevant classpath. In this particular case the missing class would
be ActionForm.class
This error is sometimes seen when one or more ActionForm.class instances are
Probable actually in the classpath. This most often occurs when ActionForm.class is made
Causes available correctly by placing struts.jar in the /WEB-INF/lib directory. When this
library has been correctly placed and it is verified that ActionForm.class actually is
present in the struts.jar file, the problem is either that more than one copy of
ActionForm.class is in the classpath or (more likely) that duplicate versions of class
files other than ActionForm are in the same classpath, causing confusion. This is
especially true if a class that extends ActionForm is made available twice, such as in an
.ear file that encompasses a .war file as well as in the .war file's own classpath
(/WEB-INF/classes). This problem can be resolved by guaranteeing that there are no
redundant classes, especially those related to Struts (directly from Struts or extensions
of Struts), in the web application's view.
Related • EJB and Web Shared Links:
Links http://forum.java.sun.com/thread.jsp?
forum=26&thread=413060&tstart=0&trange=15
Either the <servlet> tags for the Struts action servlet or the <servlet-
mapping> tags for the .do extension mapping or both not present in the
web.xml file. I saw a case where the web.xml file had no elements other
than the root element and so this error was occurring.
Typos or spelling errors in the struts-config.xml can lead to this error
message. For example, missing a slash ("/") on a closing tag can have this
Probable effect.
Causes
Another element that must be present in the web.xml file is the load-on-
startup element. This can be either an empty tag or can have an integer
specified that indicates the priority of executing the associated servlet. The
higher the number in the load-on-startup tags, the lower its priority.
Another possibility, related to need to use load-on-startup tag, is that
precompiling JSPs using Struts can lead to this message as well.
• Explicitly Define <load-on-startup>
Related http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?
Links ubb=get_topic&f=50&t=001055
http://threebit.net/tutorials/ejb/general/
NullPointerException at ... RequestUtils.forwardURL
java.lang.NullPointerException at
Exception
org.apache.struts.util.RequestUtils.forwardURL(RequestUtils.java:1223)
Probable Missing path attribute in the forward subelement of the action element in
Causes struts-config.xml
Related
Links
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
Probable
treated by your web server's parser as a no-body tag and everything after that tag you
Causes
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 Resources
• JSP Best Practices
• More JSP Best Practices