<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ITworks</title>
	<atom:link href="http://itworks.hu/feed/" rel="self" type="application/rss+xml" />
	<link>http://itworks.hu</link>
	<description>Blog for the tech-beer attendees</description>
	<lastBuildDate>Wed, 25 Nov 2009 22:04:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Regexp fun</title>
		<link>http://itworks.hu/2009/11/25/regexp-fun/</link>
		<comments>http://itworks.hu/2009/11/25/regexp-fun/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 21:57:31 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=95</guid>
		<description><![CDATA[Reading the post about useful regular expressions,  remembered what my favourite solution is to one of  the questions of the test we give to junior Java developers. The task is to write a method that takes a string as a parameter and returns the acronym of the string in uppercase made up of the first [...]]]></description>
			<content:encoded><![CDATA[<p>Reading the post about<a href="http://www.mkyong.com/regular-expressions/10-java-regular-expression-examples-you-should-know/"> useful regular expressions</a>,  remembered what my favourite solution is to one of  the questions of the test we give to junior Java developers.</p>
<p>The task is to write a method that takes a string as a parameter and returns the acronym of the string in uppercase made up of the first letters of the words in the string. The acronym must ignore the words &#8220;the&#8221;, &#8220;of&#8221; and &#8220;and&#8221;.</p>
<p>The usual solutions are either to sequentially step through the string (Yuck!) or split it up or use a StringTokenizer class. The people usually overlook the fact, that the input strings can be padded with whitespace, or contain multiple spaces, and they usually ignore, that the keywords that are to be omitted might be found on the begining of a valid word. Thus my test &#8221; United   States of Andorra&#8221; string breaks most of the methods.  The ones who have time to write the answer down, usually forget to return the value from the method, or to change it to uppercase and sometimes even ignore that it should be a method to start with! This is my favourite question, as it can really show how the applicant can handle stressful situations.</p>
<p>I was tired after several interviews one day and tried to come up with the  shortest possible solution. Naturally it contains regular expressions.</p>
<p>My solution looked  something like this (OK I just reproduced it for the sake of the article, using nano and javac, so it might have overlooked flaws in it):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Acronym <span style="color: #009900;">&#123;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> toAcronym<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> str.<span style="color: #006633;">toUpperCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.
                        <span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(THE|OF|AND)(<span style="color: #000099; font-weight: bold;">\\</span>W+|$)&quot;</span>,<span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.
                        <span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(<span style="color: #000099; font-weight: bold;">\\</span>w)<span style="color: #000099; font-weight: bold;">\\</span>w*<span style="color: #000099; font-weight: bold;">\\</span>W*&quot;</span>,<span style="color: #0000ff;">&quot;$1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>args.<span style="color: #006633;">length</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>toAcronym<span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/11/25/regexp-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New trends in Linux desktop UIs</title>
		<link>http://itworks.hu/2009/11/24/new-trends-in-linux-desktop-uis/</link>
		<comments>http://itworks.hu/2009/11/24/new-trends-in-linux-desktop-uis/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 21:14:25 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=89</guid>
		<description><![CDATA[As I see there is a solid movement to reform the user interfaces that are in use in our computers. After all the menu bars with a start menu are on the mainstream desktops since the win95/OS2 era. And the programs can be started using icons on the desktop and the start menu. For the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-90" title="win95Menu-Word" src="http://itworks.hu/wp-content/uploads/2009/11/win95Menu-Word-300x231.jpg" alt="win95Menu-Word" width="300" height="231" />As I see there is a solid movement to reform the user interfaces that are in use in our computers. After all the menu bars with a start menu are on the mainstream desktops since the win95/OS2 era. And the programs can be started using icons on the desktop and the start menu. For the ones who know what they are looking for there is also a command line. And there is a task bar to switch your running applications. But things ought to change with time, shouldn&#8217;t they?</p>
<p><span id="more-89"></span>On Linux (Ubuntu) first there was a movement to make things fancier than on Windows. Compiz made a huge visual improvement but has not really changed anything. Having your desktop on a cube and spinning it around is particularly fancy, but not really useful.</p>
<p>Taking the ideas from MacOS X a couple of dock style window navigators popped up. Avant Window Navigator, Cairo Dock or Docky theme of the gnome-do (more about that later) These are really nice looking, but have no added value compared to standard application switcher that I see.</p>
<p><img class="size-medium wp-image-91 alignleft" title="gnome-shell" src="http://itworks.hu/wp-content/uploads/2009/11/gnome-shell-300x187.png" alt="gnome-shell" width="300" height="187" />The path gnome 3.0 is taking is quite different, it completely replaces the taskbar, with a live miniature based desktop switcher. It is activated with a hot-spot for mouse/thouchpad users, or a hotkey (Super) for those who don&#8217;t want to leave the keyboard.  You can switch to running apps with a single click, if unsure which window you want to see, you can use the wheel to zoom on the window before changing.</p>
<p>Personally I like it, and I&#8217;ve been using it on my laptop for weeks now. Why not on my desktop? Well, there is a catch. It requires working 3d acceleration to use. This rules out quite a few cards, all legacy nvidia and ati cards have issues. Basically it&#8217;s only Intel I&#8217;ve heard it works properly. Unfortunately there are no plans to support legacy cards. So for those hardware one will have to switch to icewm or kde based desktops.</p>
<p>There is more to desktop software than switching, after all you must start your applications before switching them. Are there improvements in that over the start menu?</p>
<p>First there is the intelligent start menu you find in Linux SuSe and Mint. It&#8217;s a lot like XP, where the most frequently applications are remembered and the menu provides you with that on opening. This is a change compared to the classic start menu, and is quite helpful. Unless of course you don&#8217;t quite where you find the application you are looking for in the menu. What can help there?</p>
<p>Both the upcoming gnome-shell and the gnome-do add-on provide an excellent, find as you type style interface, this greatly helps you finding the application you might want to start. It is quite basic in gnome-shell yet, and is only useful for finding applications and preferences with names and descriptions containing the characters typed. Gnome-do however is more advanced, it can be extended with plugins, that search in your IM&#8217;s contact list, recent documents, etc. This greatly speeds up application startup. I heard there are plans to integrate the gnome-do capabilities in gnome-do and I really welcome the idea.</p>
<p>On the whole I see the usability of the gnome-shell is the best enhancement in the past few years, and I really hope those wrinkles I meet every day will soon be eliminated.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/11/24/new-trends-in-linux-desktop-uis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brief &#8211; a feed reading extension for Firefox</title>
		<link>http://itworks.hu/2009/09/02/brief-a-feed-reading-extension-for-firefox/</link>
		<comments>http://itworks.hu/2009/09/02/brief-a-feed-reading-extension-for-firefox/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 14:50:04 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=85</guid>
		<description><![CDATA[I read several feeds daily, like The Daily WTF or friend&#8217;s blogs. Since I always have both Thunderbird and Firefox running on my computer, I don&#8217;t want a standalone RSS reader application, like Liferea hog my memory. I don&#8217;t want to keep a Google page always open to use the Reader either. I took some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://brief.mozdev.org/"><img class="alignright" src="http://itworks.hu/wp-content/uploads/2009/09/home-screenshot.png" alt="" /></a>I read several feeds daily, like <a href="http://thedailywtf.com/">The Daily WTF</a> or friend&#8217;s blogs. Since I always have both Thunderbird and Firefox running on my computer, I don&#8217;t want a standalone RSS reader  application, like Liferea hog my memory. I don&#8217;t want to keep a Google page always open to use the Reader either. I took some time to research an RSS reader, which fits these criteria.</p>
<p><span id="more-85"></span>Up until now I used the <a href="http://www.wizzrss.com/Welcome.php">WizRSS</a> plugin, which is a nice Firefox extension, but has no automatic refresh option, and manual refresh disables the browser for long seconds.</p>
<p>I recently realized, that ThunderBird 3.0 already has RSS support built in. Since feeds are a lot like newsletters that would be a convenient place to read my feeds.</p>
<p>There are some issues I have with Thunderbird as an RSS reader.</p>
<ul>
<li>I use two computers in parallel, a desktop and a laptop (I know I&#8217;m old fashioned, but I like 19&#8243; LCDs) The feeds are to be kept in sync on them. (This could be a case for <a href="http://www.cis.upenn.edu/~bcpierce/unison/">Unison</a>, but I rather not restart my mail client every time I go home, otherwise what would be the point of suspend/resume?) Thunderbird doesn&#8217;t have any feed synchronization support, that I know of.</li>
<li>OPML import doesn&#8217;t work. Export works well, but once you want to restore your bookmarks, the folder structure is lost. That&#8217;s probably just a simple bug that the developers will take care of, but for now I have to reorganize all my feeds.</li>
<li>Item display is not very fancy yet, links are opened in your browser. For picassa  feeds this is quite annoying. Once you want to see an image in full size, you must switch over to your browser, and when done switch back.</li>
</ul>
<p>So I looked up other Firefox extensions to see if there is one that fits my needs. That&#8217;s when I found <a href="http://brief.mozdev.org/">Brief</a>. Unlike WizRSS, which keeps the links to the feeds in a separate bookmark folder, that I cannot sync with X-Marks, it uses the Live bookmarks feature of Firefox, and I can easily choose the folder to store the bookmarks in. It allows the feed items to be bookmarked (which is a missing feature in WizRSS) so I can mark articles for later.</p>
<p>I simply imported my bookmarks from OPML, and I haven&#8217;t tried, but export probably works just as well.</p>
<p>Since the embedded links are opened in the frame, I can navigate with the standard browser buttons.</p>
<p>I&#8217;m pretty satisfied with it so far, but let&#8217;s see what the daily use brings!</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/09/02/brief-a-feed-reading-extension-for-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maker&#8217;s Schedule, Manager&#8217;s Schedule</title>
		<link>http://itworks.hu/2009/09/01/makers-schedule-managers-schedule/</link>
		<comments>http://itworks.hu/2009/09/01/makers-schedule-managers-schedule/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 11:00:19 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=83</guid>
		<description><![CDATA[Insightful post about issues in scheduling. Maker&#8217;s Schedule, Manager&#8217;s Schedule.]]></description>
			<content:encoded><![CDATA[<p>Insightful post about issues in scheduling.</p>
<p><a href="http://www.paulgraham.com/makersschedule.html">Maker&#8217;s Schedule, Manager&#8217;s Schedule</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/09/01/makers-schedule-managers-schedule/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wicket in action and confusion</title>
		<link>http://itworks.hu/2009/08/29/wicket-in-action-and-confusion/</link>
		<comments>http://itworks.hu/2009/08/29/wicket-in-action-and-confusion/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 22:53:56 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[annoyance]]></category>
		<category><![CDATA[java security]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[tomcat]]></category>
		<category><![CDATA[wicket]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=68</guid>
		<description><![CDATA[For a recent project lead, we decided to create a mock-up of the application, so the prospective Customer would be able to see that we understand their needs. As I&#8217;m not very good at interactive HTML mock-ups I decided to go with Wicket, which seemed to be useful and easy when a friend showed me. [...]]]></description>
			<content:encoded><![CDATA[<p>For a recent project lead, we decided to create a mock-up of the application, so the prospective Customer would be able to see that we understand their needs.</p>
<p>As I&#8217;m not very good at interactive HTML mock-ups I decided to go with <a href="http://wicket.apache.org/">Wicket</a>, which seemed to be useful and easy when a friend showed me. The mock-up progressed well, but upon deployment all <a href="http://www.microsoft.com">Hell</a> broke loose.</p>
<p><span id="more-68"></span>I chose <a href="http://wicket.apache.org/">Wicket</a>, because I hate most web frameworks already, Struts is way to old and twisted for anything proper, I have not found a single open source JSF implementation that works properly, and I had nothing concrete against <a href="http://wicket.apache.org/">Wicket</a> yet.</p>
<p>I also wanted to try Maven, since I hate it&#8217;s conception so much, it seemed like a good time to try, after all we had two days on our hands, why not waste it properly? I still hate it, but only on principle, otherwise it to me it&#8221;s a lot like the apt of java. And my world is Debian based. <img src='http://itworks.hu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So the mock-up went well. I&#8217;ve spent hours figuring out how to do a simple menu that shows selected items with the &lt;wicket:link&gt; feature, with mouseovers. I managed to get it working, to realize it would never work on IE. Then I reimplemented it, then again. Finally I threw it all away and added a JavaScript onload and some brute-force to get it working.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> fireOnLoad<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// highlight current menu</span>
  <span style="color: #003366; font-weight: bold;">var</span> menuTable <span style="color: #339933;">=</span> window.<span style="color: #660066;">document</span>.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'menuTable'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>menuTable.<span style="color: #660066;">rows</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">cells</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> curM <span style="color: #339933;">=</span> menuTable.<span style="color: #660066;">rows</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">cells</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>curM.<span style="color: #660066;">children</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">tagName</span> <span style="color: #339933;">!=</span><span style="color: #3366CC;">'A'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> curClassName <span style="color: #339933;">=</span> curM.<span style="color: #660066;">className</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'Selected'</span><span style="color: #339933;">;</span>
      curM.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> curClassName <span style="color: #339933;">;</span>
      curM.<span style="color: #660066;">children</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'block'</span><span style="color: #339933;">;</span>
      menuTable.<span style="color: #660066;">rows</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">cells</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'block'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>For the HTML code like</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;table id=&quot;menuTable&quot; class=&quot;menuTable&quot; border=&quot;0&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;subMenuItemContainer&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&quot;subMenuPointer&quot;&gt;
    &lt;img style=&quot;display:none&quot; onclick=&quot;window.location.href='../img/submenu.gif';return false;&quot; src=&quot;../img/submenu.gif&quot; alt=&quot;&quot; /&gt;&lt;/td&gt;
...&lt;/tr&gt;
&lt;tr class=&quot;menuItemContainer&quot;&gt;
&lt;td class=&quot;menuItem&quot; onmouseover=&quot;return menuRollOver(this)&quot; onmouseout=&quot;return menuRollOut(this)&quot;&gt;
&lt;div class=&quot;hiddenSubMenu&quot;&gt;
&lt;ul class=&quot;subMenu&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;../pages/AgencyList&quot;&gt;Keresés&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;a href=&quot;../pages/AgencyList&quot;&gt;Ügynökségek&lt;/a&gt;&lt;/td&gt;
...&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</pre></div></div>

<p>It&#8217;s quite ugly, but adequate for the current situation.</p>
<p>After the pages were ready and tested on localhost I decided to move it to our server for presentation. The server runs Debian and has an Apache Tomcat 5.5 running on it for ages. It turned out however, that somehow the project requires Tomcat 6. Not wanting to go over all the project&#8217;s config, I went for the server upgrade. The Tomcat had no applications that were to be effected, so it seemed like an easy choice.</p>
<p>Install from apt went smoothly, the application deployed easily. There was a strange problem though.</p>
<p>Every time I clicked a link it either didn&#8217;t display any images or it displayed some, or none at all. Refreshing the page always changed something. I suspected, it must be an issue with the <a href="http://wicket.apache.org/">Wicket</a> filter, but could not put my hand on it.</p>
<p>Trying to isolate the problem I tried loading a single image from the application. It turned out, that a security exception is thrown every time I try to reload a resource that was previously loaded. Turning of security in Tomcat packaged for Debian did not work out of the box, so I tried to find a solution. I found the page on Java security in <a href="http://wicket.apache.org/">Wicket</a> but adding the values on the page just resulted in another error.</p>
<p>I decided to add all rules found on the <a href="http://cwiki.apache.org/WICKET/java-security-permissions.html">Wicket WIKI</a>, but that wasn&#8217;t enough. So I was adding the rules one-by-one to come up with my version of the security policy for 1.4</p>
<pre>grant {
// For substitution of one object for another during serialization
// or deserialization. This is used in ReplaceObjectOutputStream,
// which is used for page versioning (undoing changes).
//permission java.io.SerializablePermission "enableSubstitution";

// For FilePageStore's custom serialization
//permission java.io.SerializablePermission "enableSubclassImplementation";

// For crypted URL functionality (see WebRequestWithCryptedUrl).
//permission java.security.SecurityPermission "insertProvider.SunJCE";

// The following was required to get Wicket, at least the examples, to work at all
permission java.lang.reflect.ReflectPermission
   "suppressAccessChecks";
permission java.lang.RuntimePermission
   "accessClassInPackage.org.apache.tomcat.util.http";
permission java.util.PropertyPermission
   "org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE",
   "read";
};</pre>
<p>As it turned out the problem is gone now. At least until I hit another security restriction.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/08/29/wicket-in-action-and-confusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating for a bot for MafiaWars</title>
		<link>http://itworks.hu/2009/08/12/creating-for-a-bot-for-maffiawars/</link>
		<comments>http://itworks.hu/2009/08/12/creating-for-a-bot-for-maffiawars/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 21:54:07 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[macro]]></category>

		<guid isPermaLink="false">http://itworks.hu/2009/08/12/creating-for-a-bot-for-maffiawars-2/</guid>
		<description><![CDATA[I started playing MafiaWars on my last job, where I had time to spare. As it has happened in the past with me playing on a mud, when the game got repetitive I start writing tools to speed things up.When I was on the mud I used macro-enabled clients, like tintin++ to perform simple tasks [...]]]></description>
			<content:encoded><![CDATA[<p>I started playing <a href="http://apps.facebook.com/inthemafia/" target="_blank">MafiaWars</a> on my last job, where I had time to spare. As it has happened in the past with me playing on a mud, when the game got repetitive I start writing tools to speed things up.When I was on the mud I used macro-enabled clients, like <a href="http://tintin.sourceforge.net/" target="_blank">tintin++</a> to perform simple tasks for me. Since   <a href="http://apps.facebook.com/inthemafia/" target="_blank">MafiaWars</a> is a Web 2.0 application, one must emulate a web client, so things are a bit trickier than what one can achieve using a simple wget or shell-script based bot.<br />
<span id="more-41"></span><span style="font-weight: bold;"> Preparations </span></p>
<p>Digging through the Internet I couldn&#8217;t find a decent bot-base that I could use for my experiment. The only traces of bots I found were simple brainless fight bots implemented as <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacros.</a></p>
<p><span style="font-weight: bold;">First steps</span></p>
<p>As it seemed like a good idea at the time, I started by installing <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro plugin</a>, then saving a macro. My first goal was to allow for the bot to fight until it has stamina, then wait until some is regenerated.  I soon discovered that while there is a <code>LOOP</code> command, there is no conditional execution support in the <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro</a> language. Recognizing that not even a simple AI can be exclusively written in <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro</a>&#8216;s own language, I switched over to JavaScript based Macros.</p>
<p>The basic idea of the bot is to extract some data off the rendered screen, then perform some action, then start from the begining.</p>
<p><strong>Bot loop</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> terminated<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Check for termination here</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>terminated<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// Do your logic here</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">// I use throw(0) for forced termination when debugging, and I don't want alerts then</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Logging</strong></p>
<p>To make the bot&#8217;s work auditable, and to provide some help for debugging, I created a few simple logging functions.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> consoleWindow<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * Opens a console window
 *
 * @return the console window handle
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> openConsole<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> ww <span style="color: #339933;">=</span> Components.<span style="color: #660066;">classes</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;@mozilla.org/embedcomp/window-watcher;1&quot;</span><span style="color: #009900;">&#93;</span>
 .<span style="color: #660066;">getService</span><span style="color: #009900;">&#40;</span>Components.<span style="color: #660066;">interfaces</span>.<span style="color: #660066;">nsIWindowWatcher</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow <span style="color: #339933;">=</span> ww.<span style="color: #660066;">openWindow</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;DescriptiveWindowName&quot;</span><span style="color: #339933;">,</span>
 <span style="color: #3366CC;">&quot;width=600,height=300&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #660066;">title</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'MaffiaWars Console'</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;html&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;head&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;title&amp;gt;MaffiaWars Console&amp;lt;/title&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;/head&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;body&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;div id=&quot;status&quot; style=&quot;font-size:10px;width:100%;background-color:red&quot;&amp;gt;Starting up&amp;lt;/div&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;div id=&quot;log&quot; style=&quot;font-size:10px&quot;&amp;gt;&amp;lt;/div&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&amp;lt;/body&amp;gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 setConsoleStatus<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> setConsoleStatus<span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>consoleWindow<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 consoleWindow <span style="color: #339933;">=</span> openConsole<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 statusE <span style="color: #339933;">=</span> consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'status'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 statusE.<span style="color: #660066;">firstChild</span>.<span style="color: #660066;">nodeValue</span><span style="color: #339933;">=</span>content<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * Writes to the console window, if it exists, opens it if it doesn't
 *
 * @param content
 * @return
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> writeConsole<span style="color: #009900;">&#40;</span>content<span style="color: #339933;">,</span>color<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>consoleWindow<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 consoleWindow <span style="color: #339933;">=</span> openConsole<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 logE <span style="color: #339933;">=</span> consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'log'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #003366; font-weight: bold;">var</span> p <span style="color: #339933;">=</span> consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;p&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>color<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #003366; font-weight: bold;">var</span> styleA <span style="color: #339933;">=</span> document.<span style="color: #660066;">createAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 styleA.<span style="color: #660066;">nodeValue</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'background-color:'</span><span style="color: #339933;">+</span>color<span style="color: #339933;">;</span>
 p.<span style="color: #660066;">setAttributeNode</span><span style="color: #009900;">&#40;</span>styleA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 p.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>consoleWindow.<span style="color: #660066;">document</span>.<span style="color: #660066;">createTextNode</span><span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">toDateString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; &quot;</span> <span style="color: #339933;">+</span> d.<span style="color: #660066;">toLocaleTimeString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;: &quot;</span>
 <span style="color: #339933;">+</span> content<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 logE.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span>logE.<span style="color: #660066;">firstChild</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> isConsoleOpen <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">return</span> consoleWindow<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">!</span>consoleWindow.<span style="color: #660066;">closed</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">/**
 * Closes the console window
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> closeConsole<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isConsoleOpen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 consoleWindow.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 consoleWindow<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This implements a simple log window, where you can add new entries with the chosen background color. Since the code is for my own fun, several documentation comments are missing. The window contains two areas, the status area is used to display longer units of work, while the log area displays the logs in reverse order (newest first).</p>
<p>Using the log is pretty straightforward. To set the status you use setConsoleStatus(message) and to add  a new log entry you use the function writeConsole(content,color).The log window is not reused, and the log is not written to file, because I don&#8217;t need it.</p>
<p><strong>Business logic</strong></p>
<p>The business logic of the bot is very simple. It is based on how I actually play the game. The features are implemented in separate functions.</p>
<p>There are some global variables in the script, to store data for workflow based operations. For example the fully mastered job tiers are stored in such a global array.</p>
<p><strong>Completed features</strong></p>
<ul>
<li>Search for and fight opponents with mafias of the same size or smaller, when stamina is available<br />
The function searches the fight screen for the mafia of the smallest size, that is smaller than ours. If found it&#8217;s attacked, if there is no target, the function changes the city and checks the other location for targets.</li>
<li>Going to hospital in NY (I have more money there) when the health is critical</li>
<li>Keeping track of fight results<br />
This feature is not useful for determining opponents yet, as there is no way of identifying the opponents on the Fight screen.</li>
<li>Selling goods in Cuba, then depositing to bank<br />
Selling goods was easier, when all items started with &#8220;Sell&#8230;.&#8221; now there are the corrupt politicians, that are either collected or bought right in the middle. I didn&#8217;t see it introduced, so I thought there was something wrong with the logic&#8230;</li>
<li>Depositing to bank in NY</li>
<li>Doing jobs</li>
<li>Tiers are scanned sequentially to see if there is a job that is available. If the tier is fully mastered, it is stored and is avoided in later searches. The jobs, that are not mastered are checked against the specified requirements (sufficient energy and consumables are available) If there are more jobs that satisfy the requirements the one with most required energy is executed.</li>
<li>Using up energy-packs wisely to get level boosts.<br />
The function considers the amount of energy available, the amount of experience required for the next level, the 25% extra energy from the pack, and a rule-of-thumb multiplyer, to calculate the amount of XP per energy point.</li>
</ul>
<p><span style="font-weight: bold;">Planned features</span></p>
<ul>
<li>Repair and protect buildings in NY, before going to bank</li>
<li>Playing free lotto tickets</li>
<li>Using profile points to boost attack/defense</li>
<li>Identifying job pre-requisites in NY and mark those jobs available despite them  mastered</li>
</ul>
<p><span style="font-weight: bold;">Lessons learned</span></p>
<p><em><span style="font-weight: bold;">JavaScript issues<br />
</span></em></p>
<p>JavaScript has never been the language of my choice. My code probably features really poor practices, there were several things that drove me nuts though.</p>
<p>One of my biggest disappointment in JavaScript, is that it doesn&#8217;t support suspending execution in any way. One can&#8217;t write a simple <code>while(true){}</code> loop, and use a <code>sleep()</code> or <code>yield()</code> function to allow his computer do other things then running the bot. To overcome this issue on Linux I used the <a href="http://cpulimit.sourceforge.net/" target="_blank">cpulimit</a> utility, and ran the browser in a different process than my normal process. In fact I used firefox 3.0, then later firefox 3.6 to run the bot, while using firefox 3.5 as my normal browser. If I was to start again I would be using <a href="http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/" target="_blank">setInterval()</a> and create some kind of heartbeat based finite state machine.</p>
<p>JavaScript doesn&#8217;t allow for code inclusion, which was a surprise for me. I thought I could organize the code properly, into logging, utility and business logic modules. This comes from the browser based nature of JavaScript. Unfortunately modifying the parent document to include the other files is impossible, once you run your script from a plug-in. Maybe it can be worked around, but there is really no need for that on such a pet project.</p>
<p>The other JavaScript issue I had, is that the authors of <a href="http://apps.facebook.com/inthemafia/" target="_blank">MafiaWars</a> used window level variables to store some data, and use that data to dynamically create URL&#8217;s. Thus in order to access the data, that is to be stored in the link I would have to be able to access this data. Unfortunately, I just can&#8217;t. I&#8217;ve tried everything, and even though the variables are visible using <a href="http://getfirebug.com/" target="_blank">FireBug</a> they are inaccessible through the <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro plugin</a>.</p>
<p><em><strong>IMacro issues</strong></em></p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro</a> has issues with stopping running JavaScript macros. Once you close the iMacros tab it says it will terminate the running JavaScript macro, but in fact it&#8217;s only suspended. I had to implement in all the loops I used logic, to terminate the loop on certain conditions, like navigating the window away from FaceBook or closing the log window.</p>
<p>There is a strange feature of the <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro</a>, it seems that stopping the script either normally or through an exception takes almost 2 minutes for the browser to recover. I couldn&#8217;t yet find a reason for this, but it certainly causes problems.</p>
<p>While <a href="https://addons.mozilla.org/en-US/firefox/addon/3863" target="_blank">IMacro plugin</a> is certainly great for simple tasks, invoking it frequently from JavaScript kills it&#8217;s performance. After a while it got so bad, that my stamina was recharging faster, then it was spent! To overcome this issue I reimplemented the simple data extraction functions in JavaScript.</p>
<p>These changes have sped the execution up, and reduced the number of times the browser had to be forcefully restarted.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Extracts the element matching the specified parameters
 *
 * @param tagName
 *            type of tag to look for
 * @param pos
 *            occurrence of the tag matching the search attributes
 * @param attributeTxt
 *            attributes to look for. The attributes are : separated key=value
 *            pairs, where the value is either a quoted string or a regular
 *            expression
 * @return the element matching the search attributes, or null if it's not found
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> extractElement<span style="color: #009900;">&#40;</span>tagName<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> attributeTxt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> attributeA <span style="color: #339933;">=</span> attributeTxt.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> attributes <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>attributeA.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> attributeA<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'='</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">length</span><span style="color: #339933;">!=</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Error extracting attributes from string '</span> <span style="color: #339933;">+</span> attributeTxt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		attributes<span style="color: #009900;">&#91;</span>s<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>s<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	elements <span style="color: #339933;">=</span> content.<span style="color: #660066;">document</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span>tagName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> curPos <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
	outer_loop<span style="color: #339933;">:</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> elementIx<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> elementIx<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>elements.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> elementIx<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> curE <span style="color: #339933;">=</span> elements<span style="color: #009900;">&#91;</span>elementIx<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> attrIx <span style="color: #000066; font-weight: bold;">in</span> attributes<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'!curE.'</span><span style="color: #339933;">+</span>attrIx<span style="color: #339933;">+</span><span style="color: #3366CC;">' ||
				!(curE.'</span><span style="color: #339933;">+</span>attrIx<span style="color: #339933;">+</span><span style="color: #3366CC;">'.match('</span><span style="color: #339933;">+</span>attributes<span style="color: #009900;">&#91;</span>attrIx<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'))'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">continue</span> outer_loop<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		curPos<span style="color: #339933;">++;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>curPos<span style="color: #339933;">==</span>pos<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> curE<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * Extracts the text content from the specified element
 *
 * @param tagName
 * @param pos
 * @param attributeTxt
 * @return text content of the element
 * @see extractElement(tagName, pos, attributeTxt)
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> extractText<span style="color: #009900;">&#40;</span>tagName<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> attributeTxt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> curE <span style="color: #339933;">=</span> extractElement<span style="color: #009900;">&#40;</span>tagName<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> attributeTxt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>curE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Cannot find '</span><span style="color: #339933;">+</span>tagName<span style="color: #339933;">+</span> <span style="color: #3366CC;">' on position '</span> <span style="color: #339933;">+</span> pos
			<span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>attributeTxt<span style="color: #339933;">?</span><span style="color: #3366CC;">' matching '</span><span style="color: #339933;">+</span>attributeTxt<span style="color: #339933;">:</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> curE.<span style="color: #660066;">textContent</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">/**
 * Extracts the html content from the specified element
 *
 * @param tagName
 * @param pos
 * @param attributeTxt
 * @return html content of the element
 * @see extractElement(tagName, pos, attributeTxt)
 */</span>
<span style="color: #003366; font-weight: bold;">function</span> extractHTML<span style="color: #009900;">&#40;</span>tagName<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> attributeTxt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> curE <span style="color: #339933;">=</span> extractElement<span style="color: #009900;">&#40;</span>tagName<span style="color: #339933;">,</span> pos<span style="color: #339933;">,</span> attributeTxt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>curE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Cannot find '</span><span style="color: #339933;">+</span>tagName<span style="color: #339933;">+</span> <span style="color: #3366CC;">' on position '</span> <span style="color: #339933;">+</span> pos
			<span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>attributeTxt<span style="color: #339933;">?</span><span style="color: #3366CC;">' matching '</span><span style="color: #339933;">+</span>attributeTxt<span style="color: #339933;">:</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> curE.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>The complete code</strong></p>
<p>Did I ever say I was to share it?</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/08/12/creating-for-a-bot-for-maffiawars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting VirtualBox on boot</title>
		<link>http://itworks.hu/2009/08/06/starting-virtualbox-on-boot/</link>
		<comments>http://itworks.hu/2009/08/06/starting-virtualbox-on-boot/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 14:13:50 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=36</guid>
		<description><![CDATA[After setting up VirtalBox based virtualization on our server, I needed a way to have it automatically started and stopped whenever the host is restarted. Also it would be for the better if the system was not simply started and stopped, but rather saved and restored when possible. I love scripting, but prefer the easy [...]]]></description>
			<content:encoded><![CDATA[<p>After setting up VirtalBox based virtualization on our server, I needed a way to have it automatically started and stopped whenever the host is restarted.</p>
<p>Also it would be for the better if the system was not simply started and stopped, but rather saved and restored when possible. I love scripting, but prefer the easy way, and since it&#8217;s a problem many have probably already tackled I sniffed around for a while.</p>
<p>There it was, new and shiny <a href="http://vboxtool.sourceforge.net/">tool</a> to make my day!</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/08/06/starting-virtualbox-on-boot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting DB2 instances on boot</title>
		<link>http://itworks.hu/2009/08/06/starting-db2-instances-on-boot/</link>
		<comments>http://itworks.hu/2009/08/06/starting-db2-instances-on-boot/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 08:32:27 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=34</guid>
		<description><![CDATA[After migrating our hosted application to a virtual server I realized, that as usual the system is a &#8220;maintenance free&#8221; Linux, meaning we set it up as it were and left it running for ages without touching it. On the occasion of power failure the applications were started manually. As I don&#8217;t want to restart [...]]]></description>
			<content:encoded><![CDATA[<p>After migrating our hosted application to a virtual server I realized, that as usual the system is a &#8220;maintenance free&#8221; Linux, meaning we set it up as it were and left it running for ages without touching it. On the occasion of power failure the applications were started manually.</p>
<p>As I don&#8217;t want to restart everything by hand, whenever our system is restarted I decided to iron these glitches out. OK, the system is only restarted about twice a year, but I tend to forget to restart things manually, so that&#8217;s the real reason.</p>
<p><span id="more-34"></span>The hosted application runs on a WebSphere Application Server Community Edtition 2.0 (meaning an IBM branded Apache Geronimo 2.0) which had an init script hacked together from an init script originally for Apache Tomcat. Talking about code reuse is one thing, doing it is another. It had a few quirks, like the JAVA_HOME setup, that were easily ironed.</p>
<p>The application stores it&#8217;s data in an IBM DB2 Universal Database 9.5, which performs beautifully by the way. It&#8217;s running on Debian, and was installed using the factory installer, which created the startup scripts as well. However the DB2 instances are not automatically started, and that&#8217;s a problem.</p>
<p>I was going to write a startup script which starts the db using the instance user, but it turned out it&#8217;s easier than that. DB2 instances can be auto started, only they are not created that way. Changing the flag is easy, as documented <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v9//topic/com.ibm.db2.udb.admin.doc/doc/t0004919.htm?resultof=%22%64%62%32%69%61%75%74%6f%22%20">here</a>, you just have to issue the db2auto command for the instance.</p>
<p>The only thing left is to add some script to auto start the VirtualBox instance, and preferably stop it as well on shutdown.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/08/06/starting-db2-instances-on-boot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating from physical to virtual server with pain and tears</title>
		<link>http://itworks.hu/2009/08/05/migrating-from-physical-to-virtual-server-with-pain-and-tears/</link>
		<comments>http://itworks.hu/2009/08/05/migrating-from-physical-to-virtual-server-with-pain-and-tears/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 13:45:39 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[annoyance]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[virtualization]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=28</guid>
		<description><![CDATA[We host the server for a legacy application in our office. Since it&#8217;s more like a favor than a real assignment we don&#8217;t care much about the server. However we had a few network issues lately, so we decided to migrate it to a virtual server running on our hosted server. Also the machine produces [...]]]></description>
			<content:encoded><![CDATA[<p>We host the server for a legacy application in our office. Since it&#8217;s more like a favor than a real assignment we don&#8217;t care much about the server. However we had a few network issues lately, so we decided to migrate it to a virtual server running on our hosted server. Also the machine produces lot&#8217;s of heat and noise, so we&#8217;d better had it switched off.</p>
<p>This seemed like such an easy task to do, what could be hard in creating a disk image with <a href="http://clonezilla.org/">CloneZilla</a>, copy it to a server, set up a virtual machine there with <a href="http://www.linux-kvm.org/">kvm</a>, restore the image and redirect all traffic to this computer instead of the one in our office. We estimated it could be done in two to three hours tops, and we get home around 7PM.</p>
<p><span id="more-28"></span>We missed a few points though. The machine had a faulty CD drive, so booting <a href="http://clonezilla.org/">CloneZilla</a> was not so easy. We went for the network boot option, but something just didn&#8217;t work out on the PXE boot. So we switched the CD drive to a working one, well at least it used to work a few years ago&#8230; But not anymore. So we decided to scrap the swap partition boot <a href="http://clonezilla.org/">CloneZilla</a> from there, and create our image. It worked! Almost. Except that <a href="http://clonezilla.org/">CloneZilla</a> didn&#8217;t quite identify the disk partition types, and didn&#8217;t see the RAID device at all. It turned out, that the utility somehow runs in user mode and starting the partimage utility with sudo is an acceptable workaround. We then had the disk image on a different server, where we tried to restore it into a 10GB virtual disk image. As it turns out, <a href="http://clonezilla.org/">CloneZilla</a> is unable to restore images that are bigger then the target partition even if there is less data in it.</p>
<p>So we went on a quest for a <a href="http://www.gnu.org/software/parted/">parted</a> that can shrink our 100GB partition to 10GB. Well, if there was one&#8230; As we had no intention of booting from the non-working CD we popped in a disk from our jukebox server with Ubuntu on it. No wonder it worked flawlessly, until I learned that a RAID 1 device with ext3 on it is not easy to shrink. So I decided to break the RAID block, remove the incompatible ext3 flags, and resize the first partition to 10GB. Then I used partimage to create the backup, it was created with about 300MB/min.</p>
<p>The backup was quickly copied over to the eagerly waiting server, that was to host the virtual machine. We fired up the VM with a 10GB disk image and <a href="http://clonezilla.org/">CloneZilla</a> iso mounted as a CD, and went out to restore the image to our partition. We didn&#8217;t even try to use the <a href="http://clonezilla.org/">CloneZilla</a> UI, except for mounting the host with sshfs to access our backup image. The setup was a breeze, except, that the restore speed was only about 50MB/min. No worries, it&#8217;s a small application after all, we don&#8217;t need a huge server for it anyway. It was also 1 AM already, so we didn&#8217;t pay much attention to detail anymore.</p>
<p>We redirected all the network traffic, to the new virtual interface and tested it while waiting for the restore to complete. During redirect, we fired a command, that killed the network adapter under us, so we were desperately trying to reach the hosting provider, to reboot our server. We went through all numbers listed on their homepage. Good thing they have a <a href="http://cam03.deninet.hu:8080/view/view.shtml">webcam</a> in their console room, so we could see the admin passing through on the way to our server, obviously not in a good mood! Suffice to say that was the most fun we had all evening!</p>
<p>After the restore was complete and some minor fixes (make the image bootable, install the grub loader, change the root device in the loader AND the fstab as well, change network configuration, to match the setup, AND the /etc/hosts AND /etc/resolv.conf, that are easily overlooked at 3 in the morning) we had the image booting up already. And oh boy, was it slow? Painfully so! The machine doesn&#8217;t support HW virtualization, and SW virtualization just doesn&#8217;t cut it.</p>
<p>So we grit our teeth and moved the whole bunch of stuff back to where it was, rebuilt the RAID array, and redirected everything where it was originally. Also we were not happy at all. We went home at 4 AM, when the streets are empty, and the bars were about to close.</p>
<p>I could not believe, that a P4 running at 3GHz should be so slow. So today I took the backup from yesterday, installed <a href="http://www.virtualbox.org/">VirtualBox</a>, and restored the image to a new virtual machine. It took about 2 hours altogether. I&#8217;m not saying that <a href="http://www.virtualbox.org/">VirtualBox</a> is in any way superior to <a href="http://www.linux-kvm.org/">kvm</a>, but I can show that in our case it&#8217;s ten times as fast. I&#8217;m sure we made mistakes in the deployment and there might be ways to reach this speed with <a href="http://www.linux-kvm.org/">kvm</a> as well.</p>
<p>No matter how much trouble we went through, it was sure an interesting night, we learned a lot about virtualization and image cloning, that might soon become handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2009/08/05/migrating-from-physical-to-virtual-server-with-pain-and-tears/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using JAX-WS without code generation</title>
		<link>http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/</link>
		<comments>http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 21:58:41 +0000</pubDate>
		<dc:creator>csak</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[axis2]]></category>
		<category><![CDATA[Geronimo]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JAX-WS]]></category>
		<category><![CDATA[web-service]]></category>
		<category><![CDATA[WebSphere]]></category>

		<guid isPermaLink="false">http://itworks.hu/?p=24</guid>
		<description><![CDATA[Something gave me the weird idea to try the new features of JAX-WS on a current project. The main idea was, to get rid of the code generators that must be ran whenever some minor change is done in the web service. So instead of designing the WSDL along with the matching schema definition for [...]]]></description>
			<content:encoded><![CDATA[<p>Something gave me the weird idea to try the new features of JAX-WS on a current project. The main idea was, to get rid of the code generators that must be ran whenever some minor change is done in the web service.</p>
<p>So instead of designing the WSDL along with the matching schema definition for the connector classes, I decided to start of by designing the interfaces and the connector classes, then just create the implementation with the corresponding annotations on the server side, that will be deployed automatically. The WSDL is generated from the annotations and the connector classes, there is no need to write them manually.</p>
<p><span id="more-24"></span>Take the following example. The web service has a simple method to query a list of items, that can throw a simple exception when the database is unreachable.</p>
<pre>import java.util.List;

import dummy.ws.type.Item;

public interface ItemService {
    public List&lt;Item&gt; getItemList() throws ItemException;
}</pre>
<p>with the implementation example like:</p>
<pre>import java.util.List;

import dummy.ws.type.Item;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(serviceName = "ItemService", targetNamespace = "http://dummy/ws", portName = "ItemPortType")
public class ItemServiceImpl implements ItemService {
    @WebMethod
    public List&lt;Item&gt; getItemList() throws ItemException {
        // <strong>TODO</strong> implementation comes here
    }
}</pre>
<p>can be invoked with the following simple code</p>
<pre>...
    Service service = Service.create(new URL(URLBASE
                     + "/ItemService?wsdl"), new QName(
                     "http://dummy/ws", "ItemService"));
    ItemService itemService = service.getPort(new QName(
                             "http://dummy/ws", "itemPortType"),
                             ItemService.class);
    List&lt;Item&gt; itemList = itemService.getItemList();
...</pre>
<p>There are several problems with this, even though it would be great to have it working right away. It could actually work, if there were no Collections involved on the return value. So creating a simple wrapper class for the return value like:</p>
<pre>package dummy.ws.types;</pre>
<pre>import java.util.List;

public class ItemList {</pre>
<pre>        private List&lt;Item&gt; content;
        public ItemList() {
        }</pre>
<pre>        public ItemList(List&lt;Item&gt; content) {
               this.content = content;
       }</pre>
<pre>        public List&lt;Item&gt; getContent() {
                return content;
        }

        public void setContent(List&lt;Item&gt; content) {
                this.content = content;
        }
}</pre>
<p>along with the modification of the interface and of course the implementation to use the newly created class should break the ice.</p>
<p>There is another shortcoming to this method yet. The thrown exception must contain a constructor with (String, Object) parameters, and an Object getFaultInfo method. Took me quite a time to figure it out, as there is a huge gap in the documentation when you try this. Once you&#8217;ve done that you are ready to deploy.</p>
<p>In the project we are using WebSphere Application Server Community Edition, which is an Apache Geronimo based quite stable and fast server. The WAS CE uses Axis2 for web service implementation. The rich client we implemented used the latest Axis2 libs.</p>
<p>The whole thing worked well until the middle of the project, when all of a sudden, without any major change that we could trace, the client suddenly started throwing JAXB exceptions (classname nor any of its super class is known to this context). This could only be cured by creating the jaxb.index in the ws.types package with all the connector classnames listed in it, along with an ObjectFactory that has a XXX createXXX () method for each ws.type class. Intrestingly however this class, while mandatory is never touched by the code, the class is not even loaded!</p>
<p>On the whole this approach provided a really quick and a bit dirty way of using the web services in a single project. However I would not dare to use it on a bigger scale. I still consider starting from the WSDL and the schema, then generating the interfaces and the connector classes from them the best approach.</p>
]]></content:encoded>
			<wfw:commentRss>http://itworks.hu/2008/08/05/using-jax-ws-without-code-generation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
