JBoss Seam 2.2.0 and Google Web Toolkit (GWT) 2.0.0 support

I should have published this sooner when my colleague (Radovan Sninský, working with me on Java Simon among other things) came with the solution how to call Seam components from GWT 2 (probably in milestone 1 already). GWT 2.0.0 changed some details in its RPC protocol and built-in Seam support for GWT stopped working with errors like this:

2010-02-09  10:28:12,265 ERROR  [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/whatever]]  (http- An IncompatibleRemoteServiceException was  thrown while processing this call.
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException:  Parameter 0 of is of an unknown type 'some.Class/some number'
at  org.jboss.seam.remoting.gwt.GWTService.RPC_decodeRequest(GWTService.java:426)
at  org.jboss.seam.remoting.gwt.GWTService.processCall(GWTService.java:203)
at  org.jboss.seam.remoting.gwt.GWTService$1.process(GWTService.java:120)
at  org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
at  org.jboss.seam.remoting.gwt.GWTService.getResource(GWTService.java:105)
at  org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80)
Caused  by: java.lang.ClassNotFoundException: some.Class/number
at  java.lang.Class.forName0(Native Method)
at  java.lang.Class.forName(Class.java:247)
at  org.jboss.seam.remoting.gwt.GWTService.RPC_getClassFromSerializedName(GWTService.java:479)
at  org.jboss.seam.remoting.gwt.GWTService.RPC_decodeRequest(GWTService.java:422)
... 46 more

As GWT 2.0 is fresh it was obviously better to patch Seam. And because GWT calls are processed using awesome Seam Adapters (I really like this concept!) we decided to duplicate the existing Adapter and just rewriting problematic parts. The RPC protocol changes were very subtle but it was big enough to blow out in case of Long types and probably some others too. Radovan then copied a few classes from Seam and added some of his code, fixed some lines and registered his GWT Service adapter on the URL suffix /gwt2. That way the only thing you need to do in your project is:

  • download this ZIP
  • unzip it into your src directory and let it be compiled along with EJB part of your application – if you move classes to another package, fix package declaration as well in all 5 classes
  • change the method in GWT UI part where you retrieve the service point – for example:
SomeServiceAsync svc = GWT.create(SomeService.class);
((ServiceDefTarget) svc).setServiceEntryPoint(GWT.getHostPageBaseURL() + "seam/resource/gwt2");

The important part is “gwt2” at the end instead of “gwt”. If you have your URL in some constant, change it there. Recompile, rebuild, redeploy, restart, try it – it should work now. Of course – if you’re really using GWT 2.0.0. 🙂

Licensing? Well… I guess it is LGPL like the original Seam sources. Hopefully there is no Seam 2.3 with GWT 2 support around the corner (doesn’t seem so) which would render this post useless in a day. 😉


Stupid password policy on forums

It happens here and there that I want to register somewhere and I just give up after I find out their password policy. Thing is, I use generally 8 characters long password that are not easy to guess. I used much simpler passwords for web sites, but I reconsidered later. But on IBM’s dev-site (I don’t even want to search for URL :-)) I had to include number and omit some punctuation mark or even include some other. When something forces me to use number… OK, but why the hell they then tell me not to use different character? So it’s demanding and limiting at the same time. And no, I don’t use characters beyond 7bit ASCII as it is not usable in many cases.

Whatever… said I and I simply didn’t register on that site. It was too… IBMish anyway. 😉 I could find most of the downloads I needed elsewhere or – on one occasion – a friend of mine with existing account downloaded it for me. Where I didn’t give up yet I was more than disappointed with their policy it was community site for JBoss Seam. When you register or reset password there you have to enter 10 characters which is NOT indicated anywhere. When you enter password like “AtIny,yg.” (without quotes) it will tell you that your password is easy! It doesn’t tell you that the password is short. I reported this on their forums more than a year ago. Also if you’re lucky, the CAPTCHA you get to solve is pretty uneasy. On any site CAPTCHA could be easier if it states if casing is important, if there may be numbers, etc. When you see 5 random characters often in many font shapes it is pretty unclear if something is lowercase “g” or 9 (because there is no baseline in many cases).

But to stay on passwords and keep this article short. I have now very primitive password on JBoss Seam, yet when I return there once in a year I mostly have to reset it. Today I hoped they reconsidered – but no. My complex password was easy. But “0123456789” is cool. Congratulations. As a final rant towards the page: They use their own Seam based forums, but there is no clear way how to search for two words so that results always contain both of them. Searching for “gwt upload” was pretty much the same like searching for “gwt” only. But maybe… maybe I’ll get at least direct answer for my question, which would mean that dealing with stupid password policies may be worth from time to time.

My way to JBoss Seam

If you’re not interested in Java and its Enterprise Edition you should skip this article for your own sake. 😉

I have to admit that I’m pretty lazy when it comes down to technology evaluation. On the other hand I know that I have to do it from time to time and I need to push myself further. Because last thing I want is to remain plain Java-coder. Do you wanna be proper valuable developer? You have to move ahead constantly. Sometimes I just learn things someone else is coming up with and sometimes I propagate something toward our team on myself. To learn something new was one of the most important motivation when we went to visit TheServerSide Java Symposium in Barcelona on June 2006. And there happened that moment in my life. 😉

Name Gavin King was familiar to me – because of Hibernate, of course. On the other hand I managed to forget it again and so my boss had to remind me who is it when we were going through the presentation description. “And what does he have common with some web framework?!” I was surprised when I read about Seam talk. My boss just shrugged. We were at the room waiting how he would be. And then Gavin came at the stage and started to talk about current situation in information systems development – namely about those delivered to user via HTTP/HTML. I couldn’t agree more because many things he mentioned bothered (or still bother) me from time to time. However it’s not only the content what’s important here (although it’s most important I guess). You have to see Gavin talking (and walking and gesturing on stage) because that’s really not so ordinary experience. My boss couldn’t stand it and he also didn’t like that Gavin hadn’t said anything about Seam during first 20 minutes of his speech – and so he left to check another talk (and so we also split our forces in order to gain more info from the first hand ;-)).

However, Gavin – armed with his Seam – made an impression to me – and the strong one indeed. This speech was also mentioned on TSS News (Advanced State Management with JBoss Seam). During the TSSJS in Barcelona we noticed the obvious – the community is kinda split between Spring (or other lightweighted container solution, whatever the technology stack around is complete ;-)) and the Java EE. Gavin King identifies himself as EJB3 lover. And now I started to understand it. Of course I saw some EJB3 examples with annotations before. At last bean implements the EJB interface really, many XML things are gone and everything looks simpler. I also looked at JSF but there was no use for it in our ongoing projects. And now I saw something that glues these two technologies together and the examples really shows that business code is what really dominates here. At last.

One day later we were kinda lucky when Gavin sat down at our table in foyer where we were relaxing during lunch break. I made bold to address him and then the words were somehow going on. It was exciting talk (at least for us ;-)) and I knew that I have to look at this technology later. And so I did after we came back home. First thing I liked on Seam is the start-up. If you follow the instructions precisely (and it’s not so hard) you simply have to finish with Seam examples up and running. I was also surprised that it already has reference documentation – and it is not so brief. Of course you can think about it something similar like critic in this blog post (October 2005) but I found it useful. If you want to change something in examples it’s no problem and the change mostly does what you can expect. I miss some “stupid” example where only one bean and JSF is used (useless Hello world ;-)) because it’s best minimal example for creating projects from scratch.

I also “enjoyed” Seam more than I wanted during first days because when I tried to create project on my own (not just “refactor” project tree of some example) it was a real pain. It simply didn’t work every time. Of course, the problem was between the chair and the keyboard. I rushed to do something and documentation wasn’t read completely. Biggest problem in my case (among the others) was to pack seam.properties into EJB jar – even when it’s empty. 🙂 Tricky, huh? Just do it. If you want to avoid similar stupid mistakes just point your browser to Seam’s wiki where you can find all important information – along with configuration files glossary. There I read that seam.properties must be in that jar (although I already found it out finally). It was also first time when I tried to use JSF/EJB3 for something real, so no wonder that it wasn’t walk-over. However I made it after all and now I just have to create something big with Seam to see if it’s so easy in longer run.

You’d may also want to check few others articles about Seam – few (older) TSS news: Gavin seems to really dig JSF and JBoss ‘Seam’, app framework for JEE 5, released in beta (causing some flame with Springers ;-)). See also this article on OnJava. There is also JSR 299 named Web Beans and it tries to make standard from something like Seam. And yes, Gavin is the spec leader. 😉

I’m really happy to see all this work (among the other) toward simplification of Java EE development because I have few J2EE 1.4 experiences and it was more pain than gain. Now I’m starting with Java EE again. 🙂