Butter Dev Logo

October 21, 2010

Configuration problem: Id is required for element ‘annotation-config’ when used as a top-level tag

We have been seeing this issue in DWR/Spring integrations. It looks like the Spring guys changed (changed since Spring 3.x?) their schema and now require an id attribute on top-level annotation-config elements. DWR uses a Spring class to parse the XML and it throws the following error:

“Configuration problem: Id is required for element ‘annotation-config’ when used as a top-level tag”

It appears for now adding an id attribute resolves the issue. I will continue to look into this.

DWR, Spring and Annotations

This post applies to DWR 3.x and Spring 3.x. Configuring DWR to work with annotations and Spring isn’t difficult, but there are a lot of moving parts and many users struggle with it. There are a few elements that DWR has available and understanding them is key (these elements can be viewed in the DWR Spring schema – http://directwebremoting.org/schema/spring-dwr-3.0.xsd):

annotation-scan – This element enables DWR to scan the classpath, detect beans annotated with @RemoteProxy, @RemoteMethod, @DataTransferObject and register the beans (@DataTransferObject) and Creator proxies (@RemoteProxy & @RemoteMethod) for them.

annotation-config – This element enables DWR to scan the Spring context, detect beans annotated with @RemoteProxy and @RemoteMethod and registers Creator proxies for them. Note this element will only search the Spring context and will only create the Creator proxies. You will need to manually register converters for the types the proxy methods will return or accepts as parameters.

For now I have completed two sample applications that you can use to get started. I don’t have time to discuss the code right now but it is pretty straightforward.

February 20, 2008

DWR and Spring – A configuration for everyone

DWR and Spring is a great combination. The Spring integration in DWR can support many configurations but many times this can lead to confusion. The goal of this article is to provide developers with a working skeleton for several common environments (using Spring MVC, not using Spring MVC, using the DWR Namespace, etc.).


Before we get started you may want to take a quick look at the official DWR documentation.

The DWR Namespace Handler:

Spring 2.x introduced an “XML Namespace Handlers” feature. DWR 2.x allows you to leverage this feature through a custom namespace — eliminating the need for the DWR configuration file (dwr.xml). If you are using DWR > 2.0.x and Spring > 2.x this is the recommended approach if you want seamless integration (almost) between DWR and Spring.

There are a myriad of configurations to consider.  I have included what I feel or the more popular choices.  Please select a link for a detailed description of each configuration and to download a fully functioning basic example:

  1. I am using DWR 3.x, and Spring 3.x …
  2. I am using DWR 3.x and Spring 3.x and I would like to use Annotations without Spring MVC.
  3. I am using DWR 3.x and Spring 3.x and I would like to use Annotations with Spring MVC.
  4. I am using DWR 2.0.x, Spring 2.x, and Spring MVC
  5. I am using DWR 2.0.x, Spring 2.x, but I am not using Spring MVC


If you are using an older version (pre 2.x) of DWR or Spring, DWR still provides integration with Spring through the Spring Creator. This configuration requires a dwr.xml configuration.  Information on this set-up is covered in the DWR manual.