<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Nelz&#039;s Blog &#187; Java</title>
	<atom:link href="http://nelz.net/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://nelz.net</link>
	<description>Ruminations on Development</description>
	<lastBuildDate>Sun, 06 May 2012 20:45:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='nelz.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/b1e8ad2c035555285ea1c88e99d66b4d?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Nelz&#039;s Blog &#187; Java</title>
		<link>http://nelz.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nelz.net/osd.xml" title="Nelz&#039;s Blog" />
	<atom:link rel='hub' href='http://nelz.net/?pushpress=hub'/>
		<item>
		<title>Project Begets Love for AppEngine and Python at Java&#8217;s Expense</title>
		<link>http://nelz.net/2010/10/28/project-begets-love-for-appengine-and-python-at-javas-expense/</link>
		<comments>http://nelz.net/2010/10/28/project-begets-love-for-appengine-and-python-at-javas-expense/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 07:33:58 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelz.net/?p=452</guid>
		<description><![CDATA[The Project For the past year or two I&#8217;ve had an ongoing side project where I post to the Twitter account @bman_countdown. It started out as just a simple countdown, but I realized I could use it as an opportunity to provide more information about the event, so I started to tack on links to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=452&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The Project</h2>
<p>For the past year or two I&#8217;ve had an ongoing side project where I post to the Twitter account <a href="http://twitter.com/bman_countdown" target="_blank">@bman_countdown</a>. It started out as just a simple countdown, but I realized I could use it as an opportunity to provide more information about the event, so I started to tack on links to relevant content on the <a href="http://burningman.com/" target="_blank">BurningMan.com</a> website.</p>
<p><a href="http://nelznet.files.wordpress.com/2010/10/picture-4.png"><img class="aligncenter size-full wp-image-453" title="countdown_orig" src="http://nelznet.files.wordpress.com/2010/10/picture-4.png" alt="" width="838" height="270" /></a></p>
<p>Over time I&#8217;ve increased the functionality from being a static set of links, to mixing in the most recent blog post from the Burning Blog. (Actually, this functionality just went live <em>today</em>.)</p>
<p><a href="http://nelznet.files.wordpress.com/2010/10/picture-7.png"><img class="aligncenter size-full wp-image-454" title="countdown_modern" src="http://nelznet.files.wordpress.com/2010/10/picture-7.png" alt="" width="844" height="269" /></a></p>
<p>This has been a great &#8216;toy&#8217; project that I use to experiment with different technologies.</p>
<h2>The Environment</h2>
<p>For the first couple of iterations it was a Ruby script that I ran off of my &#8216;media server&#8217; (a Mac Mini which I had set up <a href="http://www.farawaymac.com/mac-server/mac-server-series-initial-setup-of-the-mac/" target="_blank">as recommended by MacMiniColo</a>). To emulate <a href="http://en.wikipedia.org/wiki/Cron" target="_blank">cron</a> functionality, I used <a href="http://en.wikipedia.org/wiki/Launchd" target="_blank">launchd</a> to run the script once a day.</p>
<p>Predictably, this setup caused some hiccups in the continuity of the service: when my ISP service went out; when my router borked; when the hard drive failed; when I moved; etc. (Yay for providing non-mission-critical projects!)</p>
<p>Around the time of the 2010 Burning Man event, <a href="http://dev.twitter.com/pages/basic_to_oauth" target="_blank">Twitter removed the ability to use Basic Auth</a>, which is what the library I used relied upon. I decided the service could take a break right after the event while I figured out what I was going to do with it.</p>
<p>I had done some minor playing with Google AppEngine in Java, so I was familiar with the basic services GAE provides. (I love AppEngine&#8217;s first-class cron support. And the TaskQueue concept ecourages truly asynchronous and scalable design.) But, since this project is what I use to experiment with stuff, I figured I&#8217;d try out Python.</p>
<h2>Meeting Python</h2>
<p>First, I had to get up to speed on Python itself. So, I got the book <a href="http://www.qtrac.eu/py3book.html" target="_blank">Programming in Python 3</a>. I studied several chapters of this book and did a couple of the &#8216;programming assignments&#8217; (which I thought was a great idea), until I felt I was familiar enough with the language to take a poke at upgrading the countdown.</p>
<p>I came to realize that the process of developing in Python is <em>so easy</em>! (Even more so in GAE, as the development server environment that you get is great, and shit just works: just save the changes to the file and you can hit the page, and you get instant feedback.)</p>
<p>I know I&#8217;m a latecomer and I am treading dangerously close to <a href="http://en.wikipedia.org/wiki/Esoteric_programming_language" target="_blank">Programming Language War</a> territory here, but I have to say that I am entirely <em>fed up</em> with the edit/build/deploy cycle that leaks time and energy in Java projects. Do you realize that in big Java shops, there are engineers whose entire function is to iterate on the build process? Remember that whole &#8220;<a href="http://nelz.net/2010/03/05/google-app-engine-in-maven-intellij/" target="_self">Google App Engine in Maven + IntelliJ</a>&#8221; blog post that I made? In Python, the build-cycle-via-build-tool process doesn&#8217;t exist. Imagine a future where you don&#8217;t need to wrestle through Maven&#8217;s bullshit to get stuff done. I can see this future in Python, and it gives me tingles in my naughty bits!</p>
<p>Sure, I&#8217;ve got rose-colored glasses on here. I am a native speaker of <a href="http://reocities.com/tablizer/javacrit.htm" target="_blank">high-protocol</a> Java (my kingdom for a native <a href="http://jlorenzen.blogspot.com/2007/10/using-groovy-to-easily-avoid-nasty.html" target="_blank">&#8220;?&#8221; operator</a>!), who is currently a tourist in a strange land speaking a stilted <a href="http://www.thefreedictionary.com/pidgin" target="_blank">pidgin</a> version of Python. Admittedly, I have an incomplete grasp on what the costs and benefits are when moving from a <a href="http://en.wikipedia.org/wiki/Compiler#Compiled_versus_interpreted_languages" target="_blank">compiled language to an interpreted one</a>. But it sure seems easier so far.</p>
<p><a href="http://nelznet.files.wordpress.com/2010/10/picture-8.png"><img class="aligncenter size-full wp-image-456" title="nelz_on_java" src="http://nelznet.files.wordpress.com/2010/10/picture-8.png" alt="" width="771" height="248" /></a></p>
<h2>Future of Java</h2>
<p>I was originally pulling for the Java ecosystem, whether that comes from a selfish (it&#8217;s where my bread gets buttered) or a philanthropic (because I&#8217;ve seen so much good Open Source stuff come out of it) point of view, I&#8217;m not sure. I was happy when some very smart people talked about ways that at least the <a href="http://thinkrelevance.com/blog/2008/09/24/java-next-overview.html" target="_blank">JVM could stay relevant</a> by embracing more dynamic languages built on top of it.</p>
<p>But then there was last weeks announcement that Mac OS X would <a href="http://developer.apple.com/library/mac/#releasenotes/Java/JavaSnowLeopardUpdate3LeopardUpdate8RN/NewandNoteworthy/NewandNoteworthy.html" target="_blank">deprecate support for Java</a>. This generated a lot of excellent discussion. My <a href="http://www.subfurther.com/blog/?p=1305" target="_blank">favorite post</a> both described why this is a death knell for Java, while also outlining a strategy for ensuring Java could continue to function (by breaking up it&#8217;s fairly monolithic API into discrete modules).</p>
<p>Alas, because of a very specific interaction I had, I fear Chris Adamson&#8217;s cogent post will probably be ignored by Oracle. Back when the news came out that Oracle was buying Sun and therefore Java and MySQL, I spoke to a friend of mine who worked for Oracle. I told him I didn&#8217;t care if Oracle owned Java and MySQL as long as they didn&#8217;t fuck it up. His response: &#8220;Don&#8217;t worry. We&#8217;ll fuck it up.&#8221;</p>
<p>The mere fact that I heard this kind of pessimism coming from an employee within Oracle makes me think Java will be viewed more and more as a legacy system in the months and years to come.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/452/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/452/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/452/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=452&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2010/10/28/project-begets-love-for-appengine-and-python-at-javas-expense/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>

		<media:content url="http://nelznet.files.wordpress.com/2010/10/picture-4.png" medium="image">
			<media:title type="html">countdown_orig</media:title>
		</media:content>

		<media:content url="http://nelznet.files.wordpress.com/2010/10/picture-7.png" medium="image">
			<media:title type="html">countdown_modern</media:title>
		</media:content>

		<media:content url="http://nelznet.files.wordpress.com/2010/10/picture-8.png" medium="image">
			<media:title type="html">nelz_on_java</media:title>
		</media:content>
	</item>
		<item>
		<title>TestNG vs JUnit4</title>
		<link>http://nelz.net/2010/10/06/testng-vs-junit4/</link>
		<comments>http://nelz.net/2010/10/06/testng-vs-junit4/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 21:06:16 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelz.net/?p=430</guid>
		<description><![CDATA[JUnit has done huge things for the programming community. It really helped to usher &#8220;The Age of Testing&#8221; into being. I will always say that. However, I have to say that when starting a new Java project, using TestNG is the right choice. Here is how I see things happening: Project starts. Choose the &#8216;industry [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=430&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://junit.org/" target="_blank">JUnit</a> has done huge things for the programming community. It really helped to usher &#8220;The Age of Testing&#8221; into being. I will always say that. However, I have to say that when starting a new Java project, using <a href="http://testng.org/" target="_blank">TestNG</a> is the right choice.</p>
<p>Here is how I see things happening:</p>
<ol>
<li>Project starts. Choose the &#8216;industry standard&#8217; JUnit. Heck, let&#8217;s even go with JUnit 4 because it supports Java 5 Annotations.</li>
<li>JUnit works great for unit tests.</li>
<li>Hey, we want to write an integration test (talking to a db? setting up a <a href="http://www.springsource.org/" target="_blank">Spring</a> <code>ApplicationContext</code>?) as well. We&#8217;re already using JUnit, so let&#8217;s keep using it for the new integration tests too.</li>
<li>Let&#8217;s write a second (and third; and more) integration test within JUnit just like that first one we wrote.</li>
<li>Hey, why is the build taking so long? Oh, hey, JUnit is causing us to do some heavyweight operations for each individual tests. Is there some way to only do the heavy operations once per a suite of tests?</li>
<li>Blogosphere says: &#8220;JUnit is a <em>unit testing</em> framework, it&#8217;s not meant for integration testing&#8221;; &#8220;You are doing it wrong&#8221;; &#8220;Sure you can do that, here&#8217;s the horrible atrocity of code that you need to implement to make it possible&#8221;.</li>
<li>Find that TestNG has a richer lifecycle and can help with this integration test scenario, while still being easy to use for unit tests. Shake your fist at the air in impotent rage that you didn&#8217;t just start with TestNG.</li>
</ol>
<p>I&#8217;ve personally seen this happen in at least 2 large projects.</p>
<p>I am currently in the &#8220;impotent rage&#8221; phase of the cycle. My original impetus to write this blog post was to say that someone(<em>*</em>) should write the class that combines the <code>org.junit.runners.Suite</code> functionality and Spring&#8217;s <code>AbstractTransactionalJUnit4SpringContextTests</code>.</p>
<p>Here&#8217;s the straight scoop: You are probably going to want to do some integration testing in addition to unit testing. TestNG may only be a bit different from JUnit, but it is just enough different in all the right ways to make it the tool you want to use.</p>
<p>(*) I know I should consider doing it. I will add it directly to the top  of my &#8220;Things That Should Get Done But Won&#8217;t Ever See the Light of Day&#8221;  list.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/430/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/430/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/430/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=430&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2010/10/06/testng-vs-junit4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>More Maven Angst</title>
		<link>http://nelz.net/2010/01/19/more-maven-angst/</link>
		<comments>http://nelz.net/2010/01/19/more-maven-angst/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 22:20:28 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelz.net/?p=408</guid>
		<description><![CDATA[I don&#8217;t want to just jump on Maven-bashing bandwagon here, but a casual perusal of my previous posts will show that I talk about Maven a lot. This is going to be another one of those posts. I&#8217;ve been starting to play with Google App Engine, both for personal projects and at work. Since most [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=408&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t want to just jump on <a href="http://maven.apache.org/" target="_blank">Maven</a>-bashing <a href="http://www.naildrivin5.com/daveblog5000/?p=111" target="_blank">bandwagon</a> here, but a casual perusal of my previous posts will show that I talk about Maven a lot. This is going to be another one of <em>those</em> posts.</p>
<p>I&#8217;ve been starting to play with <a href="http://code.google.com/appengine/" target="_blank">Google App Engine</a>, both for personal projects and at work. Since most of my environments are Maven-based, I thought I&#8217;d go out and find a Maven Archetype or some kind of a POM file to bring these projects into my environment. I did find several blog posts trying to help: <a href="http://twelves.blogspot.com/2009/04/google-appengine-maven-pom.html" target="_blank">here</a>, <a href="http://www.salientpoint.com/blog/?p=480" target="_blank">here</a>, etc&#8230; The annoying thing you&#8217;ll notice on those blog posts is that <a href="http://www.sonatype.com/people/brian" target="_blank">Brian Fox ((formerly?) of Sonatype)</a> posts a comment pointing towards Jason van Zyl&#8217;s post <a href="http://www.sonatype.com/people/2009/04/mavenizing-the-appengine-sdk/" target="_blank">describing his efforts to Maven-ize the GAE SDK</a>.</p>
<p>That would be all well and good if things had actually progressed. If you look at JvZ&#8217;s post, you&#8217;ll see he ends with &#8220;hopefully I’ll be able to get this out for Maven users by the end of the week!&#8221; What happens after that? Bupkis, nil, nothing, NADA!</p>
<p>There&#8217;s comments as late as Dec &#8217;09 expressing interest to use and/or help with the effort. But, there is NO RESPONSE from anyone at Sonatype.</p>
<p>I just find it galling that Sonatype would go on an all-out publicity spree talking people out of working on their own because JvZ himself was going to bring his skills to bear on the problem, only to completely fizzle out. I suspect the community at large would have been better off if those 4 or 5 early Maven + GAE adopters had continued on their own path, even if JvZ had succeeded.</p>
<p>Again: my patience with Maven/JvZ is waning. I&#8217;m eager to see what comes along next to take its place.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/408/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/408/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/408/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=408&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2010/01/19/more-maven-angst/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Precompile JSPs for Tomcat 6</title>
		<link>http://nelz.net/2009/10/20/precompile-jsps-for-tomcat-6/</link>
		<comments>http://nelz.net/2009/10/20/precompile-jsps-for-tomcat-6/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 23:34:11 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelz.net/?p=385</guid>
		<description><![CDATA[At the day job, we are working to upgrade our Tomcat from 5.5.X to 6.0.Y. The biggest problem I found when running our app against Tomcat 6 was that a bunch of JSPs used some quote escaping patterns that the later version of the compile considered to be syntax errors. To get a feel for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=385&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At the day job, we are working to upgrade our Tomcat from 5.5.X to 6.0.Y. The biggest problem I found when running our app against Tomcat 6 was that a bunch of JSPs used some quote escaping patterns that the later version of the compile considered to be syntax errors.</p>
<p>To get a feel for how many of these problems existed (after I just-in-time fixed the individual JSPs that crossed my path), the boss wanted me to run a precompile against our whole JSP codebase.</p>
<p>I found the <a href="http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html" target="_blank">instructions on the Tomcat site</a>, which proved to be incomplete and/or incorrect (of course).</p>
<p>Here is what I ended up with:</p>
<pre>&lt;project name="Webapp Precompilation" default="all" basedir="."&gt;
   &lt;import file="${tomcat.home}/bin/catalina-tasks.xml"/&gt;
   &lt;target name="jspc"&gt;
       &lt;jasper
             validateXml="false"
             uriroot="${webapp.path}"
             webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
             outputDir="${webapp.path}/WEB-INF/src"
             compilerTargetVM="1.5"
             compilerSourceVM="1.5"
             failOnError="false" /&gt;
  &lt;/target&gt;

  &lt;target name="compile"&gt;
    &lt;mkdir dir="${webapp.path}/WEB-INF/classes"/&gt;
    &lt;mkdir dir="${webapp.path}/WEB-INF/lib"/&gt;
    &lt;javac destdir="${webapp.path}/WEB-INF/classes"
           optimize="off"
           debug="on" failonerror="false"
           srcdir="${webapp.path}/WEB-INF/src"
           source="1.5"
           target="1.5"
           excludes="**/*.smap"&gt;
      &lt;classpath&gt;
        &lt;pathelement location="${webapp.path}/WEB-INF/classes"/&gt;
        &lt;fileset dir="${webapp.path}/WEB-INF/lib"&gt;
          &lt;include name="*.jar"/&gt;
        &lt;/fileset&gt;
        &lt;pathelement location="${tomcat.home}/lib"/&gt;
        &lt;fileset dir="${tomcat.home}/lib"&gt;
          &lt;include name="*.jar"/&gt;
        &lt;/fileset&gt;
        &lt;fileset dir="${tomcat.home}/bin"&gt;
          &lt;include name="*.jar"/&gt;
        &lt;/fileset&gt;
      &lt;/classpath&gt;
      &lt;include name="**" /&gt;
      &lt;exclude name="tags/**" /&gt;
    &lt;/javac&gt;
  &lt;/target&gt;

  &lt;target name="all" depends="jspc,compile"&gt;&lt;/target&gt;

  &lt;target name="cleanup"&gt;
        &lt;delete&gt;
        &lt;fileset dir="${webapp.path}/WEB-INF/src"/&gt;
        &lt;fileset dir="${webapp.path}/WEB-INF/classes/org/apache/jsp"/&gt;
        &lt;/delete&gt;
  &lt;/target&gt;
&lt;/project&gt;
</pre>
<p>The real stroke of luck is this piece:</p>
<pre>             compilerTargetVM="1.5"
             compilerSourceVM="1.5"
</pre>
<p>Their document said stuff about adding some parameters (<code>source="1.5" target="1.5"</code>) to the &#8220;javac&#8221; target, but they neglected the &#8220;jasper&#8221; target. The error messages complained about the above two parameters being set to 1.4, so as an experiment I plugged them into the ANT target with 1.5&#8242;s and the compilation ran correctly!</p>
<p>Another word of note, the &#8220;showSuccess&#8221; directive did <strong>not</strong> work as their documentation states, but the &#8220;failOnError&#8221; directive does.</p>
<p>I hope this helps others!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/385/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/385/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/385/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/385/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/385/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/385/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/385/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/385/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=385&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/10/20/precompile-jsps-for-tomcat-6/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Maven Tomcat Plugin</title>
		<link>http://nelz.net/2009/08/20/maven-tomcat-plugin/</link>
		<comments>http://nelz.net/2009/08/20/maven-tomcat-plugin/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 17:28:25 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelz.net/?p=363</guid>
		<description><![CDATA[Maven. It is both fantastic, and stress-inducing. And more than just Maven itself, there is a whole community of Maven plugins which are just as frustrating. Take the Maven Tomcat Plugin for example. It sounds so nice to just type &#8220;mvn tomcat:run&#8221; in your webapp module, and have it automagically run, dynamically loading any JSP [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=363&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://maven.apache.org" target="_blank">Maven</a>. It is both fantastic, and stress-inducing. And more than just Maven itself, there is a whole community of Maven plugins which are just as frustrating.</p>
<p>Take the <a href="http://mojo.codehaus.org/tomcat-maven-plugin/" target="_blank">Maven Tomcat Plugin</a> for example. It sounds so nice to just type &#8220;mvn tomcat:run&#8221; in your webapp module, and have it automagically run, dynamically loading any JSP changes. But, if you have a non-trivial webapp, you probably need to send in some system properties.</p>
<p>Let&#8217;s pretend that I require the following command-line parameters passed to Tomcat on the command line:</p>
<pre>-Dexample.value.1=alpha -Dexample.value.2=beta</pre>
<p>How would I send that in to the Tomcat plugin? Well, <a href="http://mojo.codehaus.org/tomcat-maven-plugin/run-mojo.html#systemProperties" target="_blank">the documentation</a> says there is a &#8220;systemProperties&#8221; element where you can sent them in. But what is the format?</p>
<p>Is the format perhaps like the <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html" target="_blank">Surefire Plugin</a>?</p>
<pre>&lt;systemProperties&gt;
  &lt;property&gt;
    &lt;name&gt;example.value.1&lt;/name&gt;
    &lt;value&gt;alpha&lt;/value&gt;
  &lt;/property&gt;
  &lt;property&gt;
    &lt;name&gt;example.value.2&lt;/name&gt;
    &lt;value&gt;beta&lt;/value&gt;
  &lt;/property&gt;
&lt;/systemProperties&gt;
</pre>
<p>Or perhaps the format is like that of the <a href="http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin#MavenJettyPlugin-sysprops" target="_blank">Jetty Plugin</a>?</p>
<pre>&lt;systemProperties&gt;
  &lt;systemProperty&gt;
    &lt;name&gt;example.value.1&lt;/name&gt;
    &lt;value&gt;alpha&lt;/value&gt;
  &lt;/systemProperty&gt;
  &lt;systemProperty&gt;
    &lt;name&gt;example.value.2&lt;/name&gt;
    &lt;value&gt;beta&lt;/value&gt;
  &lt;/systemProperty&gt;
&lt;/systemProperties&gt;
</pre>
<p>Nope. The format is like neither of those. It&#8217;s like this:</p>
<pre>&lt;systemProperties&gt;
  &lt;example.value.1&gt;alpha&lt;/example.value.1&gt;
  &lt;example.value.2&gt;beta&lt;/example.value.2&gt;
&lt;/systemProperties&gt;
</pre>
<p>I&#8217;ll admit that this format is a bit less verbose. But why, <em>in the name of all that is holy</em>, does it have to have it&#8217;s own 1-off syntax?!? And can you find this documented anywhere else? I was sure challenged finding it.</p>
<p>This is the kind of non-documentation and irregularity that gives Maven a bad name and keeps my blood pressure high.</p>
<p><strong>UPDATE</strong> (1 Nov 09): As she says in the comments, <a href="http://nelz.net/2009/08/20/maven-tomcat-plugin/#comment-191" target="_self">Kathy</a> actually took the time to submit a ticket to the Maven Tomcat Plugin maintainers, rather than going with my tactic of passively bitching. And today I get notified by <a href="http://nelz.net/2009/08/20/maven-tomcat-plugin/#comment-216" target="_self">herion</a> that the suggestion was taken and there is now <a href="http://mojo.codehaus.org/tomcat-maven-plugin/examples/add-system-properties.html" target="_blank">public documentation</a> added about these properties.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=363&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/08/20/maven-tomcat-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Maven, TestNG, and SeleniumRC</title>
		<link>http://nelz.net/2009/07/30/maven-testng-and-seleniumrc/</link>
		<comments>http://nelz.net/2009/07/30/maven-testng-and-seleniumrc/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 06:01:45 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelz.net/?p=350</guid>
		<description><![CDATA[Today, I set up a Maven module to run SeleniumRC (Java) tests via TestNG. It wasn&#8217;t a straightforward or easy task, so I thought I&#8217;d share some of what I found with you. We opt to have all of our modules stay in lock-step version-wise, so we keep a pretty large structure in our SVN [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=350&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today, I set up a <a href="http://maven.apache.org" target="_blank">Maven</a> module to run <a href="http://seleniumhq.org/projects/remote-control/" target="_blank">SeleniumRC</a> (Java) tests via <a href="http://testng.org/" target="_blank">TestNG</a>. It wasn&#8217;t a straightforward or easy task, so I thought I&#8217;d share some of what I found with you.</p>
<p>We opt to have all of our modules stay in lock-step version-wise, so we keep a pretty large structure in our SVN <em>trunk</em>. We include/exclude modules for compilation by using Maven <em>profiles</em>, so we don&#8217;t have to build the whole structure if we are only changing one small component. Our top-level <strong>pom.xml</strong> file looks similar to this:</p>
<pre>&lt;project&gt;
  &lt;groupId&gt;...
  &lt;artifactId&gt;...
  &lt;version&gt;...
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;modules&gt;
    &lt;module&gt;baseModule&lt;/module&gt;
  &lt;/modules&gt;
  &lt;profiles&gt;
    &lt;profile&gt;
      &lt;id&gt;all&lt;/id&gt;
      &lt;modules&gt;
        &lt;module&gt;otherModule&lt;/module&gt;
        ...
        &lt;module&gt;web-test&lt;/module&gt;
      &lt;/modules&gt;
    &lt;/profile&gt;
    &lt;profile&gt;
      &lt;id&gt;web-test&lt;/id&gt;
      &lt;modules&gt;
        &lt;module&gt;web-test&lt;/module&gt;
      &lt;/modules&gt;
    &lt;/profile&gt;
  &lt;/profiles&gt;
&lt;/project&gt;</pre>
<p>As you can see, running &#8220;mvn clean install&#8221; at this top level would only end up building the <em>baseModule</em>. To get all the modules, we run &#8220;mvn clean install -Pall&#8221; which builds <em>baseModule</em> along with <em>otherModule</em> and <em>web-test</em> and anything else as represented by the ellipse. The <em>web-test</em> module is the one we will be interested in.</p>
<p>For our heavy-weight tests (non-unit tests, like functional or web testing), we like to have the module compile, but not run unless we specifically trigger the tests. To achieve this, we create a <strong>pom.xml</strong> (for the <em>web-test</em> module) that looks something like this:</p>
<pre>&lt;project&gt;
  &lt;parent&gt;...
  &lt;artifactId&gt;web-test&lt;/artifactId&gt;
  &lt;packaging&gt;pom&lt;/packaging&gt;
  &lt;build&gt;
    &lt;testSourceDirectory&gt;src/it/java&lt;/testSourceDirectory&gt;
    &lt;testResources&gt;
      &lt;testResource&gt;
        &lt;directory&gt;src/it/resources&lt;/directory&gt;
      &lt;/testResource&gt;
    &lt;/testResources&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.0.2&lt;/version&gt;
        &lt;configuration&gt;
          &lt;source&gt;1.5&lt;/source&gt;
          &lt;target&gt;1.5&lt;/target&gt;
        &lt;/configuration&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;goals&gt;
              &lt;goal&gt;testCompile&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
        &lt;version&gt;2.4.2&lt;/version&gt;
        &lt;configuration&gt;
          &lt;testSourceDirectory&gt;src/it/java&lt;/testSourceDirectory&gt;
          &lt;excludedGroups&gt;web-test&lt;/excludedGroups&gt;
        &lt;/configuration&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;phase&gt;integration-test&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;test&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
<p>This pom has several features:</p>
<ul>
<li>It sets up <strong>src/it/java</strong> as the location holding the source code for the tests</li>
<li>It sets the <em>surefire</em> plugin (which runs your tests) to only run at the <em>integration-test</em> part of the Maven lifecycle</li>
<li>It says to ignore any tests in the TestNG &#8220;web-test&#8221; group</li>
<li>Note the packaging says this module is of the type &#8220;pom&#8221;. I found that if this is set to &#8220;jar&#8221;, the tests run twice for some unknown reason</li>
</ul>
<p>Now, if you had tests in <strong>src/it/java</strong> (that were all annotated as &#8220;web-test&#8221;) and you ran &#8220;mvn clean install&#8221;, you&#8217;d see that zero tests ran. This is what we want! Now, we have to get the tests running if we pass a specific profile in. To achieve this, I added the following profile definition to the <em>web-test</em> <strong>pom.xml</strong>.</p>
<pre>&lt;profiles&gt;
    &lt;profile&gt;
      &lt;id&gt;run-web-test&lt;/id&gt;
      &lt;build&gt;
        &lt;plugins&gt;
          &lt;plugin&gt;
            &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.4.2&lt;/version&gt;
            &lt;configuration&gt;
              &lt;suiteXmlFiles&gt;
                &lt;suiteXmlFile&gt;src/it/resources/testng.xml&lt;/suiteXmlFile&gt;
              &lt;/suiteXmlFiles&gt;
              &lt;!--&lt;groups&gt;web-test&lt;/groups&gt;--&gt;
              &lt;!--&lt;forkMode&gt;always&lt;/forkMode&gt;--&gt;
            &lt;/configuration&gt;
            &lt;executions&gt;
              &lt;execution&gt;
                &lt;phase&gt;integration-test&lt;/phase&gt;
                &lt;goals&gt;
                  &lt;goal&gt;test&lt;/goal&gt;
                &lt;/goals&gt;
              &lt;/execution&gt;
            &lt;/executions&gt;
          &lt;/plugin&gt;
        &lt;/plugins&gt;
      &lt;/build&gt;
    &lt;/profile&gt;
  &lt;/profiles&gt;</pre>
<p>This profile is invoked when you run &#8220;mvn clean install -Prun-web-test&#8221;. There are several things I&#8217;d like to point out here:</p>
<ul>
<li>At runtime, this overrides the previously-declared <em>surefire</em> plugin configuration, but only when invoking the profile.</li>
<li>Originally, I was mostly getting stuff to work without the &lt;suiteXmlFiles /&gt; section, but with the &lt;groups /&gt; and &lt;forkMode /&gt; sections&#8230; But it was running every single test class as it&#8217;s own TestSuite.</li>
<li>To fix the multiple TestSuite (and <strong>@Before*</strong>, <strong>@After*</strong> problems that I&#8217;ll discuss later), I ended creating my own <strong>testng.xml</strong> file. Having this file and using the &lt;suiteXmlFiles /&gt; element made things a whole lot easier for configuring my TestNG executions than trying to configure the tests through the clumsy interference of the <em>surefire</em> plugin.</li>
<li>As much as I like Maven, I have to say that the lack of documentation and general obfuscation that happens when using their plugins can really drive a person BATTY!</li>
</ul>
<p>Now, I need to start integrating the stuff I need for using SeleniumRC. I found some decent help on <a href="http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+Integration" target="_blank">how to start up and shut down the selenium-server</a>, however I disagree with using a <em>post-integration-test</em> phase to shut down the server, because if the tests fail in the <em>integration-test</em>, Maven won&#8217;t progress to the next phase and you&#8217;ll be left with a spuriously running selenium-server. The client API&#8217;s do have access to the command that the was being run to shut the server down, so it is just a matter of having some TestNG <strong>@AfterSuite</strong> or <strong>@AfterGroup</strong> method issue the <strong>Selenium.shutDownSeleniumServer()</strong> command.</p>
<p>This brings me to some of the TestNG wonkiness I saw. I decided to use a Singleton <a href="http://testng.org/doc/documentation-main.html#parameters-dataproviders" target="_blank">Data Provider</a> (named  <strong>SeleniumFactory</strong>) to deliver the <strong>Selenium</strong> objects to the individual tests. (<strong>Selenium</strong> objects are time-expensive to create, so I wanted to only create 1 for the duration of the entire test suite.) I wanted to initialize the <strong>SeleniumFactory</strong> object in a <strong>@BeforeGroup</strong> method, deliver the <strong>Selenium</strong> object as a Data Provider, and then tear the <strong>SeleniumFactory</strong> down in a <strong>@AfterGroup</strong> method. (At first, I was fighting Maven&#8217;s handling of each test as its own test suite which was giving me sequence issues, which is why I ended up defining my own <strong>testng.xml</strong> file, as I stated above.) Let me start with some code to show you what I mean:</p>
<pre><strong>public</strong> <strong>class</strong> <span style="color:#2040a0;">SequenceEndsTest</span> <span style="color:#4444ff;"><strong>{</strong></span>
    @<span style="color:#2040a0;">BeforeGroups</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">groups</span> <span style="color:#4444ff;">=</span> <span style="color:#4444ff;"><strong>{</strong></span><span style="color:#008000;">"web-test"</span><span style="color:#4444ff;"><strong>}</strong></span><span style="color:#4444ff;"><strong>)</strong></span>
    <strong>public</strong> <strong>void</strong> <span style="color:#2040a0;">startupSelenium</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span> <span style="color:#4444ff;"><strong>{</strong></span>
        <span style="color:#2040a0;">System</span>.<span style="color:#2040a0;">out</span>.<span style="color:#2040a0;">println</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#008000;">"-- &gt; Called startup."</span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#4444ff;"><strong>}</strong></span>
    @<span style="color:#2040a0;">AfterGroups</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">groups</span> <span style="color:#4444ff;">=</span> <span style="color:#4444ff;"><strong>{</strong></span><span style="color:#008000;">"web-test"</span><span style="color:#4444ff;"><strong>}</strong></span>, <span style="color:#2040a0;">alwaysRun</span> <span style="color:#4444ff;">=</span> <strong>true</strong><span style="color:#4444ff;"><strong>)</strong></span>
    <strong>public</strong> <strong>void</strong> <span style="color:#2040a0;">cleanupSelenium</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span> <span style="color:#4444ff;"><strong>{</strong></span>
        <span style="color:#2040a0;">System</span>.<span style="color:#2040a0;">out</span>.<span style="color:#2040a0;">println</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#008000;">"-- &gt; Called cleanup."</span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#4444ff;"><strong>}</strong></span>
<span style="color:#4444ff;"><strong>}</strong></span>
<strong>public</strong> <strong>class</strong> <span style="color:#2040a0;">SeleniumFactory</span> <span style="color:#4444ff;"><strong>{</strong></span>
    @<span style="color:#2040a0;">DataProvider</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">name</span> <span style="color:#4444ff;">=</span> <span style="color:#008000;">"selenium"</span><span style="color:#4444ff;"><strong>)</strong></span>
    <strong>public</strong> <strong>static</strong> <span style="color:#2040a0;">Object</span><span style="color:#4444ff;"><strong>[</strong></span><span style="color:#4444ff;"><strong>]</strong></span><span style="color:#4444ff;"><strong>[</strong></span><span style="color:#4444ff;"><strong>]</strong></span> <span style="color:#2040a0;">getSelenium</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#4444ff;"><strong>)</strong></span> <span style="color:#4444ff;"><strong>{</strong></span>
        <span style="color:#2040a0;">System</span>.<span style="color:#2040a0;">out</span>.<span style="color:#2040a0;">println</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#008000;">"-- &gt; Called data provider."</span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
        <strong>return</strong> <strong>new</strong> <span style="color:#2040a0;">Object</span><span style="color:#4444ff;"><strong>[</strong></span><span style="color:#4444ff;"><strong>]</strong></span><span style="color:#4444ff;"><strong>[</strong></span><span style="color:#4444ff;"><strong>]</strong></span> <span style="color:#4444ff;"><strong>{</strong></span> <strong>new</strong> <span style="color:#2040a0;">Object</span><span style="color:#4444ff;"><strong>[</strong></span><span style="color:#4444ff;"><strong>]</strong></span> <span style="color:#4444ff;"><strong>{</strong></span><strong>null</strong><span style="color:#4444ff;"><strong>}</strong></span><span style="color:#4444ff;"><strong>}</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#4444ff;"><strong>}</strong></span>
<span style="color:#4444ff;"><strong>}</strong></span>
<strong>public</strong> <strong>class</strong> <span style="color:#2040a0;">SequenceTest</span> <span style="color:#4444ff;"><strong>{</strong></span>
    @<span style="color:#2040a0;">Test</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#2040a0;">groups</span><span style="color:#4444ff;">=</span><span style="color:#4444ff;"><strong>{</strong></span><span style="color:#008000;">"web-test"</span><span style="color:#4444ff;"><strong>}</strong></span>,
            <span style="color:#2040a0;">dataProvider</span> <span style="color:#4444ff;">=</span> <span style="color:#008000;">"selenium"</span>, <span style="color:#2040a0;">dataProviderClass</span> <span style="color:#4444ff;">=</span> <span style="color:#2040a0;">SeleniumFactory</span>.<strong>class</strong><span style="color:#4444ff;"><strong>)</strong></span>
    <strong>public</strong> <strong>void</strong> <span style="color:#2040a0;">testSomething</span><span style="color:#4444ff;"><strong>(</strong></span><strong>final</strong> <span style="color:#2040a0;">Selenium</span> <span style="color:#2040a0;">selenium</span><span style="color:#4444ff;"><strong>)</strong></span> <span style="color:#4444ff;"><strong>{</strong></span>
        <span style="color:#2040a0;">System</span>.<span style="color:#2040a0;">out</span>.<span style="color:#2040a0;">println</span><span style="color:#4444ff;"><strong>(</strong></span><span style="color:#008000;">"-- &gt; Called test."</span><span style="color:#4444ff;"><strong>)</strong></span><span style="color:#4444ff;">;</span>
    <span style="color:#4444ff;"><strong>}</strong></span>
<span style="color:#4444ff;"><strong>}</strong></span></pre>
<p>This is what I expected to see after running this code:</p>
<pre>-- &gt; Called startup.
-- &gt; Called data provider.
-- &gt; Called test.
-- &gt; Called cleanup.</pre>
<p>But this is what I *actually* saw:</p>
<pre><strong>-- &gt; Called data provider.</strong>
-- &gt; Called startup.
-- &gt; Called test.
-- &gt; Called cleanup.</pre>
<p>I would have assumed that an <strong>@BeforeGroup</strong> method got called before a data provider method, but I guess my assumption is wrong, eh? After I figured out this order-of-method-calls business, I was able to adapt my <strong>SeleniumFactory</strong> accordingly.</p>
<p>&#8230; And that is my story. To summarize: each of these tools could be better documented, but at the end of the day I <em>was</em> able to get a Maven module up and running SeleniumRC tests via TestNG. Now, on to the test-writing!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/350/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/350/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=350&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/07/30/maven-testng-and-seleniumrc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>The Life of a boolean</title>
		<link>http://nelz.net/2009/05/28/the-life-of-a-boolean/</link>
		<comments>http://nelz.net/2009/05/28/the-life-of-a-boolean/#comments</comments>
		<pubDate>Thu, 28 May 2009 23:59:46 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=7</guid>
		<description><![CDATA[Java booleans came up in conversation today, and I wanted to point out a couple of things that I&#8217;ve noticed. Firstly, when talking about (capital &#8216;B&#8217;) Booleans, it is possible to achieve a trinary state object: TRUE/FALSE/null. However, it is not recommended. In fact, I&#8217;d go so far as to recommend breaking the fingers of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=7&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Java <tt>boolean</tt>s came up in conversation today, and I wanted to point out a couple of things that I&#8217;ve noticed.</p>
<p>Firstly, when talking about (capital &#8216;B&#8217;) <tt>Boolean</tt>s, it is <i>possible</i> to achieve a trinary state object: <tt>TRUE</tt>/<tt>FALSE</tt>/<tt>null</tt>. However, it is not recommended. In fact, I&#8217;d go so far as to recommend <i>breaking the fingers</i> of anyone who tried to perpetrate this horrible pattern in your code.
</p>
<p>Secondly, I&#8217;d like to discuss <tt>boolean</tt>s in your model objects. I agree that it frequently seems like a good idea to include one in your model object. However, I have seen so many occurrences where, over time, it becomes necessary to add a third (or fourth, or fifth) state. Even the RDBMSes are hedging their bets by storing <tt>boolean</tt> flags as <tt>TINYINT</tt>s. I would suggest that you seriously consider using an <tt>Enum</tt> to represent your two states as they exist at the beginning of their lifecycle&#8230; This way you won&#8217;t get stuck with a bunch of <tt>isXXX()</tt> accessors that all have to be refactored as soon as you add a third state.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=7&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/05/28/the-life-of-a-boolean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>JDK 1.6 on OS X</title>
		<link>http://nelz.net/2009/05/13/jdk-1-6-on-os-x/</link>
		<comments>http://nelz.net/2009/05/13/jdk-1-6-on-os-x/#comments</comments>
		<pubDate>Wed, 13 May 2009 15:32:54 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=9</guid>
		<description><![CDATA[For Widgetbox I was recently tasked with investigating a new Java memcached client called xmemcached. Things were going smoothly (except that the xmemcached documentation is written mostly in Chinese)&#8230; But then I hit a bump in the road: the xmemcached JAR file was compiled for JDK 1.6. Up until this point, all our code was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=9&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For <a class="external" href="http://www.widgetbox.com/">Widgetbox</a><img class="outlink" src="images/out.png" alt="" /> I was recently tasked with investigating a new Java <a class="external" href="http://www.danga.com/memcached/">memcached</a><img class="outlink" src="images/out.png" alt="" /> client called <a class="external" href="http://code.google.com/p/xmemcached/">xmemcached</a><img class="outlink" src="images/out.png" alt="" />.</p>
<p>Things were going smoothly (except that the xmemcached documentation is written mostly in Chinese)&#8230; But then I hit a bump in the road: the xmemcached JAR file was compiled for <a class="external" href="http://java.sun.com/javase/downloads/index.jsp">JDK 1.6</a><img class="outlink" src="images/out.png" alt="" />.
</p>
<p>Up until this point, all our code was using JDK 1.5, and we had only vague plans to eventually upgrade to JDK 1.6. Upon discussion, I&#8217;m just gonna work on the 1.6 stuff in a branch until we get the rest of the development team and operating environments up to a JDK 1.6 standard.
</p>
<p>So, I went about upping my chosen JDK via the &quot;<a class="external" href="http://developer.apple.com/java/faq/#multiple">Java Preferences</a><img class="outlink" src="images/out.png" alt="" />&quot; dialog.
</p>
<p>Now, I saw something like this:
</p>
<pre>
$ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
</pre>
<p>Awesome. That&#8217;s exactly what I wanted!
</p>
<p>But hold the phone, I was also getting this:
</p>
<pre>
$ mvn -v
Maven version: 2.0.9
Java version: 1.5.0_16
OS name: "mac os x" version: "10.5.6" arch: "i386" Family: "unix"
</pre>
<p>So, I did some digging. With some <a class="external" href="http://dhruba.name/2008/12/22/compiling-java-16-projects-using-maven-on-mac-os-x/">hints</a><img class="outlink" src="images/out.png" alt="" />, I found that the executable <tt>/usr/bin/mvn</tt> uses the symlink &quot;CurrentJDK&quot; to figure out which JDK to run, and the &quot;Java Preferences&quot; panel doesn&#8217;t update that when you change JDKs. (<b>Dumb!</b>)
</p>
<p>So, here&#8217;s how I fixed it:
</p>
<pre>
$ cd /System/Library/Frameworks/JavaVM.framework/Versions/
$ ls -la
...
lrwxr-xr-x   1 root  wheel    5 Sep 29  2008 1.5 -&gt; 1.5.0
drwxr-xr-x   8 root  wheel  272 Feb 21  2008 1.5.0
lrwxr-xr-x   1 root  wheel    5 Sep 29  2008 1.6 -&gt; 1.6.0
drwxr-xr-x   8 root  wheel  272 May  6  2008 1.6.0
lrwxr-xr-x   1 root  wheel    3 May 12 18:18 CurrentJDK -&gt; 1.5
...
$ sudo rm CurrentJDK
$ sudo ln -s 1.6 CurrentJDK
</pre>
<p>Now, I am seeing the environment I want:
</p>
<pre>
$ ls -la
...
lrwxr-xr-x   1 root  wheel    5 Sep 29  2008 1.5 -&gt; 1.5.0
drwxr-xr-x   8 root  wheel  272 Feb 21  2008 1.5.0
lrwxr-xr-x   1 root  wheel    5 Sep 29  2008 1.6 -&gt; 1.6.0
drwxr-xr-x   8 root  wheel  272 May  6  2008 1.6.0
lrwxr-xr-x   1 root  wheel    3 May 12 18:18 CurrentJDK -&gt; 1.6
...
$ mvn -v
Maven version: 2.0.9
Java version: 1.6.0_07
OS name: "mac os x" version: "10.5.6" arch: "x86_64" Family: "mac"
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=9&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/05/13/jdk-1-6-on-os-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Java 5 Auto-Unbox Is Not NULL Safe</title>
		<link>http://nelz.net/2009/03/25/java-5-auto-unbox-is-not-null-safe/</link>
		<comments>http://nelz.net/2009/03/25/java-5-auto-unbox-is-not-null-safe/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 16:03:21 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=10</guid>
		<description><![CDATA[Yuck! I am kinda getting fed up with the way the language implementers of Java continually add all these conveniences, but leave them 1/2 baked. Example: 01public class UnboxTest { 02 @Test 03 public void testUnbox() { 04 final Integer a = Integer.valueOf(10); 05 final Integer b = null; 06 unboxIt(a); 07 unboxIt(b); 08 } [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=10&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>Yuck!</h4>
<p>I am kinda getting fed up with the way the language implementers of Java continually add all these <i>conveniences</i>, but leave them 1/2 baked.
</p>
<p>Example:
</p>
<pre>
01public class UnboxTest {
02    @Test
03    public void testUnbox() {
04        final Integer a = Integer.valueOf(10);
05        final Integer b = null;
06        unboxIt(a);
07        unboxIt(b);
08    }
09    void unboxIt(final int value) {
10        System.out.println("Value: " + value);
11    }
12}
</pre>
<p>Guess what happens when you run this code?
</p>
<p>A big, fat <b>NullPointerException</b> on line 7.
</p>
<p>Oh yeah&#8230; <a class="external" href="http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html">Autoboxing</a><img class="outlink" src="images/out.png" alt="" /> is supposed to be soo helpful, but they can&#8217;t default a frigging <tt>null</tt> to the default value of an <tt>int</tt>. (I.e. <b>0</b>)
</p>
<p>See my previous post for <a class="external" href="http://www.nelz.net/roller/nelz/entry/java_5_foreach_syntax">similar problems</a><img class="outlink" src="images/out.png" alt="" /> in the Java 5 <tt>foreach</tt> syntax.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=10&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/03/25/java-5-auto-unbox-is-not-null-safe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>SeleniumRC and FireFox3</title>
		<link>http://nelz.net/2009/01/09/seleniumrc-and-firefox3/</link>
		<comments>http://nelz.net/2009/01/09/seleniumrc-and-firefox3/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 14:21:29 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=12</guid>
		<description><![CDATA[We have started playing with Selenium for some automated testing at my day job. (I&#8217;ve been a proponent of Selenium, but I haven&#8217;t played with it directly for a bit.) I ran into a problem, as described by the Space Vatican. Luckily, he also had the solution to the problem. I took his command-line instructions [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=12&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We have started playing with <a class="external" href="http://seleniumhq.org/">Selenium</a><img class="outlink" src="images/out.png" alt="" /> for some automated testing at <a class="external" href="http://www.widgetbox.com/">my day job</a><img class="outlink" src="images/out.png" alt="" />. (I&#8217;ve been a proponent of Selenium, but I haven&#8217;t played with it directly for a bit.)</p>
<p>I ran into a problem, <a class="external" href="http://www.spacevatican.org/2008/9/27/selenium-and-firefox-3">as described by the Space Vatican</a><img class="outlink" src="images/out.png" alt="" />. Luckily, he also had the solution to the problem.
</p>
<p>I took his command-line instructions and created two scripts to run those command on a given file (&#8216;cuz my file was named differently than the one in his script). Here are the contents of the script:
</p>
<pre>
jar xf $1 customProfileDirCUSTFFCHROME/extensions/readystate@openqa.org/install.rdf
jar xf $1 customProfileDirCUSTFFCHROME/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
jar xf $1 customProfileDirCUSTFFCHROME/extensions/\{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4\}/install.rdf
jar xf $1 customProfileDirCUSTFF/extensions/readystate\@openqa.org/install.rdf
jar xf $1 customProfileDirCUSTFF/extensions/\{538F0036-F358-4f84-A764-89FB437166B4\}/install.rdf
</pre>
<pre>
jar uf $1 customProfileDirCUSTFFCHROME/extensions/readystate@openqa.org/install.rdf
jar uf $1 customProfileDirCUSTFFCHROME/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
jar uf $1 customProfileDirCUSTFFCHROME/extensions/\{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4\}/install.rdf
jar uf $1 customProfileDirCUSTFF/extensions/readystate\@openqa.org/install.rdf
jar uf $1 customProfileDirCUSTFF/extensions/\{538F0036-F358-4f84-A764-89FB437166B4\}/install.rdf
</pre>
<p>And if you&#8217;d like, and feel like trusting me, here is the resultant, FF3-friendly, jar file : <a class="external" href="http://nelz.net/download/selenium-server-1.0-beta-1.jar">selenium-server-1.0-beta-1.jar</a><img class="outlink" src="images/out.png" alt="" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=12&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2009/01/09/seleniumrc-and-firefox3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Compile-Time Dependencies</title>
		<link>http://nelz.net/2008/10/18/compile-time-dependencies/</link>
		<comments>http://nelz.net/2008/10/18/compile-time-dependencies/#comments</comments>
		<pubDate>Sat, 18 Oct 2008 11:57:38 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=13</guid>
		<description><![CDATA[When building out your architecture, I would encourage you to break out your APIs as first-class modules. (Sorry, a &#8216;module&#8217; is Maven speak for the parts of a project that create their own artifacts such as JAR or WAR files.) For an example of a simple suggested structure, look at the following image. (Arrows denote [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=13&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When building out your architecture, I would encourage you to break out your <a class="external" href="http://en.wikipedia.org/wiki/API">API</a><img class="outlink" src="images/out.png" alt="" />s as first-class modules. (Sorry, a &#8216;module&#8217; is <a class="external" href="http://maven.apache.org">Maven</a><img class="outlink" src="images/out.png" alt="" /> <a class="external" href="http://www.sonatype.com/book/reference/multimodule.html#multi-intro">speak</a><img class="outlink" src="images/out.png" alt="" /> for the parts of a project that create their own artifacts such as JAR or WAR files.)</p>
<p>For an example of a simple suggested structure, look at the following image. (Arrows denote compile-time dependencies.):</p>
<p><img class="aligncenter size-full wp-image-297" title="IdealModule" src="http://nelznet.files.wordpress.com/2009/06/idealmodule.png" alt="IdealModule" width="449" height="397" /></p>
<p>In some of my recent projects I received some push-back on breaking out the APIs. The concern was that breaking them out as modules would add overhead to the build process.  I do understand that concern, but I think it is a minimized threat if you are using a fairly sophisticated build system.</p>
<p>I acquiesced at the time, and now we have a structure that looks similar to the next image.  (Can you see the problem already?):<img class="aligncenter size-full wp-image-300" title="PreviousModule" src="http://nelznet.files.wordpress.com/2009/06/previousmodule.png" alt="PreviousModule" width="449" height="438" /></p>
<p>The black arrow indicates just one of the weaknesses of this model.  Here, you can see that a UI component can (at the least offensive) access the DAO API as well as (at the most offensive) access the concrete DAO implementations.</p>
<p>When you have a structure like this, the question is not <em>if</em>, but <em>when</em> will one of your fellow engineers take advantage of this and circumvent the nice functional striations that you have taken so much time to isolate?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=13&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/10/18/compile-time-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>

		<media:content url="http://nelznet.files.wordpress.com/2009/06/idealmodule.png" medium="image">
			<media:title type="html">IdealModule</media:title>
		</media:content>

		<media:content url="http://nelznet.files.wordpress.com/2009/06/previousmodule.png" medium="image">
			<media:title type="html">PreviousModule</media:title>
		</media:content>
	</item>
		<item>
		<title>XMLUnit and TestNG</title>
		<link>http://nelz.net/2008/10/14/xmlunit-and-testng/</link>
		<comments>http://nelz.net/2008/10/14/xmlunit-and-testng/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 17:50:12 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=14</guid>
		<description><![CDATA[Our entire testing system is based on TestNG, but one of our developers recently invoked XMLUnit to test some of the XML he was producing. Now, XMLUnit is built to be used with JUnit (old JUnit&#8230; like 3.8.1 style JUnit&#8230;), which at first glance doesn&#8217;t seem to play well with TestNG test runners. (We were [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=14&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Our entire testing system is based on <a class="external" href="http://testng.org/">TestNG</a><img class="outlink" src="images/out.png" alt="" />, but one of our developers recently invoked <a class="external" href="http://xmlunit.sourceforge.net/">XMLUnit</a><img class="outlink" src="images/out.png" alt="" /> to test some of the XML he was producing.</p>
<p>Now, XMLUnit is built to be used with <a class="external" href="http://www.junit.org/">JUnit</a><img class="outlink" src="images/out.png" alt="" /> (old JUnit&#8230; like 3.8.1 style JUnit&#8230;), which at first glance doesn&#8217;t seem to play well with TestNG test runners.  (We were having some build timeouts and other mysterious behavior when trying to run these tests.)
</p>
<p>To give you an idea, here is a <a class="external" href="http://xmlunit.sourceforge.net/example.html">snippet from the examples</a><img class="outlink" src="images/out.png" alt="" />:
</p>
<pre>
package net.nelz.test.xmlunit;
import org.custommonkey.xmlunit.XMLTestCase;
public class MyXMLTestCase extends XMLTestCase {
public MyXMLTestCase(String name) {
super(name);
}
public void testForEquality() throws Exception {
String myControlXML = "&lt;msg&gt;&lt;uuid&gt;0x00435A8C&lt;/uuid&gt;&lt;/msg&gt;";
String myTestXML = "&lt;msg&gt;&lt;localId&gt;2376&lt;/localId&gt;&lt;/msg&gt;";
assertXMLEqual("comparing test xml to control xml", myControlXML, myTestXML);
assertXMLNotEqual("test xml not similar to control xml", myControlXML, myTestXML);
}
}
</pre>
<p>If you look at that example, the only methods that seem to add any value are <tt>assertXMLEqual(...)</tt> and <tt>assertXMLNotEqual(...)</tt>.
</p>
<p>If you <a class="external" href="http://xmlunit.svn.sourceforge.net/viewvc/xmlunit/trunk/xmlunit/src/java/org/custommonkey/xmlunit/XMLTestCase.java?view=markup">look at the source code</a><img class="outlink" src="images/out.png" alt="" /> for those methods, you&#8217;ll realize that they just delegate to parallel static methods in the class <tt>XMLAssert</tt>:
</p>
<pre>
...
public void assertXMLEqual(String control, String test)
throws SAXException, IOException {
XMLAssert.assertXMLEqual(control, test);
}
...
</pre>
<p>What this all means is that XMLUnit already <i>is</i> TestNG friendly.  Here&#8217;s what that snippet from XMLUnit&#8217;s example code would look like if it were rewritten to target TestNG.:
</p>
<pre>
package net.nelz.test.xmlunit;
import org.custommonkey.xmlunit.XMLAssert;
import org.testng.annotations.Test;
public class MyXMLTestCase {
@Test
public void testForEquality() throws Exception {
String myControlXML = "&lt;msg&gt;&lt;uuid&gt;0x00435A8C&lt;/uuid&gt;&lt;/msg&gt;";
String myTestXML = "&lt;msg&gt;&lt;localId&gt;2376&lt;/localId&gt;&lt;/msg&gt;";
XMLAssert.assertXMLEqual("comparing test xml to control xml", myControlXML, myTestXML);
XMLAssert.assertXMLNotEqual("test xml not similar to control xml", myControlXML, myTestXML);
}
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=14&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/10/14/xmlunit-and-testng/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring JMX Challenges</title>
		<link>http://nelz.net/2008/10/10/spring-jmx-challenges/</link>
		<comments>http://nelz.net/2008/10/10/spring-jmx-challenges/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 13:33:21 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=26</guid>
		<description><![CDATA[Yesterday I started to do some clean-up work around how we are using Spring and JMX in some of our webapps. We started off with a very basic configuration: ... &#60;bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"&#62; &#60;property name="beans"&#62; &#60;map&#62; &#60;entry key="OurApp:name=beanName" value-ref="beanReference"/&#62; ... &#60;/map&#62; &#60;/property&#62; &#60;/bean&#62; ... By default, this exposes all public methods for management, which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=26&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I started to do some clean-up work around how we are using <a class="external" href="http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html">Spring</a><img class="outlink" src="images/out.png" alt="" /> and <a class="external" href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX</a><img class="outlink" src="images/out.png" alt="" /> in some of our webapps.</p>
<p>We started off with a very basic configuration:
</p>
<pre>
...
&lt;bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"&gt;
&lt;property name="beans"&gt;
&lt;map&gt;
&lt;entry key="OurApp:name=beanName" value-ref="beanReference"/&gt;
...
&lt;/map&gt;
&lt;/property&gt;
&lt;/bean&gt;
...
</pre>
<p>By default, <a class="external" href="http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html#jmx-interface">this exposes all public methods</a><img class="outlink" src="images/out.png" alt="" /> for management, which is overkill for us.  So I wanted to use the <a class="external" href="http://static.springframework.org/spring/docs/2.5.x/reference/jmx.html#jmx-interface-annotations">Java 5 Annotation capabilities</a><img class="outlink" src="images/out.png" alt="" /> to expose only those methods that are appropriate for management.  This brought us to the following configuration:
</p>
<pre>
...
&lt;bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"&gt;
&lt;property name="assembler" ref="assembler"/&gt;
&lt;property name="beans"&gt;
&lt;map&gt;
&lt;entry key="OurApp:name=beanName" value-ref="beanReference"/&gt;
...
&lt;/map&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id="jmxAttributeSource"
class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/&gt;
&lt;bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler"&gt;
&lt;property name="attributeSource" ref="jmxAttributeSource"/&gt;
&lt;/bean&gt;
...
</pre>
<p>This worked for <b>most</b> of the beans, but when I tried to port this one bean to the new Annotation-based interface definition, I kept getting a nasty stack-trace upon startup, the root of which says &quot;<tt>MetadataMBeanInfoAssembler does not support JDK dynamic proxies - export the target beans directly or use CGLIB proxies instead</tt>&quot;.
</p>
<p>I couldn&#8217;t figure out for the life of me what the structural difference was between this one bean, and all the others&#8230; I tried changing around the other annotations in the class, substituting other beans from the same layer, everything.  I couldn&#8217;t figure it out.
</p>
<p>After a bit, I decided to give up on adding the Annotations to that one bean, but I still wanted to expose the bean.  I couldn&#8217;t find documentation on this, but it turns out that you are completely able to have <i>multiple</i> &quot;exporters&quot; invoked in your Spring configuration files.  This gave me a configuration like this:
</p>
<pre>
...
&lt;bean id="exporter1" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"&gt;
&lt;property name="assembler" ref="assembler"/&gt;
&lt;property name="beans"&gt;
&lt;map&gt;
&lt;entry key="OurApp:name=beanName" value-ref="beanReference"/&gt;
...
&lt;/map&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id="exporter2" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false"&gt;
&lt;property name="beans"&gt;
&lt;map&gt;
&lt;entry key="OurApp:name=problemBeanName" value-ref="problemBeanReference"/&gt;
&lt;/map&gt;
&lt;/property&gt;
&lt;/bean&gt;
&lt;bean id="jmxAttributeSource"
class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource"/&gt;
&lt;bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler"&gt;
&lt;property name="attributeSource" ref="jmxAttributeSource"/&gt;
&lt;/bean&gt;
...
</pre>
<p>Great. This worked. I was able to manage the problem bean, and I was able to define the interface to all the other beans via the Annotations.  But, when I went to manage the problem bean via the JMX console, there were all sort of dynamic proxy methods exposed&#8230;
</p>
<p>This got me thinking back to the stack trace:
</p>
<pre>
~MetadataMBeanInfoAssembler does not support JDK dynamic proxies - export the target beans directly or use CGLIB proxies instead
</pre>
<p>&#8230; I definitely see other traces of dynamic proxying in the JMX interface itself.
</p>
<p>Then it hit me: <a class="external" href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html">AOP</a><img class="outlink" src="images/out.png" alt="" />.  The one thing that was different between the problem bean and all the other beans is that the problem bean is being AOP&#8217;ed.
</p>
</p>
<p>Doing some research on that stack trace error message, I found <a class="external" href="http://forum.springframework.org/showthread.php?t=14349">this discussion</a><img class="outlink" src="images/out.png" alt="" />. They seem to have figured out there&#8217;s a conflict with the <tt>MetadataMBeanInfoAssembler</tt> and dynamically proxied classes, but I&#8217;m still unclear (until further testing) if the suggestion to &quot;set the proxyTargetClass property of your ProxyFactoryBean to true&quot; will work.
</p>
<p>In summation, here are the learnings:
</p>
<ol>
<li> <tt>MetadataMBeanInfoAssembler</tt> is challenged with defining an interface based on Annotations of an AOP&#8217;ed class.
</li>
<li> It is trivial to define multiple <tt>MBeanExporter</tt>&#8216;s with different configurations if you need to.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=26&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/10/10/spring-jmx-challenges/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Back in Action!</title>
		<link>http://nelz.net/2008/09/09/back-in-action/</link>
		<comments>http://nelz.net/2008/09/09/back-in-action/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 20:11:02 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=28</guid>
		<description><![CDATA[I am now back from Burning Man, and having a fairly smooth re-adjustment to this so called real world. Spring AOP and Internal Method Calls When using AspectJ with Spring&#8217;s AOP framework, I didn&#8217;t realize that there were challenges getting AOP to work when a member method calls to a sibling method. Here&#8217;s an example [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=28&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am now back from <a class="external" href="http://www.burningman.com">Burning Man</a><img class="outlink" src="images/out.png" alt="" />, and having a fairly smooth re-adjustment to this so called <i>real world</i>.</p>
<h4>Spring AOP and Internal Method Calls</h4>
<p>When using <a class="external" href="http://www.eclipse.org/aspectj/">AspectJ</a><img class="outlink" src="images/out.png" alt="" /> with <a class="external" href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html">Spring&#8217;s AOP</a><img class="outlink" src="images/out.png" alt="" /> framework, I didn&#8217;t realize that there were challenges getting AOP to work when a member method calls to a sibling method.</p>
<p>Here&#8217;s an example I&#8217;ve borrowed from <a class="external" href="http://forum.springframework.org/showthread.php?t=16896">some discussion</a><img class="outlink" src="images/out.png" alt="" /> of <a class="external" href="http://forum.springframework.org/showthread.php?t=9926">this phenomenon</a><img class="outlink" src="images/out.png" alt="" />:
</p>
<pre>
public class MyService {
public methodA()
{
//do something
methodB();
//do something
}
public methodB()
{
//do something else
}
}
</pre>
<p><i>Now both the method in the service have been AOPed, and when I call the methodA() on the proxied instance, the methodA() will have the benefit of the aspect, but when the methodB() gets called from methodA(), it would not get that benefit of AOP.</i>
</p>
<p>Used strategically, I think this can be a benefit.  When I came upon this problem, I basically used it as an opportunity to refactor &quot;methodB&quot; (and it&#8217;s associated overhead) into a new stand-alone class. This may not always solve your specific problem, but it worked in my one case so far.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=28&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/09/09/back-in-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Applying the Java Keyword &#8216;final&#8217; To Classes</title>
		<link>http://nelz.net/2008/05/21/applying-the-java-keyword-final-to-classes/</link>
		<comments>http://nelz.net/2008/05/21/applying-the-java-keyword-final-to-classes/#comments</comments>
		<pubDate>Wed, 21 May 2008 18:11:26 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=30</guid>
		<description><![CDATA[I was ponderin&#8217; the usages of the final keyword as applied to classes in Java. I have heard before that all classes should be defined as final by default. The theory goes that unless you are specifically designing (and testing) your classes as potentially extensible, the final class modifier is a nice &#8216;pertinent negative&#8217;. In [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=30&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was ponderin&#8217; the usages of the <tt>final</tt> keyword as applied to classes in Java.</p>
<p>I have heard before that all classes should be defined as <tt>final</tt> by default.  The theory goes that unless you are specifically designing (and <i>testing</i>) your classes as potentially extensible, the <tt>final</tt> class modifier is a nice &#8216;pertinent negative&#8217;.
</p>
<p>In practice, this theory falls apart.
</p>
<p>If you are exposing your concrete classes to other clients, a final class can neuter the consumer&#8217;s ability to mock your class for testing purposes.  (I ran into this at one point when using <a class="external" href="http://lucene.apache.org/java/">Lucene</a><img class="outlink" src="images/out.png" alt="" /> at work, and tried to mock out a class.)
</p>
<p>Another problem that arises, even if you have hidden all your concrete classes behind a nice API, is that <tt>final</tt> classes are not accessible by <a class="external" href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">AOP</a><img class="outlink" src="images/out.png" alt="" />. (At least, not in the <a class="external" href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-proxying">framework</a><img class="outlink" src="images/out.png" alt="" /> that I looked into.)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/30/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/30/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=30&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/05/21/applying-the-java-keyword-final-to-classes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Revelation of the Day</title>
		<link>http://nelz.net/2008/05/13/revelation-of-the-day/</link>
		<comments>http://nelz.net/2008/05/13/revelation-of-the-day/#comments</comments>
		<pubDate>Tue, 13 May 2008 23:36:28 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=33</guid>
		<description><![CDATA[This revelation hit me (and my coworkers) today: Caching is a cross-cutting concern&#8230; You many not understand the implications of that phrase, but it leads to some interesting stuff&#8230;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=33&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This revelation hit me (and my coworkers) today:  Caching is a <i>cross-cutting concern</i>&#8230;</p>
<p>You many not understand the implications of that phrase, but it leads to <a class="external" href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">some interesting stuff</a><img class="outlink" src="images/out.png" alt="" />&#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=33&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/05/13/revelation-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Tomcat ROOT Context</title>
		<link>http://nelz.net/2008/05/11/tomcat-root-context/</link>
		<comments>http://nelz.net/2008/05/11/tomcat-root-context/#comments</comments>
		<pubDate>Sun, 11 May 2008 11:04:07 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=37</guid>
		<description><![CDATA[I&#8217;ve been fighting with Tomcat a bunch this week. My specific challenges have been around configuring a webapp to have the context root of &#34;/&#34;, without having to name it ROOT.war&#8230; The documentation page on context configuration says that &#34;Context elements may be explicitly defined&#34;: in the $CATALINA_HOME/conf/context.xml file- the Context element information will be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=37&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been <a class="external" href="http://twitter.com/nelz9999/statuses/806688758">fighting</a><img class="outlink" src="images/out.png" alt="" /> with <a class="external" href="http://tomcat.apache.org">Tomcat</a><img class="outlink" src="images/out.png" alt="" /> a bunch this week.</p>
<p>My specific challenges have been around configuring a webapp to have the context root of &quot;/&quot;, without having to name it ROOT.war&#8230;
</p>
<p>The documentation page on <a class="external" href="http://tomcat.apache.org/tomcat-5.5-doc/config/context.html">context configuration</a><img class="outlink" src="images/out.png" alt="" /> says that &quot;Context elements may be explicitly defined&quot;:
</p>
<ul>
<li> in the <tt>$CATALINA_HOME/conf/context.xml</tt> file- the Context element information will be loaded by all webapps
</li>
<li> in the <tt>$CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default</tt> file- the Context element information will be loaded by all webapps of that host
</li>
<li> in individual files (with a <tt>.xml</tt> extension) in the <tt>$CATALINA_HOME/conf/[enginename]/[hostname]/</tt> directory. The name of the file (less the <tt>.xml</tt>) extension will be used as the context path. Multi-level context paths may be defined using #, e.g. <tt>context#path.xml</tt>. The default web application may be defined by using a file called <tt>ROOT.xml</tt>.
</li>
<li> if the previous file was not found for this application, in an individual file at <tt>/META-INF/context.xml</tt> inside the application files
</li>
<li> inside a Host element in the main <tt>conf/server.xml</tt>
</li>
</ul>
<p>In my experience this week, the option of creating the file <tt>$CATALINA_HOME/conf/[enginename]/[hostname]/ROOT.xml</tt> didn&#8217;t work for me.
</p>
<p>But, one of my coworkers (Chris) found some other resource somewhere that said you could create a <tt>$CATALINA_HOME/webapps/ROOT.xml</tt> that looked like this:
</p>
<pre>
&lt;?xml version='1.0' encoding='utf-8'?&gt;
&lt;Context docBase="/absolute/path/to/your/webapp/dir"&gt;
&lt;/Context&gt;
</pre>
<p>Chris tried this setup, and it seemed to work for him.  Here&#8217;s my caveats:
</p>
<ol>
<li> I haven&#8217;t verified this myself yet.
</li>
<li> I&#8217;m not sure if it has to be an exploded WAR file structure, or if it can be a WAR file itself.
</li>
</ol>
<p>I will update if I find that this actually does work. </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=37&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/05/11/tomcat-root-context/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Helpful Maven Command: &#8220;mvn dependency:tree&#8221;</title>
		<link>http://nelz.net/2008/04/30/helpful-maven-command-mvn-dependencytree/</link>
		<comments>http://nelz.net/2008/04/30/helpful-maven-command-mvn-dependencytree/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 23:49:05 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=40</guid>
		<description><![CDATA[Sometimes you need to peruse the dependencies (and transitive dependencies) within your Maven project. The &#34;mvn site&#34; command generates a pretty nice version of this in HTML. (Example: Jetty Maven Plugin &#8211; Depenencies Report.) Well, the good news is that you don&#8217;t need to go through the whole &#34;mvn site&#34; generation to find out this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=40&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to peruse the dependencies (and transitive dependencies) within your Maven project.  The &quot;mvn site&quot; command generates a pretty nice version of this in HTML. (Example: <a class="external" href="http://mojo.codehaus.org/jetty-maven-plugin/dependencies.html">Jetty Maven Plugin &#8211; Depenencies Report</a><img class="outlink" src="images/out.png" alt="" />.)</p>
<p>Well, the good news is that you don&#8217;t need to go through the whole &quot;mvn site&quot; generation to find out this information, as the &quot;dependency&quot; plugin can provide this information to you via the command-line.
</p>
<pre>
% mvn dependency:tree
</pre>
<p>Here is (a part) of the output from one of the projects I&#8217;m working on:
</p>
<pre>[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building SomeCompany :: Main Webapp
[INFO]    task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree]
[INFO] com.somecompany:somecompany:war:1.0-SNAPSHOT
[INFO] +- com.somecompany:backend:jar:1.0-SNAPSHOT:compile
[INFO] |  +- mysql:mysql-connector-java:jar:5.0.4:runtime
[INFO] |  +- antlr:antlr:jar:2.7.6:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.3:compile
[INFO] |  +- commons-dbcp:commons-dbcp:jar:1.2.1:compile
[INFO] |  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] |  +- commons-httpclient:commons-httpclient:jar:3.0:compile
[INFO] |  |  \- junit:junit:jar:3.8.1:compile
[INFO] |  +- commons-lang:commons-lang:jar:2.3:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.0.4:compile
[INFO] |  +- commons-pool:commons-pool:jar:1.3:compile
[INFO] |  +- dom4j:dom4j:jar:1.6:compile
[INFO] |  +- net.sf.ehcache:ehcache:jar:1.4.0:compile
[INFO] |  |  +- net.sf.jsr107cache:jsr107cache:jar:1.0:compile
[INFO] |  |  \- backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[INFO] |  +- org.hibernate:hibernate-annotations:jar:3.2.0.ga:compile
[INFO] |  |  +- org.hibernate:hibernate:jar:3.2.0.ga:compile
[INFO] |  |  |  +- javax.transaction:jta:jar:1.0.1B:compile
[INFO] |  |  |  +- asm:asm-attrs:jar:1.5.3:compile
[INFO] |  |  |  +- cglib:cglib:jar:2.1_3:compile
[INFO] |  |  |  \- asm:asm:jar:1.5.3:compile
[INFO] |  |  \- javax.persistence:persistence-api:jar:1.0:compile
[INFO] |  +- jdom:jdom:jar:1.0:compile
[INFO] |  +- ognl:ognl:jar:2.6.7:compile
[INFO] |  +- rome:rome:jar:0.9:compile
[INFO] |  +- org.springframework:spring:jar:1.2.7:compile
[INFO] |  +- net.sourceforge.stripes:stripes:jar:1.4.3:compile
[INFO] |  +- velocity:velocity:jar:1.5:compile
[INFO] |  |  \- oro:oro:jar:2.0.8:compile
[INFO] |  +- org.json:json:jar:20070829:compile
[INFO] |  +- org.htmlparser:htmlparser:jar:1.6:compile
[INFO] |  +- javax.mail:mail:jar:1.4:compile
[INFO] |  |  \- javax.activation:activation:jar:1.1:compile
[INFO] |  \- org.safehaus:jug:jar:2.0.0:compile
[INFO] +- javax.servlet:jstl:jar:1.1.2:compile
[INFO] +- taglibs:standard:jar:1.1.2:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- com.oreilly.servlet:cos:jar:1.0:compile
[INFO] +- c3p0:c3p0:jar:0.9.1.2:compile
[INFO] +- jaxen:jaxen:jar:1.1-beta-7:compile
[INFO] |  +- xerces:xmlParserAPIs:jar:2.6.2:compile
[INFO] |  +- xerces:xercesImpl:jar:2.6.2:compile
[INFO] |  \- xom:xom:jar:1.0b3:compile
[INFO] |     +- com.ibm.icu:icu4j:jar:2.6.1:compile
[INFO] |     +- xalan:xalan:jar:2.6.0:compile
[INFO] |     \- org.ccil.cowan.tagsoup:tagsoup:jar:0.9.7:compile
[INFO] +- javax.sql:jdbc-stdext:jar:2.0:compile
[INFO] +- org.apache.lucene:lucene-core:jar:1.9.1:compile
[INFO] +- quartz:quartz:jar:1.5.1:compile
[INFO] +- commons-collections:commons-collections:jar:3.2:compile
[INFO] +- org.apache.avalon.logkit:avalon-logkit:jar:2.2.1:compile
[INFO] +- jgroups:jgroups-all:jar:2.6.1:compile
[INFO] \- log4j:log4j:jar:1.2.11:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Wed Apr 30 16:40:42 PDT 2008
[INFO] Final Memory: 12M/508M
[INFO] ------------------------------------------------------------------------
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=40&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/04/30/helpful-maven-command-mvn-dependencytree/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Java 5 FOREACH Syntax</title>
		<link>http://nelz.net/2008/04/16/java-5-foreach-syntax/</link>
		<comments>http://nelz.net/2008/04/16/java-5-foreach-syntax/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 21:35:50 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=46</guid>
		<description><![CDATA[For those that don&#8217;t currently use the new Java 5 &#34;foreach&#34; syntax, you are missing out. I got to a point today where I wanted to verify that the construct is doing the intelligent thing, so I wrote the following unit test: @Test public void forEachLoop() { for (String str : doHeavyWeigthMethod()) { System.out.println(str); } [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=46&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For those that don&#8217;t currently use the new Java 5 &quot;foreach&quot; syntax, you are missing out.</p>
<p>I got to a point today where I wanted to verify that the construct is doing the intelligent thing, so I wrote the following unit test:
</p>
<pre>
@Test
public void forEachLoop() {
for (String str : doHeavyWeigthMethod()) {
System.out.println(str);
}
}
private List&lt;String&gt; doHeavyWeigthMethod() {
System.out.println("heavyMethod");
final List&lt;String&gt; results = new ArrayList&lt;String&gt;();
results.add("one");
results.add("two");
results.add("three");
return results;
}
</pre>
<p>I was psyched to see the output:
</p>
<pre>
heavyMethod
one
two
three
</pre>
<p>Basically, this shows that the foreach construct only evaluates the collection once and caches the value to be used in each iteration.
</p>
<p>However, the construct is not without some pitfalls. I would have expected the new construct to be programmed more defensively, but it is still susceptible to <tt>NullPointerException</tt>.  Running the following throws the NPE:
</p>
<pre>
@Test
public void forEachLoop() {
for (String str : doHeavyWeigthMethod()) {
System.out.println(str);
}
}
private List&lt;String&gt; doHeavyWeigthMethod() {
return null;
}
</pre>
<p>So, unless you know you are in control of the method you are calling in the expression part of the &quot;foreach&quot; construct, you still need to defensively check for <tt>null</tt>.  And, <a class="external" href="http://nelz.net/roller/nelz/entry/heavyweight_syntax">we all know how much I love that</a><img class="outlink" src="images/out.png" alt="" />, right? </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/46/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/46/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=46&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/04/16/java-5-foreach-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
		<item>
		<title>Heavyweight Syntax</title>
		<link>http://nelz.net/2008/04/11/heavyweight-syntax/</link>
		<comments>http://nelz.net/2008/04/11/heavyweight-syntax/#comments</comments>
		<pubDate>Fri, 11 Apr 2008 11:33:08 +0000</pubDate>
		<dc:creator>nelz9999</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://nelznet.wordpress.com/?p=276</guid>
		<description><![CDATA[Method chaining seems like such a good idea. And Java supports it, always has. However, if you have been bitten in the butt too often by code you can&#8217;t (or don&#8217;t) control, you learn the value of defensive programming. Whereas, I want to write code like this: public String getDeepString(ComplexObjectA a) { return a.getComplexObjectB().toString(); } [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=276&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Method chaining seems like such a good idea.  And Java supports it, always has.  However, if you have been bitten in the butt too often by code you can&#8217;t (or don&#8217;t) control, you learn the value of <a class="external" href="http://thediscoblog.com/2008/02/18/defensive-programming-is-so-groovy/">defensive programming</a><img class="outlink" src="images/out.png" alt="" />.</p>
<p>Whereas, I want to write code like this:
</p>
<pre>
public String getDeepString(ComplexObjectA a) {
return a.getComplexObjectB().toString();
}
</pre>
<p>&#8230; I can&#8217;t.  Or at least it&#8217;s not a good idea to write it like that.  To protect myself, or classes that utilize my method, I have to write it like this:
</p>
<pre>
public String getDeepString(ComplexObjectA a) {
String result = null;
if (a != null) {
ComplexObjectB b = a.getComplexObjectB();
if (b != null) {
result = b.toString();
}
}
return result;
}
</pre>
<p>Wash. Rinse. Repeat.  Over and over and over, I&#8217;m checking for null.  And, I&#8217;m getting kind of tired of it.
</p>
<p>But wait, what light over yon hill breaks?  Is it <a class="external" href="http://groovy.codehaus.org/">Groovy</a><img class="outlink" src="images/out.png" alt="" />?!?  Groovy provides a fantastic &quot;<a class="external" href="http://groovy.codehaus.org/Operators#Operators-SafeNavigationOperator%28%3F.%29">?.</a><img class="outlink" src="images/out.png" alt="" />&quot; construct, which can reduce the above noisy code to nearly what I was hoping for in my first example:
</p>
<pre>
public String getDeepString(ComplexObjectA a) {
return a?.getComplexObjectB()?.toString();
}
</pre>
<p>I showed the &quot;<a class="external" href="http://thediscoblog.com/2008/03/07/unadulterated-java-is-so-groovy/">Unadulterated Java is so groovy</a><img class="outlink" src="images/out.png" alt="" />&quot; post to some of my coworkers, and the &quot;?.&quot; construct is the single most talked about benefit of potentially adopting Groovy.
</p>
<p>No, we haven&#8217;t adopted Groovy yet.  We&#8217;ve got some work to do, including moving toward a <a class="external" href="http://maven.apache.org">Maven</a><img class="outlink" src="images/out.png" alt="" /> (2) build system. But from what I hear the Groovy <a class="external" href="http://mojo.codehaus.org/groovy/">plugins to Maven</a><img class="outlink" src="images/out.png" alt="" /> and <a class="external" href="http://www.jetbrains.com/idea/features/groovy_grails.html">IntelliJ</a><img class="outlink" src="images/out.png" alt="" /> make dropping in Groovy transparent and easy.  We may become a Groovy shop yet!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nelznet.wordpress.com/276/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nelznet.wordpress.com/276/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nelznet.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nelznet.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/nelznet.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/nelznet.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nelznet.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nelznet.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nelznet.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nelznet.wordpress.com/276/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nelz.net&#038;blog=8173157&#038;post=276&#038;subd=nelznet&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://nelz.net/2008/04/11/heavyweight-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f992f247f63ba6ca6e0e0c3fa5726f72?s=96&#38;d=monsterid&#38;r=G" medium="image">
			<media:title type="html">nelz9999</media:title>
		</media:content>
	</item>
	</channel>
</rss>
