Spring Modules comes with lots of handy add-ons for Spring. I particularly enjoy the benefits of the cache and validation modules. But ever since moving up to Eclipse Europa, I've been plagued with annoying errors in Eclipse that just won't go away. And from what I've been told, some of you have been seeing the same problems in older versions of Eclipse. If you've been seeing errors that look like this...
Error:Error:line (13)cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:config'.
...then you're not alone. I've had no trouble building and deploying applications that use Spring Modules, but it's very annoying to see those ugly red X's in Eclipse. The problem boils down to the fact that Spring Modules' custom XML elements are defined in XML Schema that is purported to be available on http://www.springmodules.org. For example, here's how you declare the Spring Modules Cache elements:
The catch is that those XSD files aren't actually anywhere to be found at http://www.springmodules.org/. So, Eclipse (and other Schema-validating XML editors) complains. This is actually an issue in Spring Modules' JIRA. Vote for MOD-329 if you want to see it fixed.
In the meantime, however, here's how to help Eclipse to hush up about those errors. These instructions assume that you're using Eclipse Europa...adjust accordingly for older versions of Eclipse.
- Open up the Eclipse preferences dialog and navigate to "Web and XML" -> "XML Catalog".
- In the tree box at the top right, click on "User Defined Entries" (to get focus on that node).
- Click the "Add..." button.
- Enter the following into the "Add XML Catalog Entry" dialog:
- Location: jar:file:/path/to/spring-modules/spring-modules-cache.jar!/org/springmodules/cache/config/springmodules-cache.xsd
- Key Type: Schema Location (note: For me, this option didn't appear until I had entered the Location entry as above.)
- Key: http://www.springmodules.org/schema/cache/springmodules-cache.xsd
- Click the "OK" button to add the entry. At this point, you have the base XSD for Spring Modules Cache. This is important because all of Spring Modules' other schemas are based on this one. But I'm using EHCache, specifically, as my caching solution. So I also need to add and entry for the Spring Modules EHCache XSD. So, click on "Add..." again.
- Enter the following into the "Add XML Catalog Entry" dialog:
- Location: jar:file:/path/to/spring-modules/spring-modules-cache.jar!/org/springmodules/cache/config/ehcache/springmodules-ehcache.xsd
- Key Type: Schema Location
- Key: http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
- Click "OK" to add the entry. Refresh the XML files with the errors and voila! No more errors!
At least that's what worked for me. I've only tried it on one instance of Eclipse, but it should work as advertised for you. Also, you can pull the same kind of trickery to address similar problems with other XSDs that can't be found at their online home.