Tuesday, January 30, 2007

I don't want to be a "regression test slave" !

Yesterday I went to Jfokus, a one-day Java conference in Stockholm.
One of the best talks, in my opinion, was the opening keynote by Simon Phipps, Chief Open Source Officer at Sun Microsystems. He was talking about the motivation of Open source, and there was a few phrases that got stuck in my memory (I hope I am quoting him correctly).

- "Earn a living by giving back" - By giving back you the community, you can feel good about making your own living out of that product/project. I like that phrase.

- "Regression test slave" - someone that is using open source, but does not commit back their patches and new additions to the community. For the complete lifecycle of that OS project they have to maintain their codebase, and make sure they dare to upgrade to a newer version. Doesn't sound so good. So there is a selfish reason to help the community too.

There was a lot of other good content in his talk (regarding licenses etc. ), but I don't recall everything right now, hopefully the slides will be available somewhere soon.

So, what about the rest of the day? I went to the following talks:

Intro Java EE5, EJB 3.0
Mike Keith, Oracle
- A bit to basic (but again, it was supposed to be an intro)
Mike was talking about the "news" of EJB 3.0
I was talking to a collegue about the usefulness of comparing EJB 3 to EJB 2 (which is a technique nobody in the would even consider using nowadays), it would have been much more interesting to compare it agaist for example a Spring/Hibernate solution.
I had a bit of a deja vu feeling too ("I have heard exacly this talk before..."), and when I got home a couldn't help myself from verifying that it was almost the same slides that Mike Keith used at JAOO 2005...

Testing a Java system using Ruby
Ola Bini, from "Karolinska institutet" (and JRuby committer) was talking about how you can use rspec (and Jruby) to test Java code as easy as if it was ruby code.
An hour was a little bit short time to try to fit in an intro of Ruby, Jruby, rspec AND demo the testing framework at KI. But I think that Ola did a good job showing the benifits.
I really like the idea of a "runnable specification", and will see if I can use similar ideas in my projects.

OSGi - intro
I would have preferred a more hands-on talk, telling what you could use OSGi for, but for me, that didn't no much about OSGi before, it was kind-of ok. The best part was the demo the last 10 minutes (using eclipse), and when Rickard Öberg was answering a few questions at the end, of how he can see JBoss is moving towards using OSGi.

Spring Web Services
Arjen Poutsma, of Interface21, was talking about different ways of creating and consuming a web service.
The most interesting part was that he advocates "Contract first", that means that you are specifying the XML-schema/WSDL before the java class, and not by just adding an annotation to a regular java method.
In my post "A few gotchas from consuming .net-webservices with a Linux/Java-client" I talked about the problems that generating a WSDL without thinking about the return types etc. can have. So I personally can really see the point of "contract first" for interoperability reasons, if you have a web serivice that is supposed to support clients written in different languages for instance.

To summarize, it was a day with varying quality of content (some high, some low), and I had a good time and met a lot of people I have worked with before.

Monday, December 18, 2006

TDD abstinence

- Yes, I admit it, I am a TDD-junkie. I have become addicted to TDD. If you have once tried it, you are stuck!

After having used test-driven development for the last projects, I find it really hard to live without the tests. Recently I started to work for a client with the job description "Do Java development, integrating an ERP system". There was very few unit tests in the codebase, and like a drug-addict I felt severe abstinence, feeling restless, and started to sweat heavily, until I wrote my first unit tests, set up test coverage, and starting to feel that satisfying feeling of control. After a week I started to preach TDD, and last week they wanted me to set up Continuous Integration, and teach the development team the basics about TDD and mock testing.
So like a drug dealer I sold them TDD, and soon they will be as addicted as I am. And it will be my fault... But it feels good!

Monday, November 06, 2006

A few gotchas from consuming .net-webservices with a Linux/Java-client

Webservice-integration and SOAP is easy, right? Well I wouldn't really agree with the S in SOAP standing for "simple"...
I have been working for a client, building a Java(Tomcat) web application that integrates with a Microsoft back-end using SOAP web services. I have been working with SOAP frameworks a lot before, mostly Apache Axis, and I didn't think I was going to run into so many problems, but...

The setup:
Java/Tomcat/Axis on Linux --> c#/.net on Windows Server

The first obstacle was to even generate Java-classes from the WSDL. Apparently Axis didn't support operation overloading (and a bit of googling on the subject told me that it wasn't really clear whether it was supported in the specification or not. If I got it right it was not supported in SOAP 1.0, but supported in SOAP 1.1 (but didn't really work there either), and then...not supported again in SOAP 1.2).
Anyway, other people have had the same problem and have fixed it (if you need it, you can download an enhanced version of wsdl4j.jar from: http://www.xwebservices.com/Resources/wsdl4j-esigma.zip)

The second obstacle was that the web service I was suppose to use returned .net-datasets (which I could not find any solution to use). After a lot of discussion I managed to have the web services rewritten to return standard "complexTypes".

The third obstacle does not have to do with SOAP but with Windows authentication. The client I worked with had a policy to use Windows Integrated Security for authentication (NTLM) as the only way to authenticate, and you had to use NTML version 2. I don't really know the details of that protocol but when searching the web for a solution to use it from Java on Linux I only found frustrated questions but no answers. Apparently Sun has licensed to have the JRE Http client work with NTLM, but only on the Windows platform. So that didn't work. Next try was to use Apache Commons Http Client, but the documentation was pretty clear on the support for NTLM.
From jakarta.apache.org:
"NT Lan Manager (NTLM) authentication is a proprietary, closed challenge/response authentication protocol for Microsoft Windows. Only some details about NTLM protocol are available through reverse engineering. HttpClient provides limited support for what is known as NTLMv1, the early version of the NTLM protocol. HttpClient does not support NTLMv2 at all."
Well...after a lot of searching I found a commercial http-client from oakland software that managed to handle the ntlm-protocol. And it finally it worked fine after some tweaking.

My advices:
1. Don't let tools like Visual Studio generate web services for you, without specifying the interface yourself (in particular do not return .net datasets if you want to service other than .net clients)
2. Don't use Windows Integrated Security (NTLM) for authentication from other than Windows clients (unless really, really necessary)
3. If you do choose to use NTLM, and want to use a commercial client, consider Oakland software's http-client, they had excellent support (and fixed Axis support in just a couple of days)...
4. SOAP is not (S)imple...Consider REST instead of SOAP where applicable... (after this project I am really looking forward to try out REST-support (and Active resources) in Rails 1.2. That might be my next blog post.

Hello world!

Well, I can't be the last man in the world to have a blog, can I? Let's see if I have some interesting stuff to write about...