Don't forget that / in front of WEB-INF PDF Print E-mail
Written by Chintan Rajyaguru   
Wednesday, 13 September 2006 16:12

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.

Comments
Add New Search
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 
 

Calendar

< September 2006 >
Mo Tu We Th Fr Sa Su
        1 2 3
4 5 6 7 8 9 10
11 12 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30