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

I should have publish 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-127.0.0.1-8080-1) 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. ;-)

Leave a Comment

24 highs and lows

Good I read my concerns about the third season of 24 – because otherwise I would elaborate on many things I can now just briefly confirm. Yes – again – lots of dead, smart people doing stupid things, hardly believable reasons for their actions. Just to name a few. It’s the day of the crisis again – after all they must have noticed all those cameras shooting another 24 season, so they must have known that it IS a serious crisis! Yet when some agent loses his key-card he will not report it for four hours! I don’t know how he got back into CTU. And the card – hardly believable – was stolen by a friend of agent’s addict sister when the agent predictably meets his sister on a parking near to CTU – yet out of all cameras – like the sister’s friends knew he will do so and have his card in the first pocket because somehow someone had contacted the rascal before just to get the card for some money. Of course – don’t tell me it’s a spoiler, because it’s not, it’s 24 pattern actually – sister and her friend would get shot by the card “buyer”. Hard life. Easy death.

Another typical 24 pattern is this. Jack (mostly he, but you can replace him by any agent – but other agent’s are more “by a book” – so again, mostly Jack :-) ) gets some nearly unrelated person – for instance a manager of some bank – in the middle of the night to get to some specific item. Now villains get on them when they are in the bank. I – being the poor manager – would close myself on a safe place, waiting till tomorrow, claiming I was forced to open the vault by Jack Bauer (everybody knows he’s the second best – right after Chuck Norris – so who would refuse?) – that all is actually true, so there should be no consequences. But no – in 24 they all go out and guess who will die?

a) also present agent Manning?
b) bank manager?
c) Jack Bauer?!

No, unlike in commercials, c) is obviously not right. You get it, right? It’s no fun when you can say “this poor fellow will die soon” – and you can say so right after they meet him! That’s how it is in 24. I’m still strongly backing the opinion that 24 in overall is fun and it is catchy and thrilling, fast-pacing action. I watched fourth season and I was extremely satisfied after the previous one. But right after that one I took the fifth season with all the aforementioned stupid catches. Fourth season is compact and working, and there are also two innocent people who will NOT die! Isn’t that beautiful? There was even moment I realized I was shouting “yes! yes!” – when Tony Almeida appeared on the scene. Highly recommended season, I mean it.

Fifth season – on the other hand – seems to be a series of loosely tight threats that all happened to be based on weaponized toxin gas in cans. Last one of them – of course – appears at the end of the season and I honestly don’t know if it was planned or the season somehow took only 20 hours and they needed to shoot 4 more. Let’s say with a submarine. Good old faces from previous episodes are the highs of this season – Mike Novick, Wayne Palmer, Aaron Pierce around the presidential sub-plot. But the CTU operations were rather puzzled. When homeland security took over CTU – pointing out their mistakes – I was confused why nobody told them what I was screaming inside of my head: “Last agent sent by the White House was so embarrassed when he lost his key-card that he rather didn’t tell us at all about it! That’s why half of the CTU died, that’s why White House is sending us you now!”

Man! So many things didn’t make any sense on this season. Shameful. Watchable, yes. Enjoyable, yes. But believable? No – not even by 24 standards. And many favourite characters dead don’t change a bit about it. On the contrary.

Yet I started with season 6 now, because I AM curious what will happen with Jack “The Second Best After Chuck” (by a close margin only) Bauer!

Leave a Comment

Salix GWT Tree

Talking about DIY may be sign of a man that can handle some things and doesn’t rely on other’s work. Reinventing the wheel – on the other hand – means someone is stupid enough to do what is already done. Of course it is easy to reinvent that wheel when you don’t know it has been invented already. When you don’t know how to check it out, or when you checked it out but the search didn’t provide proper answer (that may – again – mean that one is stupid to search properly :-) ). Whatever you can say about writing “new, simple, custom” whatever – when it does solve the problem in reasonable time frame, it’s sometimes the best thing to do. Even if it’s the wheel. Or the tree.

In this case I’m talking about my recent GWT Tree troubles. I assigned my workmate with some task based on the idea of a tree as good/nice as GWT-Ext one without using any other library, he came up with solution, we’re now cleaning it up and adding things we like and need (automatic sorting, connectors, custom icons for connectors, …) – but the important thing is – we have the Tree we can use! We call the project Salix (yeah, there is some Salix OS too, it’s really difficult to come up with some brand new tree name after we decided to move from something as original as “Simple Tree”) and you can find it on it’s Google Code project page.

I took care of the initial page and while the code is far behind Java Simon standards (other project I participate on) I’m sure you can find everything necessary right away on the first page. If you like the idea, if you struggle with GWT default tree, try it, send us feedback, patch, idea, code, whatever. We don’t plan to work on this project just for the sake of the project itself. We fulfilled our needs and published the result – nothing more, nothing less. Maybe you will like this… ehm… simple Tree too. :-)

Leave a Comment

Steam doesn’t like me… again

I don’t know why I’m so lucky . I started the computer but for some unknown reason Windows XP just didn’t want to start any program for me. Not even Ctrl+Alt+Delete worked. Not even Turn Off Computer. Otherwise it just looked OK. I even noticed bubble saying that Steam is updating EVE Online. God knows why EVE is so stupidly updated in Steam. I have already patch 1.1 of Dominion. Yesterday I patched to 1.1.1 and it was like 5 megabytes. Now today Steam was obviously downloading more megabytes. I’m even convinced I turned off updating for this game. But who knows…

Back to computer problem. I pressed reset – harsh but not my fault after all.

After another reboot, computer was OK, but Steam said it couldn’t connect. Of course – it couldn’t go to Offline mode either. Steam NEVER went to Offline mode when I needed – and I really don’t know why. Steam website seems to be OK. So I decided to search a bit. I hit troubleshooting link on the error dialog (the one offering Offline mode too). First time I timed out, second time I got to what was expected. FAQs about network issues. But there are no actual network issues!

Funny thing is that whether I hit Retry connection or Start in Offline Mode, the error is still the same: Could not connect …blablabla. And behind this window there is another one saying: “The operation cannot be completed when Steam is in offline mode.”

I went to their forums and wanted to search for other tips. To my surprise, blank page with error message was the result:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes) in /valve/www/forums.steampowered.com/forums/search.php on line 1034

I – poor stupid user – blamed myself for querying with a long string, went back to repeat with shorter – yet the page told me: “This forum requires that you wait 60 seconds between searches. Please try again in 44 seconds.” By the way – the same message appears even when Steam tells you only that “could” is too common and should not be used, ergo no search was performed at all. I tried more keywords later, but often the result was – no results at all. I consider their forum search pretty much unusable and I miss full-text search. What should I search for when I think that “Steam couldn’t connect because of some other non-network issue”. Or why I can’t search for “offline mode doesn’t work”. Is it “offline mode malfunction”? I seriously doubt many users use word “malfunction” in their problem post. I’m pretty sure – on the other hand – you can see “doesn’t work” a lot.

Isn’t it beautiful to have games for hundreds of Euros unavailable because of some stupid Steam issues? I told it before – Steam is supposed to be client for simple users as well. I pity them if they have to resolve any issue like this by themselves. For most of them there is only one option -reinstallation. That just sucks.

Actually – I believe that pirates are lucky guys who have much less problems playing their games. I don’t know what troubles I would hit using Impulse more often. On the other hand Impulse is run byStardock – a company that issued The Gamer’s Bill of Rights. I’m convinced that Steam/Valve should do better to make their client more robust and failure safe.

(The little tragedy is that I often hear that Steam is one of the top products in its category. I’m afraid it’s true.)

Edit: Problem was obviously on the server side which means it really was network problem. It was resolved soon “by itself” from my perspective. It – however – doesn’t change anything on the fact that I was unsuccessfull with Offline mode.

Leave a Comment

GWT Tree and SmartGWT troubles

We have adopted Google Web Toolkit about a half-year ago, went from 1.6.x to 1.7 and recently switched to 2.0. The first and the most important point is: Most of us feel it’s fun to create user interfaces again! After years with servlets, JSP, Struts, JSTL, JSF, Facelets, RichFaces … well, no surprise actually. GWT has – of course – its drawbacks. Now you have to communicate with your server from client side explicitly. Good thing that we can still code it all in Java and GWT does the dirty work for us.

Of course we had some problems using GWT too. We still have to mess with CSS, sometimes styles get to code, we still need to sort it all out and learn new patterns, … but even so we’re far more productive and we just love to do user interfaces in GWT.

And then there is that Tree component. Ugly, buggy, close to no features. Ok, here is what I really dislike about default GWT Tree:

  • No connectors, actually no real visual customization.
  • Focused item is not highlighted on Firefox – this bug goes all the way from (at least) 1.6, it’s reported – and probably ignored. Then you have to add ugly lines like this to your code:
    treeItem.getElement().getFirstChildElement().setAttribute("style", "display: block;");
    No, you can’t just put it into your CSS for treeItem class, because there is internally set “inline” display in GWT somewhere.
  • When the tree is put into a fixed-size div with scroll-bars and this tree is a bit wider, it tends to display right side of the tree after some clicks. Very annoying.
  • To add one more visual problem – you can’t highlight (selected, or mouse hover) the whole line, nor you can click anywhere on the line with the item. It seems to be a minor thing, but such trees are much easier to work with for users.

Now there is one big advantage of GWT default Tree: You can use GWT Widgets, you can use Image resources (from bundles), you can do virtually anything GWT related within the Tree. It’s GWT tree after all. It’s really a shame (and our pity) Google guys doesn’t want to extend this Tree anytime soon – so it seems. This way we’re reliant on some custom component. As I couldn’t find nice tree as a signle component project (preferably with really good GWT integration) I tried to use big players in space of GWT component libraries. GWT-Ext (not the same like Ext GWT) and SmartGWT. Both are wrappers around existing JavaScript libraries. GWT-Ext uses extjs – and because of changes in licensing of this library GWT-Ext was based on the last LGPL version and slowly fell behind. Extjs now offers only commercial licence if you want to use it in commercial projects – the same applies for their own Ext GWT. As GWT-Ext is now dead and using it with GWT 2.0 results in more and more compilation warnings, I’m stuck with SmartGWT. So let’s check this one out.

First thing fist – I went for SmartGWT solely because of the Tree. Yes, I can use more things from the library later, but now I’m interested only in the Tree. SmartGWT is based on SmartClient JavaScript library and both are LGPLed. This is obviously nice for tight-budget – yet commercial (for instance custom) – small GWT applications. With any library – first thing you need is to integrate it into your project. GWT-Ext needed more steps, you had to download extjs separately, copy some files here and there, change GWT module file – but in the end everything was nicely documented here – and you could get there from Google project page via the Wiki in maybe 3-4 clicks.

SmartGWT has simpler setup – but I simply miss any real Getting Started for plain project *without any IDE involved*. On their Google project Wiki there is Getting Started page, but it’s more a joke for me. No steps, no setup, nothing, just the hint to check examples. That means you have to crawl through HTML file, GWT module file and god-knows-what-else to find out what you actually have to do. I expressed my concerns in the comment on the page, but there was no real answer about actual project setup.

So I tried Tutorials. Count with me – one example for Google App Engine, another for Grails, then the rest for Eclipse and NetBeans and one of them I tried doesn’t have anything related to SmartGWT except the name – it was part 1 and maybe in part 2 there would be something about SmartGWT, but part 2 is nowhere to find. I’m surprised to see positive comments there, because there are better articles how to setup GWT project and there was no help with the SmartGWT itself (and some other comments even asked for steps how to setup SmartGWT – no wonder). Now – if I were the manager of SmartGWT project page, I’d remove this tutorial right away (I added comment on the Tutorials page too). I would check it out before I would add it in the first place – and added it after both parts were really written.

After all you’ll probably end up on their forums. Well – I don’t think forums are the best place to find out steps for integrating some GWT library into GWT, what do you think? Of course, good developer can find out all steps in the end – but after GWT-Ext you may easily think you’re missing something. SmartGWT is easy to setup and I simply can’t understand why they don’t add a few lines into their Getting Started page. Yesterday I found obsolete SmartGWT setup tutorial – but it still works with only one thing missing. As someone mentioned in comments there, you need to add following code into your HTML (before script with your GWT module):

<script>var isomorphicDir = "module-name-change-it/sc/";</script>

Besides this you only need one inherit in your GWT Module XML:

<inherits name="com.smartgwt.SmartGwt"/>

And of course – add smartgwt.jar on your classpath for GWT compiler. That’s it – now you know how to setup SmartGWT project. (Of course I omitted the coding part, but there is a Showcase with examples.) That’s the missing Getting Started. A few lines instead of many links mostly for Eclipse users – with some links not even related to SmartGWT at all.

I’ll tackle the Tree very quickly – because right now I’m not using it. Why? For one thing I wanted custom icons for every tree level (or maybe for every node). SmartGWT allows you to do it – if you provide the node with image URL. If you work with GWT for some time, you will probably expect Image widget instead. No way – as far as I know (please, let me know in comments if I’m mistaken!) – you have to do it the old way and have your icons as separate files. If you use them in bundle already… well, that’s not the way you wanna go I’m sure. The other thing with tree is that in some other project we were not able to put it into our layout. We used CSS positioning, mixing absolute/relative to get what we want. Everything works just fine – but not with SmartGWT components. For instance label on IButton is printed completely off the button the first time. Then – when you resize the browser – it jumps to proper position. But when you move split on the split panel – button moves, but the label stays. Well – not funny really. The same in a bigger extend happens with the Tree. We were unable to position it properly, unable to properly use scroll-bars on the parent div, unable to use Tree’s own scroll-bars, etc. Maybe we have to rewrite layout of our application first – probably using new GWT 2.0 Layout mechanism. But I’m not sure if everything will be alright after that…

I know that there are many happy SmartGWT users out there. I actually envy them a bit. ;-) I don’t want problems, but it just happened in this case that I hit those problems. I’ll see if I return to you with more about SmartGWT, but it will not be anytime soon – as I expect a lot of work to become a happy user too. :-) But at least there is a page with all three steps for SmartGWT startup – without a single Eclipse screenshot.

PS: Nothing against Eclipse, but it’s just annoying when you want to know how to do something and the only thing you find is how to do something in Eclipse, I guess you understand.

Comments (3)

Older Posts »