Monthly Archives: June 2009

My first restful application!

Today I wrote my first restful application! Well actually I copied the instructions at restlet.org mavenized the project so all the restlet libs were in place, created a war and deployed it in Tomcat. Even the client wasn’t mine because Firefox did the work there. But I displayed ‘hello world’, a moment that will stay in memories forever!

What I did do myself was read the documentation on Rest and searched for some comprehensive and workable frameworks. I’ll be blogging on that matter soon. Actually this is what I created this blog for in the first place. When attending a great Google developer day in London, I fell in love. So much I claimed this url right away. To be perfectly honest, Arjan Poutsma of the Spring team actually indulged me back in 2007, while attending their fine WebServices course.

To be continued….

Dependency mayhem: Cannot find the declaration of element ‘beans’

Last week I ran into this fun problem while fixing our Fitnesse tests (easy to say while looking back ;)). I had to fix the tests because of an Axis problem on which I’ll possibly blog later on.
The exception thrown while running the Fitnesse tests was:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from class path resource [...-application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)

All this is saying is that Spring isn’t able to validate the xml against a dtd or xsd.
A little background on the fine solution the Spring framework supplies to do schema or dtd validation on application configuration files. The code first checks if the xsd or dtd can be located globally, if not it will try to resolve the files locally. Spring has a mapping in its jars META-INF directories called spring.schemas, in which the mapping between the url and local file path is made. Still strange to me is that I had an internet connection, but possibly the proxy was in Springs way.

After a lot of research and trial and error (kuddos to these guys and a clear moment out of coffee and a nicotine shot) I found the actual problem. We had created an assembly for our Fitnesse tests where we included all the unpacked jars referenced in our projects. Because of this Spring and other dependencies got included several times and with that the spring.schemas and spring.handlers files (never knew that a file with the same name and path could be included more than once by the way). This never seemed a problem untill I added a Spring-WS dependency to one of our projects to fix the earlier mentioned Axis problem. Since by now we had around 10 spring.schemas and spring.handlers it was absolutly random which file was read and some of these included only a subset of the info since the jars only cover parts of the framework. After deleting all but one of each (I left the largest in place) my Fitnesse tests got past the point of validation errors.

To actually solve the dependency problem we’ll have to look at a better way to integrate Fitnesse and Maven. Hope to post the solution shortly.

Packing up our backpacks

Next month: apples-n-pears goes backpacking! We are planning on visiting the Emirates, Singapore and Malaysia and in detail Dubai, Singapore, Malakka, Cameron Highlands, Taman Negara, Pulau Perhentian, Pulau Redang, Kota Bharu and Kuala Lumpur. Throughout our holiday I’ll try to keep you informed by blogging, also hopefully building up a nice reference for fellow travellers.

Today, while google-ing for the best route from Melakka to Cameron to Taman Negara, I ran into a cool Malaysia journal. The entries on Malaysia and Singapore gave me a good impression…. no luck on my route options yet though for the last part of this stint.