Carlo Sciolla
Posts by Carlo Sciolla
Spring Surf meets Clojure
May 23rd

For those who missed it, some time ago the Alfresco guys donated their Surf Platform to SpringSource, giving birth to the now-called SpringSurf, which is thereby described as:
a view composition framework for Spring MVC that plugs into your existing Spring applications. It provides a scriptable and content-centric approach to building web applications.
I’m not going to introduce you how to use this yet-another MVC framework, but Michael Uzquiano provided an awesome blogpost, in case you were interested into learning more about it.
Part of the job of this Spring Surf framework is to provide an easy to use web scripting framework, REST like, that enables you to easily put together a View and, optionally, a Controller to implement a web API, provide them in the classpath together with a small XML descriptor, and your REST API is deployed right away. In the SpringSurf parlance, this is called called WebScript. Again, technical insights about the framework are better explained elsewhere, so no repetitions here. What I think is cool about Spring Surf, and I’m here with you to discuss, is it’s multi-language focus: web script Controllers can be written in Javascript, PHP or Groovy right out of the box, allowing you to choose whichever language you prefer. Moreover, if you just peek at Spring Surf source code, plugging in support for new languages doesn’t look so hard, so I decided to challenge myself and write support for Clojure backed webscripts. You can find the result of my efforts on github, with a sample webscript that proves the concept.
Following the webscript framework praxis, a model map object is passed around that acts as a container for whichever result your computation will produce, that will at the end handed over to a view rendition engine, Freemarker in our case, to build the resulting document. Webscripts are intended to support a number of different output formats, from JSON to XML to plain text, so being generic here is not an option.
Anyway, the first thing you usually do is to populate the model map with a number of objects that will be needed by the rendering engine to build the response. To support this use case, this first implementation of the Clojure backend for Spring Surf webscripts expects your Clojure “script” to yield a map, in Clojure sense. This map will be then forwarded to a Freemarker template and used to build a webpage or whatever the user asked for, i.e. this controller:
(ns web.script.test)
{:foo "bar"}
and this freemarker template:
foo: ${foo}
will provide “foo: bar” back to the client.
This is just an experiment at the moment, and far from being production-quality stuff. Still, it has been instructing to build a Java-to-Clojure integration, and nonetheless it might come in handy when I’ll be trying to put more Clojure in my working life.
(bye)
Handling Microsoft Windows NTP sync
Apr 23rd

This post should raise some eyebrows around, as I’m advocating Linux since ages and I’m not at all into Microsoft stuff for the 99.99% of my time. This story comes out of that (usually negligible) 0.01%.
Why bother with NTP on MS Windows?
The Alfresco implementation I’m working on has to integrate with a fully MS-powered environment, with a Domain Controller pulling the strings of network entities such as users and hosts. As the customer has strict security requirements, no remote access can be granted to their intranet, and since their offices are a bit far away from mine, we decided to replicate their environment locally, providing the minimum set of components such as
- a domain controller (WinServer 2k8)
- a domain host (WinXP Pro SP2)
- the Alfresco server (RHELv5.4)
I was able to build up the whole replicated environment, with a relative limited effort, using virtual machines to host all the different operating system on my laptop. I was so happy that everything worked almost at the first shot that I almost died when it all went wrong after the first reboot of the VMs: I couldn’t log anymore on the WinXP box!
It turned out that all clocks drifted away, making Kerberos auth checks fail because of replication attacks protection. Looked like it was time to strengthen my Win-fu and configure NTP in a proper way. This is what I learned.
WinServer2k8 and clock management
If there’s one thing I enjoyed out of all the time spent on these tasks, the prize goes definitely to w32tm: I had to deal with Windows, and there were no windows involved! As usual, whenever I’m typing into a command line, I feel at home. I’m actually writing this whole blog post to take note of the tricks I learned around w32tm and NTP clock sync. Here we go:
- Configure NTP servers
w32tm /config /manualpeerlist:europe.pool.ntp.org /syncfromflags:manual /reliable:no /update
- Query NTP servers
w32tm /stripchart /computer:europe.pool.ntp.org /samples:5 /dataonly
- Resync clock
w32tm /resync /rediscover
- Allow resync in case of huge drifts
If your clock drifted too far away Windows will refuse to sync. In order to disable such check you have to import the following changes (write them in a reg-keys.reg file and double click it):Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config] "MaxNegPhaseCorrection"=dword:ffffffff "MaxPosPhaseCorrection"=dword:ffffffff
That’s it for now. I hope this will come in handy to somebody else, since I’ll try to avoid any more contact with the Microsoft stacks as long as possible, since without grep, find, awk, sed, vim I feel as uncomfortable as this.
Tales from an Icelandic volcano victim
Apr 21st

Last weekend Eyjafjallajökull decided my long-planned trip to visit my dear family in Italy had to be exhausting. On Friday, April 16th at 2pm my flight to Milan, scheduled to leave Amsterdam Schiphol at 8pm, was eventually cancelled. It had to be the first step of a longer journey, which was planned to be as follows:
- Amsterdam -> Milan – Friday, 16th April @8pm
- Milan -> Cagliari – Saturday, 17th April @10am
- Cagliari -> Milan – Monday, 19th April @12.30pm
- Milan -> Asterdam – Monday, 19th April @6pm
When it was clear that I was not going to leave Amsterdam by plane, I did the only thing you wouldn’t take seriously, if you were me: I rented a car to try and catch the flight leaving Milan the next day. This is the story of this long, long journey.
Amsterdam -> Milan: CANCELLED
I didn’t take note of the steps along the way down to Milan, so I will just write down a short story here.
We left Amsterdam by car at around 6pm. “We” means just me and my girlfriend, who wasn’t 100% sure I had a great idea renting the car. But she supported me all the way long, she even drove for ~300km between Frankfurt and Stuttgart, while I was sleeping next to her. She had to stop around midnight, when we both fell asleep for 2h.
Coffee, sugar, then I got back at the driver seat and drove with no intermediate stops, if not for fueling, down to Milan.
We were stopped at the customs between Switzerland and Italy (6am), where three cops checked our pockets, our luggages and even our car trying to find some criminal stuff. Needless to say, they didn’t find anything, but we lost 30 precious minutes.
Fortunately, the traffic jam that usually takes you ages to get through when you’re near Milan at rush hours was yet to ramp up, so that we made it on time at Milan airport (7.45am). We left the car at the parking area, grabbed a coffee and waited to take off.
Milan -> Cagliari: AIRBORNE
This is the most boring part of this diary: everything went really good, no delays, no nothing. We arrived, we enjoyed our time and my beloved Sardinia (and a Misfits concert, by the way). As time went by, it was clear that some more troubles were about to come.
We didn’t care until Sunday night, when they announced that Milan airport was definitely closed.
Cagliari -> Milan: CANCELLED
This hit us badly: we didn’t even considered the idea that that ash could get past the Alps, and now we were stuck in an island, even though a beautiful one. We decided to go the traditional way: we bought tickets to get back to Italy by boat.
This time we teamed up with my brother, his girlfriend and their awesome, 4 months old son. They had to come back to Pisa, so that we could share the first part of our trip together.
We left Iglesias, my birth place, at 11am, and after some hours and two stops (feeding, then fueling) we arrived at Olbia at 2.30pm. Having studied in Pisa for 7 years, the whole boat experience became quite familiar and boring long time ago. But those 9 hours passed by quite fast, as we enjoyed our time together with the little newborn totally starring the show.
We eventually arrived at Livorno at 11pm, where my girlfriend’s father was awaiting us to give us a lift to Milan. Take note: 60 years old man, driving all night long for a total of 700km just to start working the next day without any rest in between. I hope I’ll have the same energy when I’ll be aged the same.
Milan -> Amsterdam: CANCELLED
We got at Milan airport at 2.30am, where we found a surreal, totally empty place that was nonetheless bright, colorful and with all the monitors repeating the same word “cancelled” to death with nobody except us staring at them, as if their only purpose was to remind us why we were actually there.
Bathroom, coffee, take back the car from the parking lot and back on track: our former driver headed back to the south, we followed the Pole Star (3am).
They didn’t care to stop us again at customs, so we went straight to Basel, around where we took our now traditional 2h nap at around 6am.
Coffee, sugar, my girlfriend took the driver seat. I slept for the usual 300km and then drove all the way to Amsterdam.
The end
We arrived at home around 4.30pm. We were both completely exhausted, done, finished. Yet something more was left to do: empty the car, fuel it, take it back to the airport where the rental agency is, and then, finally, back at home, with enough energies left to get on and crush on the bed. 12h of sleep later, the whole story started to look like a long, distant, strange dream.
It has been devastating, and I don’t think I’m going to did it again. Still, the only regret I have is that I didn’t take pictures, as my camera was packed within my luggage. I now look at the map above, which pin points all the steps along our way back here, and think “did it”. And I cannot hide a smile.












