Kenai to Java.net migration update

March 3, 2010
by petermount1

Just a quick one but finally I’ve received an update about whats happening with the migration of kenai.com over to java.net. I was wondering what was happening as there’s been nothing apparent for a while now, well at least this helps.

Hi Everyone,

We told you we would have an update in about a month and that time has come.
The plan of record has not changed. Work is on-going for migrating the Java.net domain over to the Kenai infrastructure and we will move the existing Kenai.com projects over to the Java.net domain as soon as we have everything in place.

The work will take a bit of time to complete, so please feel comfortable using Project Kenai while we work towards the final move to Java.net.

If you have any questions please continue to send them to the kenai-admin<at>sun.com alias as always. We’ll do our best to answers them.

Best Regards,

The Project Kenai Team

Using JAXB to marshall XMPP

February 12, 2010
by petermount1

Back in late 2008, one of the original design goals for the rewrite of my retepXMPP project was to use JAXB for handling the marshalling of XMPP Stanzas into POJO’s. The main ideas behind this was to standardise against the XMPP schemas available online and to make the addition of further protocols easier – mainly not to break existing code.

Now this was fine until I started testing against a couple of client libraries, certain messages were being ignored. It turned out that the XML generated by JAXB does not follow the rules defined in RFC 3920bis. The problem here was that JAXB was placing all of the namespaces together in the root.

For example here’s one of the examples from RFC3921bis as generated by JAXB:

  <iq from='juliet@example.com/balcony'
       id='rg1'
       type='get'  xmlns='jabber:client'  xmlns:ns1='jabber:iq:roster'>
    <ns1:query/>
  </iq>

Here’s what it should look like:

  <iq from='juliet@example.com/balcony'
       id='rg1'
       type='get'>
    <query xmlns='jabber:iq:roster'/>
  </iq>

There’s two differences here, but the main issue is where ‘jabber:iq:roster’ is declared in the root iq element and not against the query element it’s supposed to be – the other is the declaration of the ‘jabber:client’ namespace but that one is not a problem here.

Although both are strictly correct XML wise, it isn’t for XMPP and most parsers expect the stream to follow the rules.

So why is JAXB doing this? Well apparently its by design and, if you use the JAXB-RI like I do, there’s not much we can do to change this.

In JAXB 1 it actually declared the namespaces at the appropriate places so we would get the ‘jabber:iq:roster’ namespace against the query element as expected and the XMPP stanza would then conform correctly.

However in JAXB 2.0 they changed this to the current behaviour for performance reasons. Apparently with large documents looking ahead for what namespaces are present uses a lot of resources, so they declare them first.

Now I can see their point but for one small issue – this presumes that, when a document is being parsed then unmarshalled by JAXB it was originally produced by JAXB – what if it wasn’t generated by JAXB? In that case JAXB would still do the lookup anyhow.

Unfortunately when I took a look at the source for JAXB 2.2 this declaring of namespaces is done pretty close to the start of the marshalling process, so unless they add an option to disable it we have to live with this.

So how to fix this so we can still use JAXB but generate conforming XML?

Well I’ve got a solution but it’s not pretty. The solution simply involves breaking the marshalling/unmarshalling process up into separate units of work, one per namespace. We marshal the first object, then – if it has children, marshal them.

Now this involves additional work during the marshalling/unmarshalling process but it works. The downside is that we have to modify the schemas to do this.

Fortunately the XSF’s schemas are not concrete. As Peter Saint-Andre’s put it a few weeks ago on the muc mailing list, those schemas are ‘descriptive, not normative’. This means they are representative of what the XEP’s define, but they can be changed. In fact for some (like XEP-0045/MUC) the schemas don’t define the extension points used by other XEP’s. This means we can make some simple modifications to them to get this ‘hack’ to work.

So now I have this working pretty well – marshalling to xml runs smoothly. Unmarshalling still has a few problems but I’m being hit by a nice issue with Java’s generics but that’s going to be a later post.

Kenai – is it closing or is it staying?

February 6, 2010
by petermount1

Well this is a bit of a shock – first they were going to close Kenai.com so a lot of projects (including myself) started migrating away as we had a deadline of 20th April but a couple of hours ago I got an email saying everything’s changed. Now it appears that they are going to migrate java.net to the kenai architecture so all projects are going to be migrated there rather than just deleted.

Now they could have told us this in the first place and have saved a lot of us the now wasted time of migrating everything away from kenai – effectively 1 1/2 weeks wasted in ensuring nothing is lost.

It’s not all wasted effort however.

As I use a distributed scm (Mercurial) I’ve now got a working online backup of the sources over at bitbucket.org – thats working fine, so if this is true then that will stay. I have an offline backup of the repos which I automatically push to anyhow, so getting that job to push back out to bitbucket is easy. As a bonus you can even see commits on twitter.

Also the maven repositories are at sonatype – so there maven is now working better than it did at kenai (one of the only two things I had problems with on kenai).

The one big problem I had in migrating was the project. I had created two projects on javaforge.com as that appeared to have something closer to kenai (other than jira). However I soon found two major downsides to it.

  1. You must have a javaforge account to clone from mercurial – you can’t even browse source unless logged in
  2. Anyone who submits a changeset must also have a javaforge account

Now these problems are terrible. It effectively locks you in to them and removes the benefits of having a distributed scm – receive a changeset from someone and push it to there – they automatically refuse the changeset. Also why prevent someone access to the source if they are anonymous? I’ve since found references to that problem where people have given up on javaforge because you can’t to it. Not good.

So what now?

Well I’m going to plod on – I’ve got a few major issues to sort out with JAXB and XMPP to deal with, so I’m going to see what is said over the weekend after the surprise announcement. If this is true then I’m going to stay with kenai/java.net – lets hope this means keeping jira! As others have said in the forums, kenai is the best forge out there and the only one with true IDE support with NetBeans’s kenai module.

I’ll finish off (it’s 3:30 in the morning right now) with the email about this change of heart from Oracle:

Gentlepeople,

In an effort to get information out to the Kenai community quickly, while trying to manage the integration of our two companies, I think we did a poor job at communicating our plans for Kenai.com to you. I would like to remedy that now. Our strategy is simple. We don’t believe it makes sense to continue investing in multiple hosted development sites that are basically doing the same thing. Our plan is to shut down kenai.com and focus our efforts on java.net as the hosted development community. We are in the process of migrating java.net to the kenai technology. This means that any project currently hosted on kenai.com will be able to continue as you are on java.net. We are still working out the technical details, but the goal is to make this migration as seamless as possible for the current kenai.com projects. So in the meantime I suggest that you stay put on kenai.com and let us work through the details and get back to you later this month.

Thanks for your feedback and patience.

Ted Farrell
Oracle Corporation