Tuesday, 4 November 2008

DWR, Spring and namespace configuration

I am in the process of upgrading an existing Spring based web application that also uses DWR for alot of its dynamic pages.

The current version of Spring is 1.2.7 and part of the upgrade is to move to Spring 2.5.5

Spring 2.x now supports the namespace style of XML config files which produces a dramatically smaller & easier to read configuration. I produced a working version of configuration in both the old style and the namespace style but stuck with the latter as this is the future.

The version of DWR is 1.1.3 and its configuration requires a config file dwr.xml in the old style.

All was going well until I started spotting Exceptions being thrown by DWR.
java.io.IOException: The specified call count is not a number: null
at uk.ltd.getahead.dwr.impl.ExecuteQuery.parseParameters(ExecuteQuery.java:427)
at uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:89)
at uk.ltd.getahead.dwr.impl.DefaultExecProcessor.handle(DefaultExecProcessor.java:48)
at uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:81)
at uk.ltd.getahead.dwr.AbstractDWRServlet.doPost(AbstractDWRServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)

Upgrading to DWR 2.0.5 simply caused the Exception to disappear, but instead I got a popup stating much the same.

The problem is because I chose to use the namespace syntax for my configuration. One solution was to revert to the old style. Due to the size of the app and timescales I chose this option.

The other option is far nicer but a lot more work and that is to upgrade my DWR to 2.0.5 and change the configuration to also use the namespace syntax. This would create a solution with much better integration between DWR and Spring. I will try that out on my next application.

See DWRs documentation and Bram Smeet's blog on this topic for an excellent how-to.

No comments: