<?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"
	>

<channel>
	<title>Rockhopper Blog</title>
	<atom:link href="http://rockhoppertech.com/blogs/feed" rel="self" type="application/rss+xml" />
	<link>http://rockhoppertech.com/blogs</link>
	<description>Java development tips</description>
	<pubDate>Wed, 10 Mar 2010 13:58:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Apache Wink</title>
		<link>http://rockhoppertech.com/blogs/archives/67</link>
		<comments>http://rockhoppertech.com/blogs/archives/67#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:58:57 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[Maven]]></category>

		<category><![CDATA[REST]]></category>

		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=67</guid>
		<description><![CDATA[Apache Wink is an incubating project that will allow you to write RESTful JAX-RS (JSR-311) web apps - like Jersey.
Read what Dr. Fielding has to say about what is REST and what&#8217;s not.
DeveloperWorks has a recent article on Apache Wink. They do a commendable thing by giving instructions on how to &#8220;materialize&#8221; the maven projects [...]]]></description>
			<content:encoded><![CDATA[<p>Apache Wink is an incubating project that will allow you to write RESTful JAX-RS (JSR-311) web apps - like <a href="https://jersey.dev.java.net/">Jersey</a>.</p>
<p>Read what Dr. Fielding has to say <a href="http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven">about what is REST</a> and what&#8217;s not.</p>
<p>DeveloperWorks has a recent <a href="http://www.ibm.com/developerworks/web/library/wa-useapachewink/">article </a>on Apache Wink. They do a commendable thing by giving instructions on how to &#8220;materialize&#8221; the maven projects that are Wink&#8217;s examples. No matter what I cannot materialize these projects. I have the current versions of Eclipse and the maven plug in. (And the screenshot does not match my dialog either).</p>
<p>So, if you want to give Wink a try you may be tempted to read their &#8220;<a href="http://incubator.apache.org/wink/1.0/html/3%20Getting%20Started%20with%20Apache%20Wink.html">guide</a>&#8221; . What you will find there is a lot of empty sections with TBD inserted (I guess that means &#8220;too bad, dummy&#8221;). Something like <a href="http://cwiki.apache.org/CXF20DOC/jax-rs.html">this </a>from CXF would have been nice.</p>
<p>Hell, just give me a simple pom.xml and I&#8217;ll figure it out. So where can you get one? Or at least just the artifact ids etc?</p>
<p>Turns out that you can grab the source for the examples from <a href="http://github.com/apache/wink">Github</a></p>
<p>Time to take a REST.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d67').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d67" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/67" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Apache+Wink&amp;url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/67" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/67&amp;new_comment=Apache+Wink&amp;new_comment=Apache+Wink&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Apache+Wink&amp;u=http://rockhoppertech.com/blogs/archives/67" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/67" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/67&amp;title=Apache+Wink" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/67" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/67&amp;t=Apache+Wink" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d67').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/67/feed</wfw:commentRss>
		</item>
		<item>
		<title>jetty maven version 7 beta woes</title>
		<link>http://rockhoppertech.com/blogs/archives/66</link>
		<comments>http://rockhoppertech.com/blogs/archives/66#comments</comments>
		<pubDate>Tue, 18 Aug 2009 17:52:59 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[Maven]]></category>

		<category><![CDATA[Spring Framework]]></category>

		<category><![CDATA[Jetty]]></category>

		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=66</guid>
		<description><![CDATA[So I gave the beta of the jetty maven plugin a try.
What I had was this:

&#60;groupId&#62;org.mortbay.jetty&#60;/groupId&#62;
&#60;artifactId&#62;maven-jetty-plugin&#60;/artifactId&#62;
&#60;version&#62;6.1.19&#60;/version&#62;

I changed it to this which is the most current available version in the repos:

&#60;artifactId&#62;jetty-maven-plugin&#60;/artifactId&#62;
&#60;version&#62;7.0.0.1beta3&#60;/version&#62;

N.B. for maximum cognitive dissonance the jetty guys thought it would be a good idea to swap some words in the name around. That&#8217;s not a [...]]]></description>
			<content:encoded><![CDATA[<p>So I gave the beta of the jetty maven plugin a try.</p>
<p>What I had was this:</p>
<pre>
&lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
&lt;artifactId&gt;maven-jetty-plugin&lt;/artifactId&gt;
&lt;version&gt;6.1.19&lt;/version&gt;
</pre>
<p>I changed it to this which is the most current available version in the repos:</p>
<pre>
&lt;artifactId&gt;jetty-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;7.0.0.1beta3&lt;/version&gt;
</pre>
<p>N.B. for maximum cognitive dissonance the jetty guys thought it would be a good idea to swap some words in the name around. That&#8217;s not a typo.</p>
<p>Well it started.  Six count &#8216;em six minutes later. I made a change to my Java source and was welcomed with this:</p>
<pre>Unable to locate Spring NamespaceHandler for XML schema namespace etc. etc.</pre>
<p>And then jetty cratered and had to be killed then restarted. Hardly &#8220;agile&#8221; with a 6 minute start up time and all you want to do is save one Java file&#8230;</p>
<p>So I went through the usual: was the spring jar in question on the classpath? Was the spelling of the namespace in the XML config file correct? Was the maven assembly plugin doing bad things? Was etc. etc.etc.</p>
<p>The answer is NO. The problem is the plugin.</p>
<p>Back to version 6 for me.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d66').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d66" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/66" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=jetty+maven+version+7+beta+woes&amp;url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/66" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/66&amp;new_comment=jetty+maven+version+7+beta+woes&amp;new_comment=jetty+maven+version+7+beta+woes&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=jetty+maven+version+7+beta+woes&amp;u=http://rockhoppertech.com/blogs/archives/66" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/66" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/66&amp;title=jetty+maven+version+7+beta+woes" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/66" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/66&amp;t=jetty+maven+version+7+beta+woes" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d66').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/66/feed</wfw:commentRss>
		</item>
		<item>
		<title>Spring, BasicDataSource and OpenJPA</title>
		<link>http://rockhoppertech.com/blogs/archives/65</link>
		<comments>http://rockhoppertech.com/blogs/archives/65#comments</comments>
		<pubDate>Wed, 15 Jul 2009 16:17:04 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[JPA]]></category>

		<category><![CDATA[Spring Framework]]></category>

		<category><![CDATA[DataSource]]></category>

		<category><![CDATA[OpenJPA]]></category>

		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=65</guid>
		<description><![CDATA[So you want to use Spring with commons BasicDataSource and OpenJPA? There is an interesting gotcha.
Let&#8217;s start with just the DriverManager DataSource for comparison. In your spring context you define the datasource like this:
&#60;bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="org.hsqldb.jdbcDriver"
p:url="jdbc:hsqldb:hsql://localhost:9001/testdb" p:username="sa"
p:password="" /&#62;
Then your EntityManager Factory:
&#60;bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&#62;
&#60;property name="dataSource" ref="dataSource" /&#62;
&#60;property name="persistenceUnitName" value="jpamaven-test" /&#62;
&#60;property name="loadTimeWeaver"&#62;
&#60;bean
class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" /&#62;
&#60;/property&#62;

&#60;property name="jpaVendorAdapter"&#62;
&#60;bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"&#62;
&#60;property name="showSql" value="true" /&#62;
&#60;property name="generateDdl" [...]]]></description>
			<content:encoded><![CDATA[<p>So you want to use Spring with commons BasicDataSource and OpenJPA? There is an interesting gotcha.</p>
<p>Let&#8217;s start with just the DriverManager DataSource for comparison. In your spring context you define the datasource like this:</p>
<pre>&lt;bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="org.hsqldb.jdbcDriver"
p:url="jdbc:hsqldb:hsql://localhost:9001/testdb" p:username="sa"
p:password="" /&gt;</pre>
<p>Then your EntityManager Factory:</p>
<pre>&lt;bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
&lt;property name="dataSource" ref="dataSource" /&gt;
&lt;property name="persistenceUnitName" value="jpamaven-test" /&gt;
&lt;property name="loadTimeWeaver"&gt;
&lt;bean
class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" /&gt;
&lt;/property&gt;

&lt;property name="jpaVendorAdapter"&gt;
&lt;bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter"&gt;
&lt;property name="showSql" value="true" /&gt;
&lt;property name="generateDdl" value="true" /&gt;
&lt;property name="database" value="HSQL" /&gt;
&lt;property name="databasePlatform" value="org.apache.openjpa.jdbc.sql.HSQLDictionary" /&gt;
&lt;/bean&gt;
&lt;/property&gt;
&lt;property name="jpaPropertyMap"&gt;
&lt;map&gt;
&lt;entry key="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" /&gt;
&lt;entry key="openjpa.ConnectionURL" value="jdbc:hsqldb:hsql://localhost:9001/testdb" /&gt;
&lt;entry key="openjpa.ConnectionUserName" value="sa" /&gt;
&lt;entry key="openjpa.ConnectionPassword" value="" /&gt;

&lt;entry key="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add', ForeignKeys=true)" /&gt;
&lt;entry key="openjpa.jdbc.DBDictionary" value="hsql" /&gt;
&lt;entry key="openjpa.jdbc.Schema" value="PUBLIC" /&gt;
&lt;entry key="openjpa.Log"
value="DefaultLevel=TRACE, Runtime=TRACE, Tool=TRACE, SQL=TRACE" /&gt;
&lt;entry key="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72" /&gt;
&lt;/map&gt;
&lt;/property&gt;
&lt;property name="jpaDialect" ref="jpaDialect" /&gt;
&lt;/bean&gt;</pre>
<p>Here META-INF/persistence.xml is almost empty because all the properties are specified here in Spring. See the <a href="http://static.springsource.org/spring/docs/2.5.x/reference/orm.html#orm-jpa-setup-lcemfb">Spring docs</a> for more info.</p>
<p>The trouble starts when you change your datasource to this:</p>
<pre>&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" p:driverClassName="org.hsqldb.jdbcDriver"
p:url="jdbc:hsqldb:hsql://localhost:9001/testdb" p:username="sa"
p:password="" /&gt;</pre>
<p>It &#8220;should&#8221; just work. No such luck. To make a long story short you have to change the openjpa properties.</p>
<p>Here is the combination that works.</p>
<pre>&lt;property name="jpaPropertyMap"&gt;
&lt;map&gt;
&lt;entry key="openjpa.ConnectionDriverName" value="org.apache.commons.dbcp.BasicDataSource" /&gt;
&lt;entry key="openjpa.ConnectionProperties"
value="DriverClassName=org.hsqldb.jdbcDriver,Url=jdbc:hsqldb:hsql://localhost:9001/testdb,Username=sa,Password=" /&gt;

&lt;entry key="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add', ForeignKeys=true)" /&gt;
&lt;entry key="openjpa.jdbc.DBDictionary" value="hsql" /&gt;
&lt;entry key="openjpa.jdbc.Schema" value="PUBLIC" /&gt;
&lt;entry key="openjpa.Log"
value="DefaultLevel=TRACE, Runtime=TRACE, Tool=TRACE, SQL=TRACE" /&gt;
&lt;entry key="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72" /&gt;
&lt;/map&gt;
&lt;/property&gt;</pre>
<p>You have to gang up four properties into openjpa.ConnectionProperties. Intuitive huh?</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d65').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d65" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/65" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Spring%2C+BasicDataSource+and+OpenJPA&amp;url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/65" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/65&amp;new_comment=Spring%2C+BasicDataSource+and+OpenJPA&amp;new_comment=Spring%2C+BasicDataSource+and+OpenJPA&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Spring%2C+BasicDataSource+and+OpenJPA&amp;u=http://rockhoppertech.com/blogs/archives/65" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/65" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/65&amp;title=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/65" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/65&amp;t=Spring%2C+BasicDataSource+and+OpenJPA" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d65').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/65/feed</wfw:commentRss>
		</item>
		<item>
		<title>Spring Test Framework CoC suggestion</title>
		<link>http://rockhoppertech.com/blogs/archives/64</link>
		<comments>http://rockhoppertech.com/blogs/archives/64#comments</comments>
		<pubDate>Mon, 13 Jul 2009 16:42:56 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[Spring Framework]]></category>

		<category><![CDATA[Testing]]></category>

		<category><![CDATA[junit]]></category>

		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=64</guid>
		<description><![CDATA[Let&#8217;s say you&#8217;re using JUnit 4 and the Spring Testing classes (the 2.5+ versions) for your unit tests. You can specify parameters as shown in the TransactionConfiguration annotation as shown in this example. But you can also get away with leaving them out in a nod to the uberhip Convention Over Configuration gods as shown [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you&#8217;re using JUnit 4 and the Spring Testing classes (the 2.5+ versions) for your unit tests. You can specify parameters as shown in the TransactionConfiguration annotation as shown in this example. But you can also get away with leaving them out in a nod to the uberhip Convention Over Configuration gods as shown in ContextConfigurations</p>
<pre>
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
@Transactional
public class UserServiceTest extends
AbstractTransactionalJUnit4SpringContextTests {
</pre>
<p>So here the context will be loaded by classname-context.xml (e.g. UserServiceTest-context.xml) in the same package as the test class. Cool! You can save your precious digits from typing a few characters.</p>
<p>Let&#8217;s say you have unit tests for the persistence layer too. So you have another config file named UserDAOTest-context.xml. And so on for all your other domain classes. Lots of config files that change only a little.</p>
<p>Maybe one has</p>
<pre>
&lt;aop:advisor pointcut="execution(* *..Service+.*(..))"
advice-ref="txAdvice" /&gt;
</pre>
<p>and another has</p>
<pre>
&lt;aop:advisor pointcut="execution(* *..DAO+.*(..))"
advice-ref="txAdvice" /&gt;
</pre>
<p>You&#8217;re also all wet. There is nothing DRY about this. You are repeating many things with the possibility of missing one. Case in point:<br />
I decided to try to define the datasource like this:</p>
<pre>
&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" p:driverClassName="org.hsqldb.jdbcDriver"
p:url="jdbc:hsqldb:hsql://localhost:9001/testdb" p:username="sa"
p:password="" /&gt;
</pre>
<p>instead of like this:</p>
<pre>
&lt;bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="org.hsqldb.jdbcDriver" p:url="jdbc:hsqldb:hsql://localhost:9001/testdb"
p:username="sa" p:password="" /&gt;
</pre>
<p>Small trivial thing right? Except that I missed changing it in one of the config files. Well, what happens to the transaction rollback? Since I&#8217;m using AbstractTransactionalJUnit4SpringContextTests I want the junk I shoved into the DB in the @Before method (within the transaction) to be rolled back after the test method. Nope. Ain&#8217;t gonna happen. Do a check in @BeforeTransaction and verify in @AfterTransaction and you&#8217;ll see. But first you&#8217;ll waste a few hours tracking it down thinking the real problem is in one of those Spring XML/Annotation hell holes.</p>
<p>But what would happen if you decided to be unhip and say screw CoC in this case (avoiding a CoC up)?<br />
Something like this:</p>
<pre>
@ContextConfiguration(locations = { "classpath:com/rockhoppertech/example/test-context.xml" })
</pre>
<p>OMG you had to type more. And that&#8217;s so declasse!<br />
But then you wouldn&#8217;t have problems like I just described and you wouldn&#8217;t be repeating yourself all over the place like rainman.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d64').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d64" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/64" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Spring+Test+Framework+CoC+suggestion&amp;url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/64" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/64&amp;new_comment=Spring+Test+Framework+CoC+suggestion&amp;new_comment=Spring+Test+Framework+CoC+suggestion&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Spring+Test+Framework+CoC+suggestion&amp;u=http://rockhoppertech.com/blogs/archives/64" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/64" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/64&amp;title=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/64" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/64&amp;t=Spring+Test+Framework+CoC+suggestion" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d64').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/64/feed</wfw:commentRss>
		</item>
		<item>
		<title>Multiple Persistence Units - Websphere v7, OpenJPA</title>
		<link>http://rockhoppertech.com/blogs/archives/63</link>
		<comments>http://rockhoppertech.com/blogs/archives/63#comments</comments>
		<pubDate>Wed, 08 Jul 2009 14:45:31 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[JPA]]></category>

		<category><![CDATA[Websphere]]></category>

		<category><![CDATA[OpenJPA]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=63</guid>
		<description><![CDATA[Want to do something exotic like specifying two persistence units in your persistence.xml file? Perhaps one local and one JTA managed. Maybe even go whole hog and do that to write unit tests?
In Websphere v7 (RAD 7.5) when you have multiple PUs in persistence.xml it barfs like this:

[7/8/09 10:01:55:149 EDT] 00000053 servlet       I com.ibm.ws.webcontainer.servlet.ServletWrapper init [...]]]></description>
			<content:encoded><![CDATA[<p>Want to do something exotic like specifying two persistence units in your persistence.xml file? Perhaps one local and one JTA managed. Maybe even go whole hog and do that to write unit tests?</p>
<p>In Websphere v7 (RAD 7.5) when you have multiple PUs in persistence.xml it barfs like this:</p>
<pre>
[7/8/09 10:01:55:149 EDT] 00000053 servlet       I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [someAppEAR] [/someAppJPAWeb] [/someAppUsersTable.jsp]: Initialization successful.
[7/8/09 10:01:55:227 EDT] 00000053 JPAApplInfo   E   CWWJP0012E: The persistence unit name is not specified and a unique persistence unit is not found in the someAppEAR application and someAppJPAWeb.war module.
[7/8/09 10:01:55:227 EDT] 00000053 JPAApplInfo   E   CWWJP0029E: The server cannot find the "" persistence unit in the someAppJPAWeb.war module and the someAppEAR application.
[7/8/09 10:01:55:227 EDT] 00000053 InjectionBind E   CWNEN0035E: The someAppJPAWeb reference of type javax.persistence.EntityManagerFactory for the &lt;null&gt; component in the someAppJPAWeb.war module of the someAppEAR application cannot be resolved.
[7/8/09 10:01:55:242 EDT] 00000053 annotation    E com.ibm.ws.webcontainer.annotation.WASAnnotationHelper inject exception while injecting resource
</pre>
<p>Here is IBM&#8217;s &#8220;help&#8221;:<br />
http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/index.jsp?topic=com.ibm.websphere.wbpm.messages.620.doc/messages/com.ibm.ws.jpa.jpa.html</p>
<pre>
CWWJP0012E: The persistence unit name is not specified and a unique persistence unit is not found in the {0} application and {1} module.
Problem    The application has defined a persistence unit or persistence context reference without a persistence unit name and a unique persistence unit cannot be found.
User response    Change the application to specify a persistence unit name for the reference, or provide a unique persistence.
</pre>
<p>Yeah, huh? What&#8217;s that mean? A reference in web.xml? and what name for it?<br />
Can&#8217;t find the official answer anywhere. Let&#8217;s waste time searching and looking at logs and enjoying the wonderful WAS admin console.</p>
<p>OK, here is my answer.<br />
Let&#8217;s say the JTA PU you want to use in your web app is named</p>
<pre>
&lt;persistence-unit name="someAppJPAWeb"  transaction-type="JTA"&gt;
etc.
</pre>
<p>Then in web.xml create a PU reference:</p>
<pre>
&lt;persistence-unit-ref&gt;
&lt;description&gt;
Persistence unit for the someApp application.
&lt;/description&gt;
&lt;persistence-unit-ref-name&gt;persistence/someAppJPAWeb&lt;/persistence-unit-ref-name&gt;
&lt;persistence-unit-name&gt;someAppJPAWeb&lt;/persistence-unit-name&gt;
&lt;/persistence-unit-ref&gt;
</pre>
<p>In your injected class use the reference name:</p>
<pre>
@PersistenceUnit(name="persistence/someAppJPAWeb")
private EntityManagerFactory emf;
</pre>
<p>If you have just one PU then you don&#8217;t need the name attribute nor the persistence-unit-ref.</p>
<p>Of course when you are looking at persistence.xml RAD will helpfully tell you that it doesn&#8217;t like multiple persistence units.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d63').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d63" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/63" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA&amp;url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/63" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/63&amp;new_comment=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA&amp;new_comment=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA&amp;u=http://rockhoppertech.com/blogs/archives/63" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/63" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/63&amp;title=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/63" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/63&amp;t=Multiple+Persistence+Units+-+Websphere+v7%2C+OpenJPA" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d63').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/63/feed</wfw:commentRss>
		</item>
		<item>
		<title>JSF 2.0</title>
		<link>http://rockhoppertech.com/blogs/archives/62</link>
		<comments>http://rockhoppertech.com/blogs/archives/62#comments</comments>
		<pubDate>Tue, 02 Jun 2009 16:35:15 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[JSF]]></category>

		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=62</guid>
		<description><![CDATA[JSF 2.0 is out.
But there is still no maven love here: https://maven-repository.dev.java.net/nonav/repository/javax.faces/jars/
But over at JBoss we have something close:
&#60;dependency&#62;

&#60;groupId&#62;javax.faces&#60;/groupId&#62;

&#60;artifactId&#62;jsf-api&#60;/artifactId&#62;

&#60;version&#62;2.0.0-PR2_3&#60;/version&#62;

&#60;/dependency&#62;

&#60;dependency&#62;

&#60;groupId&#62;javax.faces&#60;/groupId&#62;

&#60;artifactId&#62;jsf-impl&#60;/artifactId&#62;

&#60;version&#62;2.0.0-PR2_3&#60;/version&#62;

&#60;/dependency&#62;
is in this repository:
&#60;repository&#62;

&#60;id&#62;maven.jboss.com&#60;/id&#62;

&#60;name&#62;jboss Repository for Maven&#60;/name&#62;

&#60;url&#62;http://repository.jboss.org/maven2&#60;/url&#62;

&#60;/repository&#62;
Looks like the ManagedBean annotation does not work though. So I tried it with the mojarra jars and did the mvn install:file chacha. Still no go.
So get the source and build [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jcp.org/en/jsr/detail?id=314">JSF 2.0</a> is out.</p>
<p>But there is still no maven love here: https://maven-repository.dev.java.net/nonav/repository/javax.faces/jars/</p>
<p>But over at JBoss we have something close:</p>
<pre>&lt;dependency&gt;

&lt;groupId&gt;javax.faces&lt;/groupId&gt;

&lt;artifactId&gt;jsf-api&lt;/artifactId&gt;

&lt;version&gt;2.0.0-PR2_3&lt;/version&gt;

&lt;/dependency&gt;

&lt;dependency&gt;

&lt;groupId&gt;javax.faces&lt;/groupId&gt;

&lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;

&lt;version&gt;2.0.0-PR2_3&lt;/version&gt;

&lt;/dependency&gt;</pre>
<p>is in this repository:</p>
<pre>&lt;repository&gt;

&lt;id&gt;maven.jboss.com&lt;/id&gt;

&lt;name&gt;jboss Repository for Maven&lt;/name&gt;

&lt;url&gt;http://repository.jboss.org/maven2&lt;/url&gt;

&lt;/repository&gt;</pre>
<p>Looks like the ManagedBean annotation does not work though. So I tried it with the mojarra jars and did the mvn install:file chacha. Still no go.</p>
<p>So get the <a href="https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=11414&amp;expandFolder=11414&amp;folderID=0">source</a> and build the jars yourself.</p>
<p>Update:</p>
<p>After I published the above they pushed a snapshot to the repo. Take a <a href="http://download.java.net/maven/2/com/sun/faces/">look here</a>:</p>
<p>They are using a different groupId so do this:</p>
<pre>&lt;dependency&gt;

&lt;groupId&gt;com.sun.faces&lt;/groupId&gt;

&lt;artifactId&gt;jsf-api&lt;/artifactId&gt;

&lt;version&gt;2.0.0-SNAPSHOT&lt;/version&gt;

&lt;/dependency&gt;

&lt;dependency&gt;

&lt;groupId&gt;com.sun.faces&lt;/groupId&gt;

&lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;

&lt;version&gt;2.0.0-SNAPSHOT&lt;/version&gt;

&lt;/dependency&gt;</pre>
<p>Verdict: It still fails the simplest @ManagedBean example.</p>
<p><strong>But I got it to finally work by doing a jetty:run-war instead of jetty:run.</strong></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d62').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d62" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/62" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=JSF+2.0&amp;url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/62" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/62&amp;new_comment=JSF+2.0&amp;new_comment=JSF+2.0&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=JSF+2.0&amp;u=http://rockhoppertech.com/blogs/archives/62" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/62" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/62&amp;title=JSF+2.0" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/62" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/62&amp;t=JSF+2.0" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d62').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/62/feed</wfw:commentRss>
		</item>
		<item>
		<title>Oracle buys Sun</title>
		<link>http://rockhoppertech.com/blogs/archives/61</link>
		<comments>http://rockhoppertech.com/blogs/archives/61#comments</comments>
		<pubDate>Tue, 21 Apr 2009 22:15:41 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=61</guid>
		<description><![CDATA[It&#8217;s official. Oracle will buy Sun.


Bookmark It



















Hide Sites



]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s official. <a href="http://www.sun.com/third-party/global/oracle/index.jsp">Oracle will buy Sun.</a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d61').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d61" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/61" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Oracle+buys+Sun&amp;url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/61" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/61&amp;new_comment=Oracle+buys+Sun&amp;new_comment=Oracle+buys+Sun&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Oracle+buys+Sun&amp;u=http://rockhoppertech.com/blogs/archives/61" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/61" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/61&amp;title=Oracle+buys+Sun" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/61" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/61&amp;t=Oracle+buys+Sun" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d61').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/61/feed</wfw:commentRss>
		</item>
		<item>
		<title>Jersey 1.0 and jetty:run</title>
		<link>http://rockhoppertech.com/blogs/archives/60</link>
		<comments>http://rockhoppertech.com/blogs/archives/60#comments</comments>
		<pubDate>Fri, 20 Mar 2009 15:33:57 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[REST]]></category>

		<category><![CDATA[SOA]]></category>

		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=60</guid>
		<description><![CDATA[If you are using maven and jetty you are probably simply invoking jetty:run with your Jersey web service.
Jersey is the JAX-RS (JSR 311) Reference Implementation for building RESTful Web services
The problem is you get this exception:
The ResourceConfig instance does not contain any root resource classes.
But you are sure you do have your resources. Here is [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using maven and jetty you are probably simply invoking jetty:run with your <a href="https://jersey.dev.java.net/">Jersey web service</a>.</p>
<p>Jersey is the JAX-RS (JSR 311) Reference Implementation for building RESTful Web services</p>
<p>The problem is you get this exception:</p>
<pre>The ResourceConfig instance does not contain any root resource classes.</pre>
<p>But you are sure you do have your resources. Here is an example:</p>
<pre>@Path("/rocky/")
public class RockyResource {
  @GET
  @Produces("text/plain")
  public String yo() {
    return "Yo Adrian!";
  }
}</pre>
<p>In pre 1.0 releases you used the annotations @ProduceMime(&#8221;text/plain&#8221;), @UriTemplate(&#8221;/rocky/&#8221;) and @HttpMethod(&#8221;GET&#8221;). These are the replacements for 1.0.</p>
<p>You think that Rest is so hip and happenin&#8217; that other people have had the same problem so you google the exception.</p>
<p>You then find this <a href="http://codebeneath.blogspot.com/2008/03/jersey-jetty-and-maven-style.html">blog post</a>. It was helpful but that was a preview release.</p>
<p>Here is a web.xml that will now work:</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;

&lt;display-name&gt;Jersey test&lt;/display-name&gt;

&lt;servlet&gt;
  &lt;servlet-name&gt;ServletContainer&lt;/servlet-name&gt;
  &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
    &lt;!-- multiple packages separated by ; --&gt;
      &lt;param-value&gt;com.rockhoppertech.jerseyServer&lt;/param-value&gt;
    &lt;/init-param&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;

&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;ServletContainer&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/resources/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;

&lt;/web-app&gt;
</pre>
<p>See the <a href="http://wiki.glassfish.java.net/attach/RESTfulWebServicesDevelopersGuide/p5.html">Glassfish Wiki </a>for details.</p>
<p>Here are the <a href="https://jsr311.dev.java.net/nonav/javadoc/index.html">javadocs </a>for the JSR. Since I&#8217;m posting links, if you are new to JSON here are some <a href="http://www.json.org/java/index.html">docs</a>.</p>
<p>If you created your maven app with the Jersey teams maven archetype then this wouldn&#8217;t have been a problem. You&#8217;d just have to delete stuff from the pom and insert the jetty stuff.</p>
<pre>
 mvn archetype:generate -DarchetypeCatalog=http://download.java.net/maven/2
</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d60').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d60" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/60" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Jersey+1.0+and+jetty%3Arun&amp;url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/60" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/60&amp;new_comment=Jersey+1.0+and+jetty%3Arun&amp;new_comment=Jersey+1.0+and+jetty%3Arun&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Jersey+1.0+and+jetty%3Arun&amp;u=http://rockhoppertech.com/blogs/archives/60" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/60" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/60&amp;title=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/60" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/60&amp;t=Jersey+1.0+and+jetty%3Arun" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d60').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/60/feed</wfw:commentRss>
		</item>
		<item>
		<title>Swing Drag and Drop on non supported components</title>
		<link>http://rockhoppertech.com/blogs/archives/59</link>
		<comments>http://rockhoppertech.com/blogs/archives/59#comments</comments>
		<pubDate>Thu, 12 Mar 2009 14:13:54 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[GUI]]></category>

		<category><![CDATA[Drag and Drop]]></category>

		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=59</guid>
		<description><![CDATA[The 1.4 release of Java SE introduced a much needed overhaul for the Drag and Drop subsystem. I sweated blood back in 1999 to make it reasonably work for a client&#8217;s requirements. That led to an hour long 1999 JavaOne talk (that was before the marketing crap seeped into JavaOne) and the now out of [...]]]></description>
			<content:encoded><![CDATA[<p>The 1.4 release of Java SE introduced a much needed overhaul for the Drag and Drop subsystem. I sweated blood back in 1999 to make it reasonably work for a client&#8217;s requirements. That led to an hour long 1999 JavaOne talk (that was before the marketing crap seeped into JavaOne) and the now out of date DnD FAQ.</p>
<p>Many components such as JList, JTextField and others now have DnD baked into them. You call setDragEnabled(true) and provide them with a TransferHandler. The more complicated components like JTable have lots of customization possible through new support classes.</p>
<p>But what about the non-supported components like a JLabel? Or even your own components?</p>
<p>There are <a href="http://www.roseindia.net/java/example/java/swing/SwingDragDrop.shtml">naiive approaches</a> to adding drag capabilities to a non-supported component.  This article actually rips off a <a href="http://java.sun.com/j2se/1.5.0/docs/guide/swing/1.4/dnd.html">Sun DnD document</a> without attribution (like the rest of the content on that site).  Here the drag is initiated on a mouse pressed event. Every other drag in the known universe is commenced after the mouse moves a bit. Additionally if you start the drag on a mouse press then you cannot notify listeners for any other mouse event since DnD takes over.</p>
<p>The real way it&#8217;s done is in the plaf layer. But maybe you just want a simple subclass of JComponent and don&#8217;t want to eat the whole MVC Swing elephant.</p>
<p>Take a look at Shannon Hickey&#8217;s excellent DnD contributions to the basic plaf. For recognizing the drag gesture take a look at javax.swing.plaf.basic.DragRecognitionSupport.</p>
<p>I borrowed some of his code for a simple JComponent subclass. First I enabled the events in the constructor like this.</p>
<pre>
this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
</pre>
<p>Then I added two instance variables and overrode the event processing methods. On mouse press I simply saved (into those two instance variables) the mouse event and retrieved the number of pixels that the user needs to move the mouse in order to initiate the drag. On mouse release I null out the event (and in the example do other non DnD related stuff).</p>
<pre>
private int motionThreshold = 5;
private MouseEvent dndArmedEvent;

@Override
protected void processMouseEvent(MouseEvent e) {
  switch (e.getID()) {
  case MouseEvent.MOUSE_PRESSED:
    this.dndArmedEvent = e;
    this.motionThreshold = DragSource.getDragThreshold();
    break;
  case MouseEvent.MOUSE_RELEASED:
    if (this.isInside) // non DnD stuff
      this.notifyListeners();
    this.dndArmedEvent = null;
    break;

etc.
</pre>
<p>Then to actually initiate the drag the mouse dragged event checks the distance the mouse has been dragged and then begins if the distance exceeds the threshold. This is pretty much what Shannon does in the plaf - but he does a lot more checking. Take a look at his code for those checks.</p>
<pre>
@Override
protected void processMouseMotionEvent(MouseEvent me) {
    switch (me.getID()) {
    case MouseEvent.MOUSE_DRAGGED:
      int dx = Math.abs(me.getX() - dndArmedEvent.getX());
      int dy = Math.abs(me.getY() - dndArmedEvent.getY());
      if ((dx &gt; motionThreshold) || (dy &gt; motionThreshold)) {
        TransferHandler th = this.getTransferHandler();
                                   th.exportAsDrag(this,
                                   me,
                                   TransferHandler.COPY);
     }
     break;
  }
}
</pre>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d59').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d59" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/59" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Swing+Drag+and+Drop+on+non+supported+components&amp;url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/59" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/59&amp;new_comment=Swing+Drag+and+Drop+on+non+supported+components&amp;new_comment=Swing+Drag+and+Drop+on+non+supported+components&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Swing+Drag+and+Drop+on+non+supported+components&amp;u=http://rockhoppertech.com/blogs/archives/59" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/59" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/59&amp;title=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/59" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/59&amp;t=Swing+Drag+and+Drop+on+non+supported+components" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d59').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/59/feed</wfw:commentRss>
		</item>
		<item>
		<title>Spring autowiring Struts 1 Actions</title>
		<link>http://rockhoppertech.com/blogs/archives/57</link>
		<comments>http://rockhoppertech.com/blogs/archives/57#comments</comments>
		<pubDate>Mon, 29 Dec 2008 15:05:00 +0000</pubDate>
		<dc:creator>gene</dc:creator>
		
		<category><![CDATA[Spring Framework]]></category>

		<category><![CDATA[Web]]></category>

		<category><![CDATA[Spring]]></category>

		<category><![CDATA[struts]]></category>

		<guid isPermaLink="false">http://rockhoppertech.com/blogs/?p=57</guid>
		<description><![CDATA[That&#8217;s right. Struts 1. Not hip. Not happenin&#8217;. But in the real world you might have bills to pay and a pair-programmer to feed.
The docs are a bit sketchy with Spring 2.5 stuff.
First you set up your service layer in web.xml
&#60;context-param&#62;

&#60;description&#62;Used by ContextLoaderListener&#60;/description&#62;

&#60;param-name&#62;contextConfigLocation&#60;/param-name&#62;

&#60;param-value&#62;/WEB-INF/spring-service-layer.xml&#60;/param-value&#62;

&#60;/context-param&#62;&#60;listener&#62;

&#60;description&#62;spring. looks for /WEB-INF/applicationContext.xml unless you set contextConfigLocation (see above)&#60;/description&#62;

&#60;listener-class&#62;org.springframework.web.context.ContextLoaderListener&#60;/listener-class&#62;

&#60;/listener&#62;
Inside my spring-service-layer.xml file [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s right. Struts 1. Not hip. Not happenin&#8217;. But in the real world you might have bills to pay and a <a href="http://rockhoppertech.com/gene/mo-programming.jpg">pair-programmer</a> to feed.</p>
<p>The <a href="http://static.springframework.org/spring/docs/2.5.x/reference/web-integration.html#struts" target="_blank">docs </a>are a bit sketchy with Spring 2.5 stuff.</p>
<p>First you set up your service layer in web.xml</p>
<pre>&lt;context-param&gt;

&lt;description&gt;Used by ContextLoaderListener&lt;/description&gt;

&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;

&lt;param-value&gt;/WEB-INF/spring-service-layer.xml&lt;/param-value&gt;

&lt;/context-param&gt;&lt;listener&gt;

&lt;description&gt;spring. looks for /WEB-INF/applicationContext.xml unless you set contextConfigLocation (see above)&lt;/description&gt;

&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;

&lt;/listener&gt;</pre>
<p>Inside my spring-service-layer.xml file I tell spring to look for classes annotated with one of the 2.5 @Component stereotypes - which include the @Service annotation.</p>
<pre>&lt;context:annotation-config /&gt;
&lt;context:component-scan base-package="com.rockhoppertech.example"
scoped-proxy="targetClass"&gt;
&lt;/context:component-scan&gt;</pre>
<p>Here&#8217;s a simple service:</p>
<pre>@Service("HelloService")
public class DefaultHelloService implements HelloService {
/*
* @see com.rockhoppertech.example.service.HelloService#getMessage()
*/
public String getMessage() {
return "Yo";
}
}</pre>
<p>Spring will create a root web context in application scope accessible with the attribute name org.springframework.web.context.WebApplicationContext.ROOT. My service appears here.</p>
<pre>org.springframework.web.context.support.XmlWebApplicationContext@74907490: display name [Root WebApplicationContext]
org.springframework.context.annotation.internalCommonAnnotationProcessor
org.springframework.context.annotation.internalAutowiredAnnotationProcessor
org.springframework.context.annotation.internalRequiredAnnotationProcessor
HelloService</pre>
<p>The Spring docs say one approach is to configure Spring to manage your Actions as beans, using the ContextLoaderPlugin which will read the appropriately specified spring config files like this:</p>
<pre>&lt;plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"&gt;
&lt;set-property property="contextConfigLocation"
value="/WEB-INF/action-servlet.xml"/&gt;
&lt;/plug-in&gt;</pre>
<p>Then in action-servlet.xml for example you configure your actions as beans.</p>
<pre>&lt;bean name="/hello" class="com.rockhoppertech.example.struts.action.HelloAction"&gt;

&lt;/bean&gt;</pre>
<p>Then in struts-config.xml you specify a special Spring controller:</p>
<pre>&lt;controller&gt;

&lt;set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/&gt;

&lt;/controller&gt;</pre>
<p>Also in struts-config.xml you have to change your actions definitions to use a Spring delegate. Notice<br />
that the path matches the bean name specified in action-servlet.xml.</p>
<pre>&lt;action name="HelloForm" path="/hello"

type="org.springframework.web.struts.DelegatingActionProxy"&gt;</pre>
<p>Ok, that works fine. Not too dry though since I have to specify the bean twice.</p>
<p>Let&#8217;s try a newer Spring class.</p>
<p>In struts-config.xml I change the controller to this.</p>
<pre>&lt;controller&gt;

&lt;set-property property="processorClass"value="org.springframework.web.struts.AutowiringRequestProcessor" /&gt;&lt;/controller&gt;</pre>
<p>Since it&#8217;s named AutowiringRequestProcessor I&#8217;ve used the @Autowire annotation in my Action to get the service injected (which will NOT work if you annotate the instance variable and not a setter method).</p>
<p>The <a title="spring docs" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/struts/AutowiringRequestProcessor.html">docs </a>say that you specify just the usual action tag in struts-config.xml.<br />
But how will the action beans then be created?<br />
I simply annotated HelloAction with @Component. The scan for the service found the action too. The thing is, they live in the parent web context not in the child context created by the contextLoader plugin:</p>
<pre>(accessible as an application scoped attribute named org.springframework.web.struts.ContextLoaderPlugIn.CONTEXT)
org.springframework.web.context.support.XmlWebApplicationContext@4e8a4e8a: display name [WebApplicationContext for namespace 'action-servlet']</pre>
<p>The beans you specify in your plugin config file live here. But since we&#8217;re doing the component scan chacha they aren&#8217;t living there anymore. Do you think that&#8217;s a bad thing?</p>
<p>Here&#8217;s my annotated Action:</p>
<pre>@Component
public class HelloAction extends Action {
private Logger logger = Logger.getLogger(HelloAction.class);

private HelloService helloService;

/**
* @param helloService
*            the helloService to set
*/
@Autowired(required = true)
public void setHelloService(HelloService helloService) {
this.helloService = helloService;
if (logger.isDebugEnabled()) {
logger.debug("Service was set");
}
}

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionMessages errors = new ActionMessages();
ActionForward forward = null;

if (helloService == null) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
"helloservice.null"));
if (logger.isDebugEnabled()) {
logger.debug("Hello service is null");
}
} else {
request.setAttribute("Greeting", helloService.getMessage());
if (logger.isDebugEnabled()) {
logger.debug("Set request attribute Greeting");
}
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
forward = mapping.findForward("failure");
} else {
forward = mapping.findForward("success");
}
return forward;
}</pre>
<p>Here is a <a href="http://rockhoppertech.com/blogs/wp-content/uploads/2009/01/struts1spring02-src.zip">mavenized project</a> with all the sources for this post.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d57').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d57" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http://rockhoppertech.com/blogs/archives/57" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;digg"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Spring+autowiring+Struts+1+Actions&amp;url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;DZone"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://rockhoppertech.com/blogs/archives/57" title="Add to&nbsp;Facebook"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/edit.pl?new_url=http://rockhoppertech.com/blogs/archives/57&amp;new_comment=Spring+autowiring+Struts+1+Actions&amp;new_comment=Spring+autowiring+Struts+1+Actions&amp;linktype=Misc" title="Add to&nbsp;Fark"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Spring+autowiring+Struts+1+Actions&amp;u=http://rockhoppertech.com/blogs/archives/57" title="Add to&nbsp;FURL"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/furl.png" title="Add to&nbsp;FURL" alt="Add to&nbsp;FURL" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;reddit"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.rojo.com/add-subscription/?resource=http://rockhoppertech.com/blogs/archives/57" title="Add to&nbsp;Rojo"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/rojo.png" title="Add to&nbsp;Rojo" alt="Add to&nbsp;Rojo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://rockhoppertech.com/blogs/archives/57&amp;title=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rockhoppertech.com/blogs/archives/57" title="Add to&nbsp;Technorati"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://rockhoppertech.com/blogs/archives/57&amp;t=Spring+autowiring+Struts+1+Actions" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://rockhoppertech.com/blogs/wp-content/plugins/social_bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d57').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://rockhoppertech.com/blogs/archives/57/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
