<?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>Gerbrand on ICT &#187; Technology</title>
	<atom:link href="http://www.gerbrand-ict.nl/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gerbrand-ict.nl</link>
	<description>Weblog on JEE and software-engineering</description>
	<lastBuildDate>Tue, 18 Oct 2011 14:10:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Databases on SSD</title>
		<link>http://www.gerbrand-ict.nl/2011/10/databases-on-ssd/</link>
		<comments>http://www.gerbrand-ict.nl/2011/10/databases-on-ssd/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 18:34:47 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=574</guid>
		<description><![CDATA[SSD disk are becoming increasingly popular. As they read faster, you might consider running databases such as Oracle DBMS, MySQL or non-sql databases. However, interestingly, originally databases are optimized for tradition hard drives with spinning disks: most importantly: data is read in small chunks, and sequential reads are faster than random reads. I can&#8217;t remember [...]]]></description>
			<content:encoded><![CDATA[<p>SSD disk are becoming increasingly popular. As they read faster, you might consider running databases such as Oracle DBMS, MySQL or non-sql databases. However, interestingly, originally databases are optimized for tradition hard drives with spinning disks: most importantly: data is read in small chunks, and sequential reads are faster than random reads. I can&#8217;t remember everything anymore, but I do remember doing calculations on various reading/writing algorithms during my university days.<br />
For SSD&#8217;s this model doesn&#8217;t hold anymore: this blog posting shortly explains why: <a href="http://www.acunu.com/blogs/irit-katriel/theoretical-model-writes-ssds/">Why theory fails for SSDs</a> There&#8217;s no difference, if I understand correctly between random reads and sequential reads. However writes are much slower. Also SSD&#8217;s have to calculate the physical address for every different read or write access. Meaning if you read a different part of the disk continuously, this will be slower then reading in the same pattern again and again.</p>
<p>Of course the theory doesn&#8217;t fail, but it just doesn&#8217;t apply to SSD <img src='http://www.gerbrand-ict.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2011/10/databases-on-ssd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenID from my website</title>
		<link>http://www.gerbrand-ict.nl/2011/06/openid-from-my-website/</link>
		<comments>http://www.gerbrand-ict.nl/2011/06/openid-from-my-website/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 08:07:03 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=558</guid>
		<description><![CDATA[A lot of websites now provide a way to authenticate yourself via OpenID. That way, you don&#8217;t have to remember a separate username and password to login to such a website, while still being secure. The only challenge in using openid is remembering your openid URL, because there are quite a few possible openid providers. [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of websites now provide a way to authenticate yourself via <a href="http://openid.net/">OpenID</a>. That way, you don&#8217;t have to remember a separate username and password to login to such a website, while still being secure.<br />
The only challenge in using openid is remembering your openid URL, because there are quite a few possible openid providers. I currently can choose from (amongst others) <a href="http://code.google.com/intl/nl/apis/accounts/docs/OpenID.html">Google</a>, <a href="http://www.yahoo.com">Yahoo</a>, <a href="http://mijnopenid.nl/">mijnopenid.nl</a>, <a href="http://www.gerbrand-ict.nl/2009/04/hyves-now-also-openid-provider/">hyves.nl</a> and quite a few others. Instead of remembering the username/password you have to remember which openid provider you&#8217;ve used for what account &#8211; which I think is the reason other authentication mechanism as <a href="http://developers.facebook.com/blog/post/108/">facebook&#8217;s connect a</a>re becoming more popular. I&#8217;ll write about that later, in this page I just want to explain how I made my homepage, http://www.gerbrand-ict.nl an openid provider.<br />
Very simple:</p>
<ul>
<li>My homepage is running <a href="http://wordpress.org/">WordPress</a>, a popular open source weblog.</li>
<li>There are a lot of plugins for WordPress, of which one is the openid plugin. By going to the administration screen and then to the section plugins, you can install the openid plugin easily by entering openid in the search box.</li>
<li>After installation, setup a default account.</li>
<li>Now I can authenticate myself to any site that uses openid, by just entering http://www.gerbrand-ict.nl !</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2011/06/openid-from-my-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wicket Exception when using wrong order in addComponent</title>
		<link>http://www.gerbrand-ict.nl/2011/02/wicket-exception-when-using-wrong-order-in-addcomponent/</link>
		<comments>http://www.gerbrand-ict.nl/2011/02/wicket-exception-when-using-wrong-order-in-addcomponent/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 16:19:01 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[wicket]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=467</guid>
		<description><![CDATA[Today I working on a application that uses the Wicket framework. I was plagued with the following Exception: WicketMessage: org.apache.wicket.WicketRuntimeException: component myForm:myTable:editor not found on page nl.gerbrand-ict.gui.HomePage[id = 4], listener interface = [RequestListenerInterface name=IActivePageBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()] Root cause: ... In place of the &#8230; there was a full stacktrace, which information that&#8217;s not [...]]]></description>
			<content:encoded><![CDATA[<p>Today I working on a application that uses the <a href="http://wicket.apache.org/">Wicket framework</a>. I was plagued with the following Exception:</p>
<pre>WicketMessage: org.apache.wicket.WicketRuntimeException: component myForm:myTable:editor not found on page nl.gerbrand-ict.gui.HomePage[id = 4], listener interface = [RequestListenerInterface name=IActivePageBehaviorListener, method=public abstract void org.apache.wicket.behavior.IBehaviorListener.onRequest()]

Root cause:

...</pre>
<p>In place of the &#8230; there was a full stacktrace, which information that&#8217;s not not relevant for this posting.</p>
<p>Turned out the solution was pretty simple, but the cause isn&#8217;t that easy to find and is quite a good example how some design decisions in Wicket aren&#8217;t considered as clean.</p>
<p><span id="more-467"></span></p>
<p>I&#8217;m using Ajax-features of Wicket extensively.<br />
I was creating a table, which contained editable fields (AjaxEdiableLabel). This would allow the user to click on a field in the table, to edit the content.<br />
Somewhere I had the following code:</p>
<pre>target.addComponent(item);
if .. needed .. {
target.addComponent(myTable.this);
... make item invisible
}
super.onSubmit(target);</pre>
<p>The super.onSubmit belonged, in this case, to AjaxEditableLabel. I found out the super.onSubmit() would call <em>target.addComponent(this);</em> to update the editable label itself. As you could see, in my code I&#8217;m telling wicket to update the component that&#8217;s the parent of the editable label also.</p>
<p>In this case, the code caused wicket to first update the parent-panel, which in this case makes the child-component invisible. Then the wicket tries to redraw the child-component, which is then invisible. That will trigger the above error.<br />
Unfortunately, solving this error isn&#8217;t quite easy in all cases. Especially when you&#8217;d use a AjaxSelfUpdatingBehaviour you can have little control on the redrawing order.</p>
<p>Fortunately I found <a href="http://apache-wicket.1842946.n4.nabble.com/WicketRuntimeException-component-not-found-on-page-td3055902.html">a good tip on the wicket mailing list</a> to get rid of the exception. Add the following code your Wicketapplication class (the class that extends org.apache.wicket.protocol.http.WebApplication):</p>
<pre>    @Override
    protected IRequestCycleProcessor newRequestCycleProcessor() {
    	//Tip from http://apache-wicket.1842946.n4.nabble.com/WicketRuntimeException-component-not-found-on-page-td3055902.html
    	return new WebRequestCycleProcessor(){
    		public IRequestTarget resolve(final RequestCycle requestCycle,
    				final RequestParameters requestParameters) {
    	        try {
    	            return super.resolve(requestCycle, requestParameters);
    	        } catch (InvalidUrlException e) {
    	            if (requestCycle.getRequest().getURL().contains("LinkListener") || requestCycle.getRequest().getURL().contains("BehaviorListener")) {
    	            	log.warn("Couldn't process event, is ignored because of: "+e.getMessage());
                        //ignore exception
    	                return new PageRequestTarget(requestCycle.getRequest().getPage());
    	            } else {
                        //normal operation
    	            	throw e;
    	            }
    	        }
    	    }

    	};
    }</pre>
<p>The above code will ignore all of the exception that occur when wicket tries to do something with an component that&#8217;s no longer available because of an ajax-update. Of course this fix isn&#8217;t very nice, hopefully later versions of Wicket fix the error all-together when Ajax-support is improved. For now, this seems the best solution.</p>
<p><script type="text/javascript">// <![CDATA[
var bol_pml={"id":"bol_1298467075904","secure":false,"baseUrl":"partnerprogramma.bol.com","urlPrefix":"http://aai.bol.com/aai","productId":"productid=1001004006005258&#038;","site_id":"2396","target":false,"rating":true,"price":true,"link_name":"Gerbrand-ICT","link_subid":"","image_size":true,"image_position":"left","width":"250","cols":"1","background_color":"#FFFFFF","text_color":"#CB0100","link_color":"#0000FF","border_color":"#D2D2D2","letter_type":"verdana","letter_size":"11"};
// ]]&gt;</script><script id="bol_1298467075904" src="http://partnerprogramma.bol.com/partner/static/js/aai/clientProductlink.js" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2011/02/wicket-exception-when-using-wrong-order-in-addcomponent/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enabling accesskeys for javascript events</title>
		<link>http://www.gerbrand-ict.nl/2010/12/enabling-accesskeys-for-general-html-elements/</link>
		<comments>http://www.gerbrand-ict.nl/2010/12/enabling-accesskeys-for-general-html-elements/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 16:48:43 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[wicket]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=478</guid>
		<description><![CDATA[Using the accesskey attribute, you can enable hotkeys for various html input elements. This allows one to get the focus to an input element by using the ALT-key + &#60;CHARACTER&#62; (on Windows) or CTRL-key + &#60;CHARACTER&#62; (on Mac). This way, your page is accessible by keyboards besides mouse. Here&#8217;s the example taken from the Mozilla [...]]]></description>
			<content:encoded><![CDATA[<p>Using the <a href="https://developer.mozilla.org/en/XUL/Attribute/accesskey">accesskey</a> attribute, you can enable hotkeys for various html input elements. This allows one to get the focus to an input element by using the ALT-key + &lt;CHARACTER&gt; (on Windows) or CTRL-key + &lt;CHARACTER&gt; (on Mac). This way, your page is accessible by keyboards besides mouse.</p>
<p>Here&#8217;s the example taken from the Mozilla DevCenter:</p>
<pre>  &lt;label value="Enter Name" accesskey="e" control="myName"/&gt;
  &lt;textbox id="myName"/&gt;
  &lt;button label="Cancel" accesskey="n"/&gt;
  &lt;button label="Ok" accesskey="O"/&gt;</pre>
<p>Both buttons as well as the input box can be accessed by ALT+E, ALT+N, ALT+O on Windows or CTRL+E, CTRL+N or CTRL+O on a Apple-Mac.</p>
<p>This is quite easy to program, and works for all popular browsers (including Internet Explorer, Safari or Firefox).<br />
There might be cases where you want to execute some javascript when an accesskey is hit, for example to fire a java-event. Almost all webapplications use javascript one way or another. Fortunately, you don&#8217;t not complitated key-event-handling javascript to do that, just use an empty link:</p>
<pre>&lt;a href="#" accesskey="y" onclick="some javascript"&gt; &lt;/a&gt;</pre>
<p>The javascript is executed when the acesskey is hit, this case an ALT+y on Windows. The link is not displayed, so you&#8217;re free wetter or not to display a button, link or anything within your web-application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/12/enabling-accesskeys-for-general-html-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating an ear with version for Weblogic using Maven</title>
		<link>http://www.gerbrand-ict.nl/2010/11/creating-an-ear-with-version-for-weblogic-using-maven/</link>
		<comments>http://www.gerbrand-ict.nl/2010/11/creating-an-ear-with-version-for-weblogic-using-maven/#comments</comments>
		<pubDate>Fri, 12 Nov 2010 10:35:28 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=471</guid>
		<description><![CDATA[Using the ear plugin of Maven 2 creating an ear is very easy. The produced ear follows the JEE spec, so you can normally use it in any application server. I&#8217;m using the ear plugin as well, in my case to be used for Weblogic 9. Weblogic has a feature that allows you to update [...]]]></description>
			<content:encoded><![CDATA[<p>Using the <a href="http://maven.apache.org/plugins/maven-ear-plugin/">ear plugin</a> of Maven 2 creating an ear is very easy. The produced ear follows the JEE spec, so you can normally use it in any application server.<br />
I&#8217;m using the ear plugin as well, in my case to be used for Weblogic 9. Weblogic has a feature that allows you to update applications on the fly using the Deployments, update command. However, to be able to use that feature well, the MANIFEST file of the ear has to include a Weblogic specific version field called <em>WebLogic-Application-Version</em>, with a unique version for each ear you&#8217;d want to include. Without the version number, Weblogic will list the application twice in the weblogic administration console.</p>
<p><span id="more-471"></span> Adding a custom manifest entry is quite easy. Just add an entry to the configuration of the Maven 2 ear plugin, as shown in the example below:</p>
<pre>&lt;plugin&gt;
&lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;archive&gt;
&lt;manifestEntries&gt;
&lt;WebLogic-Application-Version&gt;${project.version}&lt;/WebLogic-Application-Version&gt;
&lt;/manifestEntries&gt;
&lt;/archive&gt;
...
&lt;/plugin&gt;</pre>
<p>This will cause the Manifest file to contain an entry WebLogic-Application-Version containing the current version of your Maven project.<br />
However, this wasn&#8217;t enough for me: I&#8217;m sometimes modifying and recreating the ear multiple times per day during development. The maven project version remains the same, which means Weblogic won&#8217;t see my new development ear as a new version.<br />
The solution is to include a timestamp in the version as well. By default, Maven doesn&#8217;t include a timestamp. Fortunately there&#8217;s <a href="http://stackoverflow.com/questions/1224359/how-do-i-add-time-stamp-information-to-maven-artifacts">Stackoverflow</a> with the answer: there&#8217;s an external plugin called <a href="http://mojo.codehaus.org/buildnumber-maven-plugin/index.html">buildnumber-maven-plugin</a> that allows you do that.<br />
For my weblogic specific entry I added the following to the pom.xml file:</p>
<pre>&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
&lt;artifactId&gt;buildnumber-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;1.0-beta-3&lt;/version&gt;
&lt;configuration&gt;
&lt;format&gt;{0,date,yyyyMMddHHmmss}&lt;/format&gt;
&lt;items&gt;
&lt;item&gt;timestamp&lt;/item&gt;
&lt;/items&gt;
&lt;/configuration&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;phase&gt;validate&lt;/phase&gt;
&lt;goals&gt;
&lt;goal&gt;create&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;</pre>
<p>The above entry will make a variable buildNumber available during build containing a timestamp.<br />
The maven ear configuration becomes:</p>
<pre>&lt;plugin&gt;
&lt;artifactId&gt;maven-ear-plugin&lt;/artifactId&gt;
&lt;configuration&gt;
&lt;archive&gt;
&lt;manifestEntries&gt;
&lt;!-- Buildnumber property is generated by buildnumber-maven-plugin,
see above --&gt;
&lt;WebLogic-Application-Version&gt;${project.version}_${buildNumber}&lt;/WebLogic-Application-Version&gt;
&lt;/manifestEntries&gt;
&lt;/archive&gt;
...
&lt;/plugin&gt;</pre>
<p>After installation in Weblogic using the admin console, weblogic now lists the version number, date and time after I install my ear. Upgrading the application won&#8217;t result in two applications being listed.</p>
<p>﻿﻿﻿﻿</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/11/creating-an-ear-with-version-for-weblogic-using-maven/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Stuff to research: JDO on Cassandra, GIT on Windows, Restlet, VMForce</title>
		<link>http://www.gerbrand-ict.nl/2010/07/stuff-to-research-jdo-on-cassandra-git-on-windows-restlet-vmforce/</link>
		<comments>http://www.gerbrand-ict.nl/2010/07/stuff-to-research-jdo-on-cassandra-git-on-windows-restlet-vmforce/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 22:15:13 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=452</guid>
		<description><![CDATA[Just had evening of just trying out stuff and not finishing anything on my Windows machine. I wanted to try out a persistence API for Cassandra. There&#8217;s a JPA implementation for Cassandra: Kundera, as well as JDO implementation, on top (or using) datanucleus: datanucleus-cassandra. Just to clarify why I would want such a thing: nosql [...]]]></description>
			<content:encoded><![CDATA[<p>Just had evening of just trying out stuff and not finishing anything on my Windows machine.</p>
<p>I wanted to try out a persistence API for <a href="http://cassandra.apache.org/">Cassandra</a>. There&#8217;s a JPA implementation for Cassandra: <a href="http://anismiles.wordpress.com/2010/06/30/kundera-knight-in-the-shining-armor/">Kundera</a>, as well as JDO implementation, on top (or using) datanucleus: <a href="http://github.com/PedroGomes/datanucleus-cassandra">datanucleus-cassandra</a>.</p>
<p><span id="more-452"></span></p>
<p>Just to clarify why I would want such a thing: <strong>nosql </strong>solutions such as Cassandra are, in essence distributed key-value stores. I know, from following a few classes on databases and distributed databases when attending the university that&#8217;s a whole lot more complicated to implement then it may seem.<br />
Nevertheless, to do anything useful with that you need a layer on top of the key-value store. Basically all SQL databases like Oracle or MySQL have SQL layer around there key-value store. But the nice thing about stuff like Cassandra you can put something more convenient on top.</p>
<p>I wanted to try out both, starting with the JDO version, as that seemed  more like a natural fit, and I once started ORM with JDO 1.0 many years  ago.<br />
I&#8217;d need a git client on Windows, and apparently there&#8217;s already a <a href="http://code.google.com/p/tortoisegit/">Tortoise Git client</a>, based on the truly great <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a>, on of the tools I really miss on my Mac. The client version of git first had to be installed, but that was quite easy as well, just download and install <a href="http://code.google.com/p/msysgit/">msysgit</a>.<br />
The tortoisegit client looks very well, and seems easy to use. At least I got the code of datanucleus-cassandra in a breeze. Well now it&#8217;s kind of late, I&#8217;ll try out later.</p>
<p><a href="http://commons.wikimedia.org/wiki/File:Hector_Cassandra_Pomarici_Santomasi.jpg"><img class="alignnone size-medium wp-image-456" title="541px-Hector_Cassandra_Pomarici_Santomasi" src="http://www.gerbrand-ict.nl/wp-content/uploads/2010/07/541px-Hector_Cassandra_Pomarici_Santomasi-270x300.jpg" alt="" width="270" height="300" /></a></p>
<p>Other stuff I want to try out: creating a Rest service using <a href="http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet.html">Restlet </a>on Google AppEngine. Just to find out how that works. But later.</p>
<p>Finally I saw a demo on <a href="http://www.vmforce.com/">VMForce</a>. Looks very promising, as I like Spring for development and that&#8217;s what you&#8217;d use. Nothing is released however, now there&#8217;s just articles and a demo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/07/stuff-to-research-jdo-on-cassandra-git-on-windows-restlet-vmforce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database upgrade during deployment</title>
		<link>http://www.gerbrand-ict.nl/2010/07/database-upgrade-during-deployment/</link>
		<comments>http://www.gerbrand-ict.nl/2010/07/database-upgrade-during-deployment/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 15:33:18 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=446</guid>
		<description><![CDATA[I want to create an installation package of a Java application. Part of the installation involves upgrading a SQL database (Oracle) &#8211; by running a few SQL scripts. Creating the SQL scripts to do the update by itself isn&#8217;t the problem, however I need to find a way to easily run those script. Of course [...]]]></description>
			<content:encoded><![CDATA[<p>I  want to create an installation package of a Java application. Part of  the installation involves upgrading a SQL database (Oracle) &#8211; by running  a few SQL scripts. Creating the SQL scripts to do the update by itself  isn&#8217;t the problem, however I need to find a way to easily run those  script.</p>
<p>Of  course Oracle has something like SQLPlus, but that would mean SQLPlus  has to be installed on the machine from where the package is installed.  Another problem with SQLPlus is that it&#8217;s not so userfriendly.</p>
<p>Using  JDBC and some programming I can easily create something that would  check what current version of my application is installed, and then run  the needed SQL scripts to upgrade the database. However, even easy  things take some time and I&#8217;d think there are already some existing  solutions.</p>
<p>I  was about to ask a question on stackoverflow, but before I finished  typing my question stackoverflow already came up with a similar  question: <a href="http://stackoverflow.com/questions/109746/update-a-backend-database-on-software-update-with-java">Update a backend database on software update with Java</a>. I&#8217;ll have to try out on of the suggested solutions, <a rel="nofollow" href="http://www.liquibase.org/">Liquibase</a>, <a rel="nofollow" href="http://code.google.com/p/dbmigrate/">dbmigrate</a> and maybe <a rel="nofollow" href="http://autopatch.sourceforge.net/">Autopatch</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/07/database-upgrade-during-deployment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proxying authentication using JBoss</title>
		<link>http://www.gerbrand-ict.nl/2010/06/proxying-authentication-using-jboss/</link>
		<comments>http://www.gerbrand-ict.nl/2010/06/proxying-authentication-using-jboss/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 23:00:19 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=264</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice if the connection to the database is done using the same username as the username used to login to a (JEE) application? Oracle has a solution for that: proxy authentication.  When using proxy authentication, every application user is also a database user: meaning when someone logins to your JEE webapplication using [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice if the connection to the database is done using the same username as the username used to login to a (JEE) application? Oracle has a solution for that: <a href="http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/proxya.htm">proxy authentication</a>.  When using proxy authentication, every application user is also a database user: meaning when someone logins to your JEE webapplication using username john, he&#8217;ll also access the database as user john. This way all actions of the user are logged at the database-level: an administrator or auditer can see exactly what data a certain user modified or accessed during a JEE session.</p>
<p><span id="more-264"></span></p>
<p>Also, this allows for fine-grained security at database level: <a href="http://www.oracle.com/technology/deploy/security/database-security-10g/virtual-private-database/index.html">Virtual Private Database</a>.</p>
<div id="attachment_297" class="wp-caption alignnone" style="width: 466px"><a href="http://www.oracle.com/technology/deploy/security/database-security-10g/virtual-private-database/index.html"><img class="size-full wp-image-297" title="virtual-private-database1" src="http://www.gerbrand-ict.nl/wp-content/uploads/2009/06/virtual-private-database1.gif" alt="Virtual private database" width="456" height="175" /></a><p class="wp-caption-text">(c) Oracle</p></div>
<p>As described in the above image and referenced article, the user identified by userid 106 (let&#8217;s say that&#8217;s user john) will access the database using a private database connection. The user can only access rows that have that userid as primary or foreign key.  John can&#8217;t see the passwords, orders, credit card data or anything of other users even if he would somehow hack the webapplication. How to set up this finegrained securiy is beyond this article, but I hope the above example explains what the purpose VPD is.</p>
<p>If you develop your JEE software using Oracle software  proxy authentication requires only a bit of configuration, for example, see the following article how to setup proxy authentication using <a href="http://blogs.oracle.com/jheadstart/2008/01/28/">JHeadstart</a>.</p>
<p>However, what if you&#8217;re JEE applicication consists of non-oracle software? Can you still use proxy authentication when you use software like JBoss, Hibernate, IBatis, MyFaces, Wicket etc? Yes you can! I&#8217;ll explain below how to set up proxy authentication using JBoss in such a way you don&#8217;t have to modify any of the code that uses JDBC, directly or indirectly.</p>
<ul>
<li>First a way is needed to set a username for each (JDBC) database connection retrieved. <a href="http://www.it-eye.nl/weblog/2005/09/12/oracle-proxy-users-by-example/">It-eye weblog</a> explains how to open a connection to a database using java, and then switch to another username.</li>
<li>Secondly, in your application users should authenticate them self using the default mechanism of J2EE 1.4 (and higher) application, using <a href="http://java.sun.com/javase/technologies/security/">JAAS</a>. Usually creating a security policy inside your web.xml or inside your ear is enough. Here&#8217;s the information how to do this under JBoss: <a href="http://www.jboss.org/community/wiki/SecureAWebApplicationUsingACustomForm">Secure a webapplication</a>.<br />
Since we&#8217;re using a database, the best option would be to use database based authentication, meaning user information comes out of a database table. There&#8217;s a lot of documentation on the web how to do add security, so I won&#8217;t repeat that here.</li>
<li>Database connection in JBoss are retrieved using connection pooling, as is custom in any JEE server.  You can create a custom connection pool, that changes the switches to the user name that is currently logged in at the webapplication. That way, every action on the database is done under a database user that is currently logged in.Do to be able to do that, first, you&#8217;ll need a custom connection factory that extends the default connection factory. Our connection factory will return a customized datasource that modifies code.Here&#8217;s a code listing:
<pre class="brush: java;">package nl.gerbrandict.dbconnaudit;

import java.sql.SQLException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;

import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
import org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory;

/**
 * An extended connection factory, that uses the Oracle feature to change the username of an existing connection
 *

 * When a user authenticated on the application server, the database connection will switch to that username.
 * This allows for better auditing and potentially for improved security.
 *
 * Properties (get'ers and set'ters) can be set via the configuration section of the -ds file
 * @author gvdieijen
 */
public class DBConnAuditConnectionFactory extends LocalManagedConnectionFactory {

    private String defaultProxyUser;

    public DBConnAuditConnectionFactory() throws SQLException {
        super();

    }

    @Override
    public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
        return new OracleWrapperDataSource(this, cm);
    }

    public void setEnableProxySession(Boolean enableProxySession) {
        this.enableDbConnAudit = enableProxySession;
    }

    public void setDefaultProxyUser(final String defaultProxyUser) {
        if (StringUtils.isEmpty(defaultProxyUser)) {
            this.defaultProxyUser=null;
        } else {
             this.defaultProxyUser = defaultProxyUser;
        }
    }

    /**
     * Default db user to open proxy session for, when no authenticated user is active
     * @return
     */
    public String getDefaultProxyUser() {
    	return this.defaultProxyUser;
    }
}</pre>
<p>As you can see, the file returns a OracleWrapperDatasource. That&#8217;s custom class, that extends the default WrapperDatasource of JBoss, and changes the user of jdbc connection just before the connection is handed of to the application. To speak in terms of the fine book</li>
<li>Now, How can you use that new class? They have to be packed into a rar file. Functionally, that&#8217;s a Resource Adapter, a module that allows a J2EE application to use resources. Technically (and practically), it&#8217;s just a jar-archive similar to a war, with a different extension. Maven can create these files automatically for you, if you set the packaging type to rar instead of jar (which is the default).</li>
<li>When you download JBoss, you&#8217;ll get a sample connection pool for a in-memory database: default-ds.xml, located in the server/default/deploy directory of jboss. To use the custom classses, copy the file into (for example) myoracleproxy-ds.xml and create a minor modification so a custom connection factory is used &#8211; update the managedconnectionfactory property, that a custom connectionfactory is used, that returns the proxied connections:
<pre class="brush: xml;">&lt;managedconnectionfactory-class&gt;nl.gerbrandict.dbconnaudit.DBConnAuditConnectionFactory&lt;/managedconnectionfactory-class&gt;</pre>
</li>
</ul>
<p>All in all, after some tweaking, all queries and updates to your Oracle database are done under the J2EE username. This means when user Joe logs in, all his database access will be logged under user Joe as well. This can improve auditing as well as security.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/06/proxying-authentication-using-jboss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala and Java</title>
		<link>http://www.gerbrand-ict.nl/2010/03/scala-and-java/</link>
		<comments>http://www.gerbrand-ict.nl/2010/03/scala-and-java/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 12:53:22 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=408</guid>
		<description><![CDATA[When you say Ruby, you say Rails. When you say Groovy, you say unit-tests, scripting and integration. Well that might be over-acted, but that&#8217;s what most people make of it. Some people remark Scala is best-suited for backend-code, or very good at parallel code, but apart from that I&#8217;ve never heard that Scala is the [...]]]></description>
			<content:encoded><![CDATA[<p>When you say Ruby, you say Rails. When you say Groovy, you say unit-tests, scripting and integration. Well that might be over-acted, but that&#8217;s what most people make of it.<br />
Some people remark Scala is best-suited for backend-code, or very good at parallel code, but apart from that I&#8217;ve never heard that Scala is the language for the Lift framework. Or the language to use when you want to create multi-threaded code. What I hear mostly, Scala is the new Java.<br/><br />
Would that be true: could you use Scala as a dropin replacement for Java, as, let&#8217;s say, a <strong>Java 2.0</strong> or <strong>Java 8</strong>?</p>
<p>
In the coming postings I want to investigate that claim using my knowledge of experience in Java/J2EE and my complete lack of experience in Scala. Can you say to you&#8217;re developers, or yourself, from this day on, we&#8217;ll use Scala instead of Java to do our development?</p>
<p>
For now, I found this nice presentation I want to share: <a title="Miles Sabin Introduction To Scala For Java Developers" href="http://www.slideshare.net/skillsmatter/miles-sabin-introduction-to-scala-for-java-developers">Introduction To Scala For Java Developers</a> by Miles Sabin.</p>
<p><script type="text/javascript">var bol_pml={"id":"bol_1298467507598","secure":false,"baseUrl":"partnerprogramma.bol.com","urlPrefix":"http://aai.bol.com/aai","productId":"productid=1001004007102405&#038;productid=1001004006568622&#038;productid=1001004006528303&#038;productid=1001004009746957&#038;","site_id":"2396","target":true,"rating":true,"price":true,"link_name":"Scala","link_subid":"","image_size":true,"image_position":"left","width":"250","cols":"1","background_color":"#FFFFFF","text_color":"#CB0100","link_color":"#0000FF","border_color":"#D2D2D2","letter_type":"verdana","letter_size":"11"};</script><script type="text/javascript" src="http://partnerprogramma.bol.com/partner/static/js/aai/clientProductlink.js" id="bol_1298467507598"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/03/scala-and-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Develop with faster with smarter tools</title>
		<link>http://www.gerbrand-ict.nl/2010/02/develop-with-jrebel/</link>
		<comments>http://www.gerbrand-ict.nl/2010/02/develop-with-jrebel/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 23:23:58 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[coder]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=401</guid>
		<description><![CDATA[I develop software for a living. This involves quite a lot of talking, coaching, attending meetings, drinking coffee, etc. but the actual work is done during programming &#8211; when the software is created. That programming involves repeated cycles of the following: modify or type some code, compile, deploy and then run the code and perform [...]]]></description>
			<content:encoded><![CDATA[<p>I develop software for a living. This involves quite a lot of talking, coaching, attending meetings, drinking coffee, etc. but the actual work is done during programming &#8211; when the software is created. That programming involves repeated cycles of the following: modify or type some code, compile, deploy and then run the code and perform some tests to see if it works. How cumbersome that process was ranged from:</p>
<ul>
<li>Hitting &#8216;Run&#8217; and waiting a few seconds,</li>
<li>to hitting &#8216;Run and deploy&#8217; in my IDE and waiting about 20-30 seconds,</li>
<li>to executing a ant script, restarting the application server and waiting 5 minutes</li>
<li>to compiling a class file, uploading the class and accompanied libraries using a cumbersome webinterface and then executing a PLSQL script to run that class, wasting in total time amount 15 minutes (<em>yes, that was a a very big and professional company)<br />
</em></li>
</ul>
<p>In my opinion, the programmer is productive when he either codes, or when he tests his codes. Any time spent on waiting or performing some troublesome actions like accessing a web interface is pure waste. In short the above time ranging from a few seconds to 15 minutes is <a href="http://www.oreillynet.com/onjava/blog/2006/03/dead_time_code_compile_wait_wa.html">dead time</a>.</p>
<p>Of course all that time wasted not only frustrates developers, it&#8217;ll cost quite some time and thus money. Now how can you limit that dead time, that is wasted by developers? One way is your have your developers write perfect code at once. Of course that&#8217;s not very realistic. Recently I found a very nice tool to limit that dead time, when you develop Java software: <a href="http://www.zeroturnaround.com/jrebe">JRebel</a>. What does that mean for you as java-developer:<br />
JRebel runs as a software agent within your virtual machine, that in turn runs your application server. What JRebel does, is taking over the class-loader.<br />
You can specify the output directories of your IDE (target/classes, /bin, etc.). Now whenever you make a change in your code, IDE&#8217;s like Eclipse can compile that code into a new class file in the output directory. JRebel will automatically detect the changed class file. Thus no waste! Since JRebel plugs into the VM, it&#8217;ll work with virtually any application server.</p>
<p><a href="http://www.zeroturnaround.com/blog"><img class="alignnone" title="JRebel Hotswap" src="http://www.zeroturnaround.com/wp-content/uploads/2009/11/hotswap.png" alt="" width="550" height="302" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/02/develop-with-jrebel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

