Monday, June 9, 2008

Struts 2 Zero Configuration issues

I've been working with a Struts 2 application recently. It's a great framework, escpecially compared to the Struts 1. Some of its features are really catching eye, and on of the is Zero Configuration. You simply add such snippet in you web.xml


<filter>
<filter-name>
struts2
</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>actionPackages</param-name>
<param-value>
com.my.acme.application.action
</param-value>
</init-param>
</filter>







and voila - all actions (if they end with Action or implement/extend some Struts 2 classes/interfaces) inside this package are parsed and added to the Struts configuration.
There was one particular action, which I preferred to define in the struts.xml. Sometimes it worked, sometimes didn't. The action class name ended with Action, and this was the source of my problems - sometimes it was recognized by the Zero Configuration, and sometimes - by the Struts 2 XML configuration. The behaviour was not consistent, and I couldn't find exact steps to reproduce the problem, but once I moved the Action to another package it started working properly all the time.

I hope they will fix it sometime in future, and overall, they warn the developers with "Zeror Configuration is an experimantal feature" message, so I will definetely continue keep an eye on this framework

No comments: