Today I faced a configuration bug in my web application, that can be made easier to detect if xwork does some more checks loading its action mapping.
I have my xwork.xml as following:
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd"> <xwork> <include file="first.xml" /> <include file="second.xml" /> ... <include file="last.xml" /> </xwork>
In two different included files I mapped actions in packages with the same name ie (first.xml):
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd"> <xwork> <package name="fist-package-name" namespace="/first"> ... </package> </xwork>
and second.xml
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd"> <xwork> <package name="fist-package-name" namespace="/second"> ... </package> </xwork>
Notice that in second.xml I have misspelled "first-package-name" instead of using "second-package-name".
The result of this mistake is that xwork does not find actions from one of the two packages, as the two packages have the same name. You may think that having the same name the second package loaded from xwork configurator has overwritten the first one, as it actually does.
It's not really a fault of xwork, but, I believe that xWork can make simpler to detect programming errors like this, for example giving an error or throwing an exception while loading the configuration file: in this case one package is hiding (we would better say: overwriting) another one. I am thinking if, in some cases, this hiding behaviour can be useful programmatically (ie using jar components that replace a package), but I think that at least a warning should be given. Uhmm... no, I think there's no advantage of having an overwriting feature like this, so I think it would be better to throw an exception and stop xwork from loading.
I checked the code that loads the Configuration and I found the piece responsible of this behaviour.
When com.opensymphony.xwork.config.Configuration.addPackageConfig(String name, PackageConfig packageConfig) is called its implementation (com.opensymphony.xwork.config.impl.DefaultConfiguration) does the following:
public void addPackageConfig(String name, PackageConfig packageContext) {
packageContexts.put(name, packageContext);
}
I think that something like this could be done:
public void addPackageConfig(String name, PackageConfig packageContext) { PackageConfig check = packageContexts.get(name); if (check != null) { LOG.error("name " + name + " is already been used by another package: " + check); // would be better to throw ConfigurationException("name already used"); } packageContexts.put(name, packageContext); }
Have you ever faced this problem? I posted this in WebWork Support Forums.
Search
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jun | Aug » | |||||
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Archives
Categories
- Android (3)
- Apple (26)
- Books (7)
- Eclipse (14)
- Errors (3)
- Firefox (7)
- Git (2)
- Hardware (16)
- Horror Code (8)
- Internet (18)
- Java (98)
- JavaScript (9)
- Life, universe and everything (45)
- Lifehacks (25)
- Linux (50)
- Opinions (25)
- OSX (4)
- Python (1)
- Software (27)
- Speeches and Conferences (8)
- Unix (3)
- Web (21)
- Windows (19)
Tag Cloud
Android apple architecture Bash colors configuration CSS Development Düsseldorf Eclipse germany Git Google Hardware hdr How-To Java JAXB job junit Karmic Linux MacBook music night Open Source Opinion oracle OSX patterns Pitfalls Practices Resume Security Software Suspend TDD Testing tip tonemapped Tricks Ubuntu video Web XML
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Blog License
Blogs I like
Books on the desk
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Simone Bruno
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links




















No Responses to “Webwork Package Configuration Problem”
Please Wait
Leave a Reply