|
It's easy to guess that these days
I have moving some projects between IDEs (WSAD to RAD to WAS 6.1 toolkit). The
issue I have spent most time fixing is this exception…
uncaught init() exception thrown
by servlet action: javax.servlet.UnavailableException: Parsing error processing
resource path WEB-INF/struts-config.xml
at
org.apache.struts.action.ActionServlet.handleConfigException(ActionServlet.java:769)
at
org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:741)
at
org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:687)
at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)
at
javax.servlet.GenericServlet.init(GenericServlet.java:256)
<more …>
Obviously when you see a parsing
error, you would think your struts-config.xml file is either not well formed or
not valid. I checked and double checked with various xml tools only to find out
that my struts-config was fine. Upon close inspection of my web.xml file, I
realized that the file defined struts-config.xml like this
<init-param>
<param-name>config</param-name>
<param-value>WEB-INF/struts-config.xml</param-value>
</init-param>
This is incorrect. The location of
struts-config.xml should be defined relative to the web application root like
this:
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
Notice the slash in front of
WEB-INF. This tells the parser to look for struts-config.xml relative to the
web application root. If you don't put the slash, the parser looks for the file
relative to the current location (i.e. relative to the web.xml file in which
the entry is defined).
Surprisingly, the entry without
slash worked fine in WSAD (I don't know why) but when moved to RAD, it gave me
the exception. What makes it worse is the exception reporting. Looking at the
stack trace there is no way to know what the actual problem is. To an extent
all these xml based frameworks suffer from this problem but more on that later.
|