<?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; java</title>
	<atom:link href="http://www.gerbrand-ict.nl/tag/java/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>Serializable Exception in Java</title>
		<link>http://www.gerbrand-ict.nl/2011/07/serializable-exception-in-java/</link>
		<comments>http://www.gerbrand-ict.nl/2011/07/serializable-exception-in-java/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 20:07:21 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[wicket]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=563</guid>
		<description><![CDATA[When  you use Wicket as webfrontend framework to build your application, sooner or later you&#8217;ll encounter the NotSerializableException. This is because Wicket will want to serialize any state you have into a HTTPSession. In Wicket, the first three pages are usually in memory too, so you could ignore the exception for a while, but of [...]]]></description>
			<content:encoded><![CDATA[<p>When  you use Wicket as webfrontend framework to build your application, sooner or later you&#8217;ll encounter the NotSerializableException. This is because Wicket will want to serialize any state you have into a HTTPSession. In Wicket, the first three pages are usually in memory too, so you could ignore the exception for a while, but of course this will fail immediately in case use want to use your webapplication in a clustered configuration. Not to mention you should never ignore Exceptions anyway.</p>
<p>The problem in solving such a Serializable exception is finding the field that is not Serializable. The stacktrace of java doesn&#8217;t help much. Fortunatelly, after some searching I&#8217;ve found the <a href="http://blog.crazybob.org/2007/02/debugging-serialization.html">solution, in the comment of blog posting</a>: add the option <em>-Dsun.io.serialization.extendedDebugInfo=true</em> to the JVM startup parameters.<br />
Now the stacktrace gives you the exact fieldname or expression that is causing the problems, as you can see in the example below:</p>
<pre>2011-07-23 21:44:50,362 ERROR [http-8080-1] [] org.apache.wicket.util.lang.Objects - Error serializing object class nl.gerbrandict.forum.AdminPage [object=[Page class = nl.gerbrandict.forum.AdminPage, id = 2, version = 0]]
java.io.NotSerializableException: org.springframework.beans.factory.support.DefaultListableBeanFactory
- field (class "org.springframework.orm.hibernate3.HibernateTransactionManager", name: "beanFactory", type: "interface org.springframework.beans.factory.BeanFactory")
- object (class "org.springframework.orm.hibernate3.HibernateTransactionManager", org.springframework.orm.hibernate3.HibernateTransactionManager@10fd8ce3)
- custom writeObject data (class "org.springframework.transaction.interceptor.TransactionInterceptor")
- object (class "org.springframework.transaction.interceptor.TransactionInterceptor", org.springframework.transaction.interceptor.TransactionInterceptor@2c96cb51)
- field (class "org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor", name: "transactionInterceptor", type: "class org.springframework.transaction.interceptor.TransactionInterceptor")
..
        - field (class "nl.gerbrandict.forum.AdminModel", name: "person", type: "class nl.gerbrandict.forum.Person")</pre>
<p>(note: not publishing the entire stack trace and using some sample dummy field/classnames).<br />
Although I haven&#8217;t tried, enabling this option in production is most likely a bad idea, because Serialization is already a pretty inefficient process without any debugging information enabled. In my case, I was using a <a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/model/PropertyModel.html">PropertyModel</a> somewhere, using non model as target object.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2011/07/serializable-exception-in-java/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>JavaFX 2.0</title>
		<link>http://www.gerbrand-ict.nl/2011/02/javafx-2-0-by-roger-brinkley/</link>
		<comments>http://www.gerbrand-ict.nl/2011/02/javafx-2-0-by-roger-brinkley/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 22:01:27 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ria]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=495</guid>
		<description><![CDATA[Yesterday I attended a NLJug meeting at Oracle at De Meern on JavaFX, called &#8216;JavaFX 2.0 EA&#8216;. The meeting was presented by Roger Brinkley, who&#8217;s a called &#8216;Community leader&#8217;, of Mobile and Embedded. That he was formally part of Sun wasn&#8217;t hard to see based on his clothing and style. Roger gave an overview of [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I attended a <a href="http://www.nljug.org/">NLJug </a>meeting at Oracle at De Meern on <a href="http://javafx.com/">JavaFX</a>, called &#8216;<a href="http://www.nljug.org/pages/events/content/university_20110217/">JavaFX 2.0 EA</a>&#8216;. The meeting was presented by Roger Brinkley, who&#8217;s a called &#8216;Community leader&#8217;, of Mobile and Embedded. That he was formally part of Sun wasn&#8217;t hard to see based on his clothing and style.</p>
<p>Roger gave an overview of the new JavaFX 2.0, the<a href="http://javafx.com/roadmap/"> road-map</a> and the planned features. The software seems to be developed in an agile manner: the dead line is fixed, as is policy at Oracle (not meeting a dead line means exit for the responsible executive), but the final set of features is not.<br />
The preview is available now for a limited audience, in May the first public beta will be released and in November the final will be available.</p>
<p><span id="more-495"></span>The most important news I heard:</p>
<ul>
<li>JavaFX 2.0 will be a <strong>library </strong>(jfx.jar), rather than a separate scripting language <em>JavaFX</em>. The language works in the language Java of course, but you can use the language <a href="http://www.scala-lang.org/">Scala</a>, <a href="http://jruby.org/">JRuby</a>, <a href="http://www.jython.org/">Jython</a> or other languages available on the JVM. JavaFX script is end-of-life. Fortunately, the syntax of the library calls is quite similar, and there&#8217;s a program to translate JavaFX script into equivalent Javacode. Curiously, the translator, <em>FX Translator</em>, is written in <a href="http://www.scala-lang.org/">Scala</a>.<br />
<em><strong>Update 2011-06-15</strong>: I only heard about the fx translator at the here mentioned presentation. I could find little references to the translator: a back-reference to <a href="http://forums.oracle.com/forums/thread.jspa?threadID=2232556&amp;tstart=45">this postin</a>g (sigh) and the fxtranslator mentioned shortly in this posting on <a href="http://drdobbs.com/blogs/java/229400781">DrDobbs</a>.</em><br />
<em>If you want to use the FXtranslator, you&#8217;ll have to contact Oracle for now. I guess Oracle will release the automatic translation tool in some time too.</em></li>
<li>The <strong>Swing</strong>-controls can be used from JavaFX 2.0. The &#8216;traditional Swing&#8217; is now in maintenance mode, Oracle won&#8217;t create an new features for the original Swing library. Meaning, if you want to develop Swing applications, or more generally, desktop applications in Java now, you can best get the beta or coming GA of JavaFX.</li>
<li>JavaFX 2.0 will be available on <strong>neither the Mobiles nor Televisions</strong>! Oracle has accepted (Sun&#8217;s) loss, and will only focus on the desktop for the time being.<br />
JavaFX seems practical on tablet-devices. However, since most tablet devices are enlarged mobiles (running a mobile os) ratter than flattened laptops (running a full desktop os), you can&#8217;t use JavaFX on any of those devices for the time being.</li>
<li>The JavaFX is supported on the <strong>MS-Windows </strong>platform only for the coming time, (but) it will run on Mac, Linux or other platforms unsupported. This means, you might miss the hardware acceleration when not using Windows. Mind you: Roger was using a Mac while doing his presentation and demonstration the code-samples so the MS-Windows-only support might not look as dramatic as it seems at first glance.</li>
<li>Of course JavaFX runs on the JVM 6 or higher. If all goes well, JavaFX will be part of JDK 8. Before that JavaFX can be downloaded as a plugin before from <a href="http://www.java.com">java.com</a>, which will be not to painful for users, especially if they already have some version of the Java-plugin installed.</li>
</ul>
<p>The JavaFX SDK contains a set of sample application called &#8216;Ensemble&#8217;. Roger presented a few impressive programs, and showed the source code. The audience, including the Oracle employee hosting the event was very tech oriented so everyone was eager to see the code of all the nice examples.</p>
<p>Furthermore, Roger frequently mentioned <a href="http://blogs.sun.com/javaspotlight">Podcasts</a>. I have yet to listen to them, but maybe if I have some time left. Should find a way to broadcast audio while doing the dishes.<br />
All in all a nice event. Oracle may turn JavaFX in something that might be practical and usable on a limited number of platforms, ratter then trying to take over the world (or more specifically taking on Android, Flex, Apple IOS).</p>
<p>As you might notice, I&#8217;ve got no code examples or screen-shots. I hope to get access to the beta release of JavaFX 2.0, I&#8217;m quite interested in trying out all those nifty things, and expect some nice blog postings on JavaFX soon!</p>
<p>Update 2011-06-01: The public beta of JavaFX is out! I&#8217;ve published on <a href="http://blog.xebia.com/2011/05/javafx-2-0-beta/">JavaFX on the Xebia-blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2011/02/javafx-2-0-by-roger-brinkley/feed/</wfw:commentRss>
		<slash:comments>5</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>Google buys Instantiations</title>
		<link>http://www.gerbrand-ict.nl/2010/08/google-buys-instantiations/</link>
		<comments>http://www.gerbrand-ict.nl/2010/08/google-buys-instantiations/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:51:12 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Various]]></category>
		<category><![CDATA[gwt]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=451</guid>
		<description><![CDATA[A while a go I used to do Swing development, and I sometimes used the tool of Instantiations to develop my GUI. I quite liked the tool. Before that I used Visual Basic and Visual Studio frequently. I never fully understood why people would fiddle so much with pixels, stylesheets, colors etc when you could [...]]]></description>
			<content:encoded><![CDATA[<p>A while a go I used to do Swing development, and I sometimes used the tool of <a href="http://instantiations.com/">Instantiations </a>to develop my GUI. I quite liked the tool.<br />
Before that I used Visual Basic and Visual Studio frequently. I never fully understood why people would fiddle so much with pixels, stylesheets, colors etc when you could just design your GUI visually.<br />
Well, Instantiations has GWT design tool as well. I recently tried it out very shortly. The tool looked very nice.<br />
I just recently Google bought Instantiations. Will this mean developer productivity in frontend development is cool again?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/08/google-buys-instantiations/feed/</wfw:commentRss>
		<slash:comments>0</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>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>
		<item>
		<title>JFall report</title>
		<link>http://www.gerbrand-ict.nl/2009/11/jfall-report/</link>
		<comments>http://www.gerbrand-ict.nl/2009/11/jfall-report/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 21:43:22 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[concurrency]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jfall]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=368</guid>
		<description><![CDATA[Ik heb een verslag geschreven over JFall 2009 voor Whitehorses, het bedrijf waarvoor ik werk. Hier is de officiele introductie Op 11 november 2009 werd JFall 2009, een van de twee congressen die jaarlijks door de NLJug worden georganiseerd, gehouden. Naast de inhoudelijke sessies, is een van de mooiste aspecten van JFall (en JSpring) het [...]]]></description>
			<content:encoded><![CDATA[<p>Ik heb een verslag geschreven over JFall 2009 voor <a href="http://www.whitehorses.nl">Whitehorses</a>, het bedrijf waarvoor ik werk.</p>
<p>Hier is de officiele introductie</p>
<blockquote><p>
Op 11 november 2009 werd JFall 2009, een van de twee congressen die jaarlijks door de NLJug worden georganiseerd, gehouden. Naast de inhoudelijke sessies, is een van de mooiste aspecten van JFall (en JSpring) het ontmoeten van andere Java programmeurs. In dit Whitebook vind je een verslag van dit congres en van een aantal sessies, o.a. over Java SE 7 en de nieuwe Google ontwikkelingen. Lees het volledige artikel »
</p></blockquote>
<p>en hier is de whitebook: <a href="http://www.whitehorses.nl/whitebooks/2009/jfall-2009-een-verslag">JFall 2009, een verslag </a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/11/jfall-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

