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-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. 😉

Advertisements

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.

Google Chrome with perspective

I can hardly believe that it’s almost a year I started to use Google Chrome browser! While I still use it at home I decided to switch back to Firefox at work – for a simple reason. Chrome is very stubborn when accessing https sites without proper certificate. We have a few on our corporate intranet and while I can simply accept any certificate forever with Firefox, it’s not so easy with Chrome. I’ve found some blog posts how to import certificate permanently in Windows, but somehow I failed to do so (maybe I messed up, maybe something else is wrong). I like to tweak things, but sometimes I’m just lazy to fix things that should be easy. That are easy somewhere else with something else. Like Firefox in this case.

I still use Google Chrome at home though, but I’m closer and closer to abandon it there as well. Do you use Google Docs? I do. When I open the document (I write now), I click on its title, little dialog box appears with the label “Enter new document name:” and the input box with the title of the document. It seems to be selected, so CTRL+C, go somewhere else, CTRL+V and guess what appears: “Enter new document name:” Hm, strange… I go there again, I select few characters from the title, copy/paste… again, the same result. I found out when I wanted to copy title to the WordPress. But I clearly remember it to work! But yeh, wait… in which browser? In Firefox it works like a charm. Well not a charm actually, it simply works like it SHOULD in the first place.

Last problem I have with Google Chrome is more technical and is related to Google Web Toolkit we started to use. Biggest trouble here is that I probably have to tackle this one but so far I’m stuck without any idea. If you’re not a programmer, stop reading and consider the article finished. If you are…

GWT compiles Java code to JavaScript which means you can write an application in Java (Google’s special libs) and then run it in the browser as a nice rich application with AJAX support and much more. You can load the resulting JavaScript on the HTML page and it works somehow. Now I wanted to generate HTML page with JSF/Facelets and power the server-side with JBoss Seam. Resulting HTML page is exactly the same, HTTP response headers are a bit different, but nothing serious. The application works fine in Firefox, IE, anything… except Google Chrome where it throws funny exception:

Uncaught TypeError: Object #<a Document> has no method 'write'

The script with the problem is generated and this particular part is some service stuff – not the result of my Java code. Problem is on the third line here:

function computeScriptBase(){
var thisScript, markerId = $intern_8, markerScript;
$doc.write($intern_9 + markerId + $intern_10);

Now how can anyone starting with GWT probably resolve this? Honestly I have no idea what is happening there and why it works fine in anything but Google Chrome. Now I hosted the SAME script in plain HTML, I ran telnet to my application server and this is how it looks (uff, now I had a problem to copy/paste this as well as it removed all my new lines from a plain text – in Chrome, so I’m now finishing it in Firefox :-)):

$ telnet xxx 8080
Trying xxx...
Connected to xxx.
Escape character is '^]'.
GET /comasutra/main.seam?cms HTTP/1.1
Host: xxx:8080

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Set-Cookie: JSESSIONID=8727F8532EA49A8FAB7E967245D5F27C; Path=/comasutra
X-Powered-By: JSF/1.2
Content-Type: text/html;charset=UTF-8
Content-Length: 823
Date: Wed, 05 Aug 2009 13:39:07 GMT

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="gwt:property" content="locale=sk" />
<title>Comasutra</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<script type="text/javascript" language="javascript" src="cms/cms.nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex="-1" style="position:absolute;width:0;height:0;border:0"></iframe>
<div class="top">
</div>
<div class="main">
<h1>Main page</h1>
<div>
<h2>Articles</h2>
<div id="cms-c1" class="article-list"></div>
</div>
</div>
</body>
</html>

GET /comasutra/bubu.html?cms HTTP/1.1
Host: xxx:8080

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Set-Cookie: JSESSIONID=650F5FDDED9EC66D0C810B6C2D69B1CC; Path=/comasutra
Accept-Ranges: bytes
ETag: W/"823-1249478709000"
Last-Modified: Wed, 05 Aug 2009 13:25:09 GMT
Content-Type: text/html
Content-Length: 823
Date: Wed, 05 Aug 2009 13:48:29 GMT

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="gwt:property" content="locale=en" />
<title>Comasutra</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<script type="text/javascript" language="javascript" src="cms/cms.nocache.js"></script>
</head>
<body>
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex="-1" style="position:absolute;width:0;height:0;border:0"></iframe>
<div class="top">
</div>
<div class="main">
<h1>Main page</h1>
<div>
<h2>Articles</h2>
<div id="cms-c1" class="article-list"></div>
</div>
</div>
</body>
</html>
Connection to xxx closed by foreign host.

Just to be complete: We use JBoss Seam 2.2.0.CR1, JBoss AS 5.1.0.GA, GWT 1.7, Windows XP SP 3, Google Chrome 2.0.172.39.

Obviously, the first GET request is JSF/Seam one, the other one uses plain HTML. HTMLs are exactly the same, headers are different. I don’t know if subsequent request for “cms/cms.nocache.js” is different, but the whole thing blows out in the JS execution after all. I really don’t know where is the problem. And I’m quite sick to even have a problem like this. Maybe it’s not the Chrome only, maybe it’s the JS engine. Will I have the same trouble with Safari on Mac? I don’t know because I can’t try it any time soon. But in the end there are more little usability problems with Chrome than I expected. I’ll probably give it a try again after some update, but for now I’m switching my default browser back to Firefox. And I’ll probably have to add a note that “this application is not supported in Google Chrome”. I’d be ashamed, but I’m rather pissed off really.

T500 minus, kudos to ZAR

This post is actually immediate continuation of my previous problem – it just took me some time to get to it. 🙂 After all my troubles with wannabe-freewares I got to the ZAR – or Zero Assumption Recovery software. While the software itself is not a freeware it has a free functionality. Luckily for me it was exactly that one I needed – image recovery from raw filesystem. I installed it on aforementioned Lenovo T500 I recently acquired at work and gave it a try. Many pictures were saved but not the ones I needed. Actually very old images were recovered. Than I discovered that whatever I do ZAR always reads only first 3.55 GB of the flash card. “Hm, wait, that’s strange!” One look to the Total Commander – right it reports 8GB card. I don’t know why I checked Windows format utility – but it wanted to format the drive only to 3.55 GB – so obviously ZAR wasn’t the only one “wrong” here.

Long story short. T500 card reader is either faulty or wrong drivers are installed or I don’t know what. I tried to reinstall drivers from Lenovo site, no luck – card was still only 3.55GB. I tried the card in my colleague’s T400 – it worked just fine! (I mean really worked as 8GB, not as it seemingly worked in my computer only to read garbage.) I couldn’t find help on Lenovo forums (yet, but after a few days the post is too low to anyone care) and I actually found out that many people have surprising amount of various problems with something I wanted for the quality. My T500 actually has also tricky fingerprint reader that sometimes gets stuck and reports “too short” swipe every two seconds or so and it’s close to impossible to enter the password. Not to mention very weak USB (I mean my wife’s Asus can power MIDI keyboard and USB audio interface better) – all three of them within 2-3 cm on one side. The computer is not THAT bad – it has actually pretty cool reviews (that affected me in my choice) – but I expected less problems for the money. Now I have notebook that looks solid (“you have a Thinkpad!”), has a nice display (1680×1050 in my case, love that) and… that’s about it. But I didn’t want to write about my disenchantment of the notebook initially.

I wanted to recommend you ZAR in case you need to recover your data from the filesystem! 🙂

And my pictures? I inserted the card into the reader we have on Epson Stylus Photo RX585 and recovered every single image I thought was lost. In addition to this adventure (that ruined one half of my day and made my day afterwards) I found out how pictures are written on the card and that they use all the capacity even when I delete them every time I download them to the computer. I don’t know if it’s FAT feature (never knew about it), I doubt camera can manage it under the filesystem level – and I don’t care really. Important thing is that the card is used nicely considering limited number of write cycles. I know, I know – I wouldn’t reach the limit even if only the first portion of the card was overwritten again and again. I just like it as it is.

Freeware? No, scamware!

I have a bad day today. I pulled SDHC card out of my digital Canon and put it into my Lenovo T500 to move photos on the disk. MOVE. After that I found out that there are some files of various lengths with proper names. But none of them was proper JPEG file. Except one that contained three fourths of some old picture deleted long time ago. In a panic move – those are the worst ones – I copied files back to the card to check them in the camera. No luck. Now I don’t know if they were corrupted before. But my bet is that they had gone wrong somehow before this whole episode happened. I decided to recover any JPEG file on the media on a binary basis. JPEG has its typical header with magic number so maybe, just maybe I’ll find something.

I tried various recovery freeware programs that were simple or lame or whatever. And then I hit Smart Image Recovery – reportedly freeware download. Let’s try it, why not. Uh, the download wants my email to send me the download link (that should be the first warning, I know). Ok, why not, I rely on Gmail spam filter anyway. I downloaded the software and started it. Buy or continue free? What?! How could the word “BUY” find its way into the freeware? Of course I want to continue Free! Ok, paid functions will be disabled. Oh, man, paid functions? You mean you would show me the pictures and I would not be able to recover them, right? (In the end this crappy software found NOTHING on that card although some other free trial found many files – of course, recovery was not for free. :-))

During the scan of the memory card dialog appears: You have some problems in Windows Registry and some temporary files (what a surprise!). Do you want to download our bla-bla cleaning software? You gotta be kidding!!! (I never use multiple exclamation marks, but I just felt like that in that very moment.) This is not freeware at all! I’ll run away if I see anything from Smart PC Solutions (or smartpctools.com) again. I don’t know what “scamware” really means, but it was the first word instead of freeware that came to my mind. Extremely annoying, not giving promised values and I feel safe only thanks to anti-virus solution I wouldn’t dare to turn off. Because you never know. This time it was only annoying software, but what it will be next time?

On-line sa už nehrám, lebo RadioLAN

This time about my online gaming troubles with information useful mostly for people around Bratislava – that’s why it’s in Slovak.

EDIT 2015: Pre aktualizáciu si prečítajte najnovšie komentáre, ktoré vyznievajú pozitívnejšie. 🙂

Počas ostatných rokov som sa dostal k online hraniu – prevažne Unreal Tournament série. Zažil som, čo to je byť súčasťou klanu, zažil som, čo to je dostať prvýkrať neuveriteľný výprask, zistil som, aký obrovský skok v skille človek môže spraviť, keď sa začne stretávať s ľuďmi online. Málokedy som počas tohto obdobia mal dobré sieťové pripojenie – myslím tým dobré na hranie. Pri hraní FPS hier (strieľačky) totiž viac ako inde rozhoduje najmä latencia (ping), až potom samotná rýchlosť pripojenia. Ďalšími faktormi sú kvalita linky (stratené pakety), stálosť pingu (jeho nestálosť spôsobuje veľmi nepríjemne sekanie pohybu – jitter), proste je toho viac a všetky tieto veci sú bežnému smrteľníkovi, ktorý si myslí, že “všetko je na webe”, vlastne úplne ukradnuté. Bol som najprv pripojený Roburom a myslel som si, že to je zlé. Potom som sa presťahoval do vlastného a jedinou možnosťou bola zdieľaná 2Mbit anténa od firmy SWAN. Na streche, pre desiatky bytov – bolo to hrozné. Nakoľko som netušil, že sa k nám chystá doraziť Orange – informovanosť vo vchode bola dosť úbohá – rozhodol som sa po dlhom váhaní k radikálnemu kroku. Vlastná anténa. Nie vlastná ako vlastná, ale anténa len pre náš byt.

Ceny takýchto pripojení už nie sú také vysoké, ale pripojenia ako FiberNet alebo Chello sú dostupné lacnejšie a v oveľa vyšších rýchlostiach. Z možností, ktoré som našiel na internete som sa napokon uchýlil k spoločnosti RadioLAN, začiatok vyzeral sľubne, úspešne ma zamerali, pripojili a spojenie sa tvárilo dobre. Lenže niektoré veci človek nezistí hneď. Prvých pár dní to išlo celkom v pohode, ale víkendové večery nebolo absolútne možné si zahrať. Druhým problémom bolo nepríjemné spomalenie prezerania webu, ak som sťahoval cez Torrenty. Na predchádzajúcich 512kbit od SWANu to tiež bolo nepríjemné, ale paradoxne zďaleka nie tak problematické. Kým u SWANu sme mali pevné verejné IP (čo Torrent klienty celkom vítajú), u RadioLANu nebola možnosť port forwardingu… neviem, či toto spôsobovalo fakt, že sťahovanie sa niekedy ťahalo ako šušne alebo aj to, že torrenty tak agresívne znižovali priepustnosť linky. Sťahovanie stranou, nasledovali pokusy pri všetkých iných sieťových aktivitách vypnutých.

Na radu známeho som si stiahol DU Meter, 30 trial dní mi na moje potreby stačilo (isto existujú aj zadarmové alternatívy), vypol všetko ostatné okrem svojej obľúbenej hry (napr. UT3) a skúšal. Boli prípady, kedy hranie išlo dobre, boli prípady, kedy pingy vyleteli behom pár sekúnd nad maximálnu zobrazovanú hodnotu 999 ms a pohyb po mape sa podobal fantastickej slide-show. Najčastejšie to bolo niečo medzitým – dalo sa ako tak hýbať po mape, ale nedalo sa ani trochu seriózne hrať. Vypol som hru a robil som pokusy so sťahovaním (jeden súbor, z webu). Niekedy išlo krásne celú dobu konštantnou rýchlosťou. Vyberal som si samozrejme zdroje, ktoré nie sú – na rozdiel od môjho pripojenia – obmedzené. Inokedy ten istý download išiel veľmi zvláštne, často aj s pár sekundami bez akéhokoľvek stiahnutého bajtu. Porobil som screenshoty s “dôkazmi” a napísal som zďaleka nie prvý mail adminom do firmy RadioLAN.

Veľmi nerád sa ocitám v pozícii sťažovateľa. Nebaví ma to. Ešte horšie je, že som sa upísal… najmä s ohľadom na cenu zriadenia spojenia až na dva roky. Cena 1Mbit linky pritom nie je taká nízka (800 Sk mesačne). Ak som sa dočkal odpovede, bolo to obligátne “všetko sme otestovali, na linke nie sú problémy”. Ešte častejšie som sa ale odpovede nedočkal. Firmy ako RadioLAN to možno nemajú v Bratislave ľahké – pri množstve wi-fi zariadení, ktoré zahlcujú najmä 2,4GHz pásmo. Ale pre mňa to už seriózna firma nie je. Po dobrom sa s nimi dohodnúť neviem (pokuta 10000 Sk je na môj vkus priveľa) – a tak ma paradoxne “zachránilo” jediné. Že ma UT3 prestalo baviť (v čom nie som spomedzi skalných fanúšikov jediný). Kašlať na to, do februára 2010 to nejak vydržím, budem celý ten čas sťahovať a browsiť a hrať sa off-line. Potom prejdem na FiberNet, ktorý už u nás je, a anténu na svojom balkóne už nebudem chcieť vidieť. Aspoň nie kvôli Internetu.

Najhoršie je, že pripojenie “nejaké” mám – a je veľmi ťažké sa sťažovať na zlé pingy v nedeľu večer. Online hranie nie je, zdá sa, súčasťou štandardu. Môj provider nie je schopný (alebo nechce) odmerať to isté, čo objektívne viem namerať na svojom konci ja. Vravel som si, čo už len môže byť zlé na vlastnej anténe? Teraz to už viem…wi-fi v Bratislave iba ak v inom pásme, ale najlepšie vôbec. K SWANu by som sa určite nevrátil, ale ten Robur by som teraz bral kedykoľvek. Pri všetkých ich zvláštnych špecifikách pobijú spojenie od RadioLANu ľavou zadnou.