<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" version="2.0">

<channel>
	<title>Moving the Curve</title>
	
	<link>http://www.stevideter.com</link>
	<description>Technology, code, and thoughts by Stevi Deter</description>
	<lastBuildDate>Wed, 28 Nov 2012 02:09:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MovingTheCurve" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="movingthecurve" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>47.686300</geo:lat><geo:long>-122.096949</geo:long><item>
		<title>Case Insensitive Usernames using Spring Security Core Plugin for Grails</title>
		<link>http://www.stevideter.com/2012/11/17/case-insensitive-usernames-using-spring-security-core-plugin-for-grails/</link>
		<comments>http://www.stevideter.com/2012/11/17/case-insensitive-usernames-using-spring-security-core-plugin-for-grails/#comments</comments>
		<pubDate>Sun, 18 Nov 2012 07:55:59 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[case insensitive]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[spring security]]></category>
		<category><![CDATA[userdetailsservice]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=96</guid>
		<description><![CDATA[How to override GormUserDetailsService to make Spring Security login case insensitive in Grails applications. <div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>Given the years I&#8217;ve worked with Spring Security, it&#8217;s a bit embarrassing how often I forget that, by default, if you&#8217;re using the default database-backed implementation, the login is case sensitive. The best place to modify this behavior by overriding it in the UserDetailsService implementation you&#8217;ve selected.</p>
<p>Most of my most recent projects have been in <a href="http://grails.org" target="_blank" title="Grails">Grails</a><a href="#footnote-1" title="Just Grails. See the link in Burt Beckwith's comment for why."><sup>1</sup></a>. This is a framework I&#8217;ve found to be very flexible and fast for development. And usually the first plugin I install is the <a href="http://grails-plugins.github.com/grails-spring-security-core/" title="Spring Security Core Plugin">Spring Security Core</a>.</p>
<p>Making your login case insensitive (which has always been my choice, since it eliminates irritating user experience issues) turns out to be quite simple. The plugin provides <a href="http://grails-plugins.github.com/grails-spring-security-core/docs/manual/guide/11%20Custom%20UserDetailsService.html" title="User Details Service">GormUserDetailsService</a> as the default implementation. Override this class and update your resource.groovy to use it instead of the default.</p>
<p>The first example shows how to override if you want to go for simplicity in your code because it&#8217;s application specific. Rather than dynamically loading the user domain class, we&#8217;ll just use it directly, since we know what it is for this application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #a1a100;">com.stevideter</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.springframework.security.core.GrantedAuthority</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.springframework.security.core.userdetails.UserDetails</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.springframework.security.core.userdetails.UsernameNotFoundException</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> CaseInsensitiveUserDetailsService <span style="color: #000000; font-weight: bold;">extends</span> GormUserDetailsService <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/**
	 * make username case insensitive. Since we're using in a specific app,
	 * let's directly use the known class and property name
	 */</span>
	UserDetails loadUserByUsername<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> username, <span style="color: #993333;">boolean</span> loadRoles<span style="color: #66cc66;">&#41;</span> 
			<span style="color: #000000; font-weight: bold;">throws</span> UsernameNotFoundException <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// in this example, I used Person as my domain class</span>
		Person.<span style="color: #006600;">withTransaction</span> <span style="color: #66cc66;">&#123;</span> status <span style="color: #66cc66;">-&gt;</span>
			<span style="color: #000000; font-weight: bold;">def</span> user <span style="color: #66cc66;">=</span> Person.<span style="color: #006600;">findByUsernameIlike</span><span style="color: #66cc66;">&#40;</span>username<span style="color: #66cc66;">&#41;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>user<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				log.<span style="color: #006600;">warn</span> <span style="color: #ff0000;">&quot;User not found: $username&quot;</span>
				<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> UsernameNotFoundException<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'User not found'</span>, username<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#125;</span>
&nbsp;
			Collection<span style="color: #66cc66;">&lt;</span>GrantedAuthority<span style="color: #66cc66;">&gt;</span> authorities <span style="color: #66cc66;">=</span> 
				loadAuthorities<span style="color: #66cc66;">&#40;</span>user, username, loadRoles<span style="color: #66cc66;">&#41;</span>
			createUserDetails user, authorities
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Then register this bean in resources.groovy, and you&#8217;re ready to log in without worrying about case:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">beans <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
	userDetailsService<span style="color: #66cc66;">&#40;</span>com.<span style="color: #006600;">stevideter</span>.<span style="color: #006600;">CaseInsensitiveUserDetailsService</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>But what if you want to be more generic in your approach? That&#8217;s still possible, we just need to remember to inject grailsApplication into our Service class so we can dynamically load the domain class.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #a1a100;">com.stevideter</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.springframework.security.core.GrantedAuthority</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.springframework.security.core.userdetails.UserDetails</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.springframework.security.core.userdetails.UsernameNotFoundException</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #a1a100;">org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> DynamicCaseInsensitiveUserDetailsService <span style="color: #000000; font-weight: bold;">extends</span> GormUserDetailsService <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">def</span> grailsApplication
&nbsp;
	UserDetails loadUserByUsername<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> username, <span style="color: #993333;">boolean</span> loadRoles<span style="color: #66cc66;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> UsernameNotFoundException <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">def</span> conf <span style="color: #66cc66;">=</span> SpringSecurityUtils.<span style="color: #006600;">securityConfig</span>
		<span style="color: #aaaadd; font-weight: bold;">String</span> userClassName <span style="color: #66cc66;">=</span> conf.<span style="color: #006600;">userLookup</span>.<span style="color: #006600;">userDomainClassName</span>
		<span style="color: #000000; font-weight: bold;">def</span> dc <span style="color: #66cc66;">=</span> grailsApplication.<span style="color: #006600;">getDomainClass</span><span style="color: #66cc66;">&#40;</span>userClassName<span style="color: #66cc66;">&#41;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>dc<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">RuntimeException</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;The specified user domain class '$userClassName' is not a domain class&quot;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		Class<span style="color: #66cc66;">&lt;?&gt;</span> User <span style="color: #66cc66;">=</span> dc.<span style="color: #006600;">clazz</span>
&nbsp;
		User.<span style="color: #006600;">withTransaction</span> <span style="color: #66cc66;">&#123;</span> status <span style="color: #66cc66;">-&gt;</span>
			<span style="color: #808080; font-style: italic;">// this time we'll use where plus a DetachedCriteria closure </span>
			<span style="color: #808080; font-style: italic;">// with =~ for case insensitivity</span>
			<span style="color: #000000; font-weight: bold;">def</span> user <span style="color: #66cc66;">=</span> User.<span style="color: #006600;">where</span><span style="color: #66cc66;">&#123;</span>
				<span style="color: #66cc66;">&#40;</span>conf.<span style="color: #006600;">userLookup</span>.<span style="color: #006600;">usernamePropertyName</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">=</span>~ username
			<span style="color: #66cc66;">&#125;</span>.<span style="color: #663399;">find</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>user<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				log.<span style="color: #006600;">warn</span> <span style="color: #ff0000;">&quot;User not found: $username&quot;</span>
				<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> UsernameNotFoundException<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'User not found'</span>, username<span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#125;</span>
			log.<span style="color: #006600;">debug</span> <span style="color: #ff0000;">&quot;found user&quot;</span>
&nbsp;
			Collection<span style="color: #66cc66;">&lt;</span>GrantedAuthority<span style="color: #66cc66;">&gt;</span> authorities <span style="color: #66cc66;">=</span> 
				loadAuthorities<span style="color: #66cc66;">&#40;</span>user, username, loadRoles<span style="color: #66cc66;">&#41;</span>
			createUserDetails user, authorities
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="groovy" style="font-family:monospace;">beans <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
	userDetailsService<span style="color: #66cc66;">&#40;</span>com.<span style="color: #006600;">stevideter</span>.<span style="color: #006600;">DynamicCaseInsensitiveUserDetailsService</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		grailsApplication <span style="color: #66cc66;">=</span> ref<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'grailsApplication'</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>In the first example, it&#8217;s possible to easily use a dynamic finder to create our query, but in the second, I chose to use the <code>where</code> method with a Detached Criteria to find the user.</p>
<p>The UserDetailsService is an important part of Spring Security, as it&#8217;s also where you&#8217;ll want to make any changes to the UserDetails returned from the authentication process.</p>
<p><a name="footnote-1" />[1] Just Grails. See the link in Burt Beckwith&#8217;s comment for why.</p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/k2QsLOpA2sw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2012/11/17/case-insensitive-usernames-using-spring-security-core-plugin-for-grails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Passionate Programmer</title>
		<link>http://www.stevideter.com/2010/01/07/the-passionate-programmer/</link>
		<comments>http://www.stevideter.com/2010/01/07/the-passionate-programmer/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 04:32:27 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[book review]]></category>
		<category><![CDATA[coding life]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Why I Do This]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[chad fowler]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[the passionate programmer]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=71</guid>
		<description><![CDATA[A few years ago, right about the time I learned my job was to be outsourced, I remember seeing a book in the bookstore titled My Job Went to India. I assumed it was a parody of sorts and decided to resist the urge to pick it up. It wasn&#8217;t until I read the introduction [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/1934356344?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1934356344"><img class="alignleft size-full wp-image-77" style="border: 0pt none; margin: 3px;" title="The Passionate Programmer" src="http://www.stevideter.com/wp-content/uploads/2010/01/passionateprogrammer.jpg" alt="The Passionate Programmer" width="106" height="160" /></a> A few years ago, right about the time I learned my job was to be outsourced, I remember seeing a book in the bookstore titled <a href="http://www.amazon.com/gp/product/0976694018?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0976694018">My Job Went to India</a>. I assumed it was a parody of sorts and decided to resist the urge to pick it up.</p>
<p>It wasn&#8217;t until I read the introduction to <a href="http://pragprog.com/titles/cfcar2/the-passionate-programmer">The Passionate Programmer</a> by Chad Fowler, that I realized it was the second edition of that same book, which had been subtitled &#8220;52 Ways to Save Your Job.&#8221; The title change is a good one, as it does a much better job of crystallizing the goal of this book.</p>
<p>The focus of <strong>The Passionate Programmer</strong> is how to have an exceptional career as a developer. It is written as several short essays on specific tips for creating a career in programming you can be passionate about, each followed by one or more specific suggestions for activities to follow through on what you&#8217;ve just read. In essence, this is <a href="http://www.amazon.com/gp/product/1580089879?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1580089879">What Color Is Your Parachute?</a> for people who already know they want to be programmers.</p>
<p>While the driving force may be passion, the topics are very pragmatic. Fowler suggests you choose your market, invest in your product, execute on your plans, and market yourself. This follows from the major thesis, that you must treat your career as a product in and of itself. The passion comes from the desire to create a great product, and do what is necessary to make that product, ultimately yourself, successful.</p>
<p>An important point that&#8217;s treated as a side note &#8211; you have to want to be a great programmer. If you find that&#8217;s not what you want, maybe you should find a career you can be passionate about.</p>
<p>Fowler provides a road map for how to create a career you love on a daily basis while moving towards a future you are excited about. The topics range from how to find enjoyment in the drudge tasks you may hate, how to keep from falling behind the technology curve, how to decide when to take career risks, and how to become truly remarkable (not just good).</p>
<p>Most of the &#8220;Act On It&#8221; tasks are highly relevant and useful. Now that I have read the entire book, I plan to review the chapters that feel the most relevant and focus on one or two of the tasks a week.</p>
<p>While much of the advice provided the The Passionate Programmer is not new, I think this is a great resource for anybody who wants to have a career as a software developer that excites and inspires. Software is a great industry, full of brilliant people and complex problems to solve. That&#8217;s why I got into it. This book provides concrete ways I can keep that passion alive.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<p>&amp;lt;a href=&#8221;http://www.amazon.com/gp/product/0976694018?ie=UTF8&amp;tag=movithecurv-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0976694018&#8243;&amp;gt;My Job Went to India: 52 Ways to Save Your Job (Pragmatic Programmers)&amp;lt;/a&amp;gt;&amp;lt;img src=&#8221;http://www.assoc-amazon.com/e/ir?t=movithecurv-20&amp;l=as2&amp;o=1&amp;a=0976694018&#8243; width=&#8221;1&#8243; height=&#8221;1&#8243; border=&#8221;0&#8243; alt=&#8221;" style=&#8221;border:none !important; margin:0px !important;&#8221; /&amp;gt;</p>
</div>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/64HjMTNDAoM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2010/01/07/the-passionate-programmer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Of ExceptionResolvers and XMLBeans</title>
		<link>http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/</link>
		<comments>http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 20:07:13 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[exception resolver]]></category>
		<category><![CDATA[soapfault]]></category>
		<category><![CDATA[spring web service]]></category>
		<category><![CDATA[xmlbeans]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=63</guid>
		<description><![CDATA[Using a custom ExceptionResolver in Spring Web Services to insert a Detail into a SoapFault.<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>We&#8217;re using <a title="XMLBeans" href="http://xmlbeans.apache.org/" target="_blank">XMLBeans </a>with <a title="Spring Web Services" href="http://static.springframework.org/spring-ws/sites/1.5/" target="_blank">Spring Web Services</a>, and the set-up was quite easy. But the one issue I found frustrating was handling the <a title="SoapFault" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/soap/SoapFault.html" target="_blank">SoapFault</a>. The requirements in this case required including a <a title="SoapFaultDetail" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/soap/SoapFaultDetail.html" target="_blank">SoapFaultDetail</a> that contained a complex type. And while the <a title="XmlBeansMarshaller" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.html" target="_blank">XmlBeansMarshaller</a> transparently handles transforming the incoming and outgoing SOAP requests, it didn&#8217;t magically include the type defined as the fault in the WSDL within the SoapFault message.</p>
<p>Digging through the <a title="Spring Web Services tutorial" href="http://static.springframework.org/spring-ws/sites/1.5/reference/html/tutorial.html" target="_blank">tutorial</a> and some online forum postings, I finally found a solution. The <a title="AbstractSoapFaultDefinitionExceptionResovler" href="http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/soap/server/endpoint/AbstractSoapFaultDefinitionExceptionResolver.html" target="_self">AbstractSoapFaultDefinitionExceptionResolver</a> provides a protected method void customizeFault(Object endpoint, Exception ex, SoapFault fault) that subclasses can override to modify the SoapFault before it is returned. Since this method includes the exception as a parameter, I chose to create an exception that is thrown by my endpoints that includes my desired XmlBean, already populated, so I can just use SoapFault.getResult() to marshall the information into the details.</p>
<p>For simplicity&#8217;s sake, I chose to override the existing SoapFaultMappingExceptionResolver. </p>
<p>Below, ServiceFaultDocument is an XmlObject generated by XMLBeans from my schema: </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:schema</span> <span style="color: #000066;">xmlns:xs</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span>  <span style="color: #000066;">xmlns:s1</span>=<span style="color: #ff0000;">&quot;http://stevideter.com/webservice&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ServiceFault&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;s1:ServiceFault&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:complexType</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ServiceFault&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;errorCode&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xs:element</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;errorDescription&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;xs:string&quot;</span> <span style="color: #000066;">minOccurs</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">maxOccurs</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:sequence<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:complexType<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xs:schema<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>For my Exception class:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.webservice</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.server.endpoint.annotation.FaultCode</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.server.endpoint.annotation.SoapFault</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.webservice.ServiceFaultDocument</span><span style="color: #339933;">;</span>
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * An exception that carries a ServiceFault document for inclusion in 
 * the SoapFault
 * @author stevi.deter
 *
 */</span>
@SoapFault<span style="color: #009900;">&#40;</span>faultCode <span style="color: #339933;">=</span> FaultCode.<span style="color: #006633;">SERVER</span>,faultStringOrReason<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SERVICE-ERR&quot;</span>,locale<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;en&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ServiceFaultException <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> ServiceFaultDocument faultMessage<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ServiceFaultException&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s, <span style="color: #003399;">Throwable</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>s, ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s, <span style="color: #003399;">Throwable</span> ex, ServiceFaultDocument msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>s,ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setFaultMessage<span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setFaultMessage<span style="color: #009900;">&#40;</span>ServiceFaultDocument msg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		faultMessage <span style="color: #339933;">=</span> msg<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> ServiceFaultDocument getFaultMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> faultMessage<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And finally my ExceptionResolver. Note that logger is ultimately inherited from AbstractEndpointExceptionResolver, which is why you don&#8217;t see it declared in the code displayed.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.webservice.soap.server.endpoint</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.Result</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.Transformer</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerFactoryConfigurationError</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.SoapFault</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.SoapFaultDetail</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.xml.transform.StringSource</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.webservice.ServiceFaultException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.webservice.ServiceFaultDocument</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DetailSoapFaultDefinitionExceptionResolver <span style="color: #000000; font-weight: bold;">extends</span>
		SoapFaultMappingExceptionResolver <span style="color: #009900;">&#123;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> customizeFault<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> endpoint, <span style="color: #003399;">Exception</span> ex, SoapFault fault<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ServiceFaultException msg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ex <span style="color: #000000; font-weight: bold;">instanceof</span> ServiceFaultException<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			msg <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ServiceFaultException<span style="color: #009900;">&#41;</span> ex<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			msg <span style="color: #339933;">=</span> createFaultMessage<span style="color: #009900;">&#40;</span>ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		addServiceFaultDetail<span style="color: #009900;">&#40;</span>msg, fault<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> addServiceFaultDetail<span style="color: #009900;">&#40;</span>ServiceFaultException msg, SoapFault fault<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> TransformerFactoryConfigurationError <span style="color: #009900;">&#123;</span>
		Transformer trn<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			trn <span style="color: #339933;">=</span> TransformerFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newTransformer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			SoapFaultDetail faultDetail <span style="color: #339933;">=</span> fault.<span style="color: #006633;">addFaultDetail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Result result <span style="color: #339933;">=</span> faultDetail.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ServiceFaultDocument doc <span style="color: #339933;">=</span> msg.<span style="color: #006633;">getFaultMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>doc <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				logger.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ServiceFaultException thrown with no serviceFaultDocument!&quot;</span>,msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				trn.<span style="color: #006633;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> StringSource<span style="color: #009900;">&#40;</span>doc.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>TransformerException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			logger.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;problem with XML transform: &quot;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> ServiceFaultException createFaultMessage<span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ServiceFaultDocument faultDocument <span style="color: #339933;">=</span> ServiceFaultDocument.<span style="color: #006633;">Factory</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ServiceFault fault <span style="color: #339933;">=</span> faultDocument.<span style="color: #006633;">addNewServiceFault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fault.<span style="color: #006633;">setErrorCode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SERVICE-ERR&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fault.<span style="color: #006633;">setErrorDescription</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ServiceFaultException faultMsg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ServiceFaultException<span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,e,faultDocument<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> faultMsg<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The final step is injecting my ExceptionResolver in my webservice&#8217;s servlet.xml; just showing the single bean definition here: </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- rest of web service bean def's elided --&gt;</span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;exceptionResolver&quot;</span></span>
<span style="color: #009900;">	        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.stevideter.webservice.soap.server.endpoint.DetailSoapFaultDefinitionExceptionResolver&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;defaultFault&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;SERVER&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;exceptionMappings&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	    com.stevideter.webservice.ServiceFaultException=SERVER,FaultMsg
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Now whether my Endpoints throw an Exception, the ExceptionResolver transforms it into the SoapFaultDetail, and the calling system get the results they desire:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Envelope</span> <span style="color: #000066;">xmlns:SOAP-ENV</span>=<span style="color: #ff0000;">&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Header</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;SOAP-ENV:Fault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;faultcode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>SOAP-ENV:Server<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/faultcode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;faultstring</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>FaultMsg<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/faultstring<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;detail<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ServiceFault</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://stevideter.com/webservice&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorCode</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>SERVICE-ERR<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/errorCode<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
               <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorDescription</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>you can't do that!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/errorDescription<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ServiceFault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/detail<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SOAP-ENV:Fault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SOAP-ENV:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/SOAP-ENV:Envelope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>One issue I discovered in developing this was that we were using Saxon 8.8, a version which apparently has a bug that throws an exception on the empty namespaces in the Service Fault elements during the transform. According to the information I found, upgrading to Saxon 8.9 fixes that; I went ahead and upgraded to <a href="http://saxon.sourceforge.net/" title="Saxon XSLT and XQuery Processor">Saxon</a> 9.1.0.5 (current version as I write this) and the problem went away. Be sure to include saxon9.jar and saxon9-dom.jar if you go this route!</p>
<p>How have you used ExceptionResolvers in Web Services?</p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/XFohBwMUiFM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2009/02/18/of-exceptionresolvers-and-xmlbeans/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>SaveOrUpdate versus Merge in Hibernate</title>
		<link>http://www.stevideter.com/2008/12/07/saveorupdate-versus-merge-in-hibernate/</link>
		<comments>http://www.stevideter.com/2008/12/07/saveorupdate-versus-merge-in-hibernate/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 22:19:33 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[NonUniqueObjectException]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[saveOrUpdate]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=51</guid>
		<description><![CDATA[We all have those problems that we encounter just infrequently enough that when we see them again, we know we&#8217;ve solved this, but can&#8217;t remember how. The NonUniqueObjectException thrown when using Session.saveOrUpdate() in Hibernate is one of mine. I&#8217;ll be adding new functionality to a complex application. All my unit tests work fine. Then in [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>We all have those problems that we encounter just infrequently enough that when we see them again, we know we&#8217;ve solved this, but can&#8217;t remember how.</p>
<p>The NonUniqueObjectException thrown when using Session.saveOrUpdate() in Hibernate is one of mine. I&#8217;ll be adding new functionality to a complex application. All my unit tests work fine. Then in testing the UI, trying to save an object, I start getting an exception with the message &#8220;a different object with the same identifier value was already associated with the session.&#8221; Here&#8217;s some example code from <a href="http://www.amazon.com/gp/product/1932394885?ie=UTF8&#038;tag=movithecurv-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1932394885" title="Java Persistence with Hibernate">Java Persistence with Hibernate</a><img src="http://www.assoc-amazon.com/e/ir?t=movithecurv-20&#038;l=as2&#038;o=1&#038;a=1932394885" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">Session session <span style="color: #339933;">=</span> sessionFactory1.<span style="color: #006633;">openSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Transaction tx <span style="color: #339933;">=</span> session.<span style="color: #006633;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Item item <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Item<span style="color: #009900;">&#41;</span> session.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>Item.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Long</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1234</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
tx.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
session.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// end of first session, item is detached</span>
&nbsp;
item.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// The database identity is &quot;1234&quot;</span>
item.<span style="color: #006633;">setDescription</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my new description&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Session session2 <span style="color: #339933;">=</span> sessionFactory.<span style="color: #006633;">openSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Transaction tx2 <span style="color: #339933;">=</span> session2.<span style="color: #006633;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Item item2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Item<span style="color: #009900;">&#41;</span> session2.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>Item.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Long</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1234</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
session2.<span style="color: #006633;">update</span><span style="color: #009900;">&#40;</span>item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Throws NonUniqueObjectException</span>
tx2.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
session2.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
To understand the cause of this exception, it&#8217;s important to understand detached objects and what happens when you call saveOrUpdate() (or just update()) on a detached object.</p>
<p>When we close an individual Hibernate Session, the persistent objects we are working with are detached. This means the data is still in the application&#8217;s memory, but Hibernate is no longer responsible for tracking changes to the objects.</p>
<p>If we then modify our detached object and want to update it, we have to reattach the object. During that reattachment process, Hibernate will check to see if there are any other copies of the same object. If it finds any, it has to tell us it doesn&#8217;t know what the &#8220;real&#8221; copy is any more. Perhaps other changes were made to those other copies that we expect to be saved, but Hibernate doesn&#8217;t know about them, because it wasn&#8217;t managing them at the time.</p>
<p>Rather than save possibly bad data, Hibernate tells us about the problem via the NonUniqueObjectException.</p>
<p>So what are we to do? In Hibernate 3, we have merge() (in Hibernate 2, use saveOrUpdateCopy()). This method will force Hibernate to copy any changes from other detached instances onto the instance you want to save, and thus merges all the changes in memory before the save.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">Session session <span style="color: #339933;">=</span> sessionFactory1.<span style="color: #006633;">openSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Transaction tx <span style="color: #339933;">=</span> session.<span style="color: #006633;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Item item <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Item<span style="color: #009900;">&#41;</span> session.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>Item.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Long</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1234</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
tx.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
session.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// end of first session, item is detached</span>
&nbsp;
item.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// The database identity is &quot;1234&quot;</span>
item.<span style="color: #006633;">setDescription</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my new description&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Session session2 <span style="color: #339933;">=</span> sessionFactory.<span style="color: #006633;">openSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Transaction tx2 <span style="color: #339933;">=</span> session2.<span style="color: #006633;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Item item2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Item<span style="color: #009900;">&#41;</span> session2.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>Item.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Long</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1234</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Item item3 <span style="color: #339933;">=</span> session2.<span style="color: #006633;">merge</span><span style="color: #009900;">&#40;</span>item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Success!</span>
tx2.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
session2.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>
It&#8217;s important to note that merge returns a reference to the newly updated version of the instance. It isn&#8217;t reattaching item to the Session. If you test for instance equality (item == item3), you&#8217;ll find it returns false in this case. You will probably want to work with item3 from this point forward. </p>
<p>It&#8217;s also important to note that the Java Persistence API (JPA) doesn&#8217;t have a concept of detached and reattached objects, and uses EntityManager.persist() and EntityManager.merge(). </p>
<p>I&#8217;ve found in general that when using Hibernate, saveOrUpdate() is usually sufficient for my needs. I usually only need to use merge when I have objects that can have references to objects of the same type. Most recently, the cause of the exception was in the code validating that the reference wasn&#8217;t recursive. I was loading the same object into my session as part of the validation, causing the error.</p>
<p>Where have you encountered this problem? Did merge work for you or did you need another solution? Do you prefer to always use merge, or prefer to use it only as needed for specific cases?</p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/Va2JbothLWI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/12/07/saveorupdate-versus-merge-in-hibernate/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
		<item>
		<title>Annotation Mapping for Ordered Lists in Hibernate</title>
		<link>http://www.stevideter.com/2008/10/20/annotation-mapping-for-ordered-lists-in-hibernate/</link>
		<comments>http://www.stevideter.com/2008/10/20/annotation-mapping-for-ordered-lists-in-hibernate/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 20:06:17 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[bidirectional]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javax]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[ordered list]]></category>
		<category><![CDATA[persistence]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=41</guid>
		<description><![CDATA[Here&#8217;s another problem that has a simple solution that took me longer than I expected to find. I am using Hibernate 3.2.5 as my ORM. In one case, I want to map a child collection of items as an ordered List, taking advantage of the database to do my ordering. I&#8217;m using Annotations intead of [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s another problem that has a simple solution that took me longer than I expected to find.</p>
<p>I am using <a title="Hibernate web site" href="http://www.hibernate.org/" target="_blank">Hibernate 3.2.5</a> as my <a title="Definition of ORM" href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">ORM</a>. In one case, I want to map a child collection of items as an ordered List, taking advantage of the database to do my ordering.</p>
<p>I&#8217;m using Annotations intead of the hbm.xml format for my mappings in this project. Whenever possible, I&#8217;m using <a title="javax.persistence api" href="http://java.sun.com/javaee/5/docs/api/javax/persistence/package-summary.html" target="_blank">javax.persistence</a> mappings in preference too Hibernate&#8217;s annoations.</p>
<p>Referring to <a title="Java Persistence with Hibernate at amazon.com" href="http://www.amazon.com/exec/obidos/ASIN/1932394885/movithecurv-20" target="_blank">Java Persistence with Hibernate</a>, the mapping looks quite complicated, using Hibernate&#8217;s annotations. With some experimentation, I found a simple solution, using just the javax.persistence mappings. For simplicity, I&#8217;ll show the example annotating the Item / Bid class idea we&#8217;re used to from the Hibernate Caveat Emptor example.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.domain</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.CascadeType</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.JoinColumn</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.OneToMany</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.OrderBy</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.collections.CollectionUtils</span><span style="color: #339933;">;</span>
&nbsp;
@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ITEM&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Item <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>7990110946186412551L<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> id<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">List</span> bids <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  @Id
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  @OneToMany<span style="color: #009900;">&#40;</span>mappedBy<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;item&quot;</span>,cascade<span style="color: #339933;">=</span>CascadeType.<span style="color: #006633;">ALL</span><span style="color: #009900;">&#41;</span>
  @OrderBy<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;userId,date,amount&quot;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">List</span> getBids<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> bids<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> setBids<span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span> bids<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">bids</span> <span style="color: #339933;">=</span> bids<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addBid<span style="color: #009900;">&#40;</span>Bid bid<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>CollectionUtils.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span>bids<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> bids <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    bids.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>bid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    bid.<span style="color: #006633;">setItem</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> removeBid<span style="color: #009900;">&#40;</span>Bid bid<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>CollectionUtils.<span style="color: #006633;">isNotEmpty</span><span style="color: #009900;">&#40;</span>bids<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      bids.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span>bid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And for reference, here&#8217;s the mapping in the Bid with the Item as a parent:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.domain</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.Serializable</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.math.BigDecimal</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Entity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Id</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.JoinColumn</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.ManyToOne</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.persistence.Table</span><span style="color: #339933;">;</span>
&nbsp;
@<span style="color: #003399;">Entity</span>
@Table<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;BID&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Bid <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">Serializable</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 8165733510722884274L<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> id<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> Item item<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Date</span> date<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">BigDecimal</span> amount<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> userId<span style="color: #339933;">;</span>
&nbsp;
  @Id
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  @ManyToOne<span style="color: #009900;">&#40;</span> targetEntity <span style="color: #339933;">=</span> com.<span style="color: #006633;">stevideter</span>.<span style="color: #006633;">domain</span>.<span style="color: #006633;">Item</span>.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span>
  @JoinColumn<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;itemid&quot;</span>, nullable <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">public</span> Item getItem<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> item<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setItem<span style="color: #009900;">&#40;</span>Item item<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">item</span> <span style="color: #339933;">=</span> item<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Date</span> getDate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> date<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setDate<span style="color: #009900;">&#40;</span><span style="color: #003399;">Date</span> date<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">date</span> <span style="color: #339933;">=</span> date<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">BigDecimal</span> getAmount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> amount<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setAmount<span style="color: #009900;">&#40;</span><span style="color: #003399;">BigDecimal</span> amount<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">amount</span> <span style="color: #339933;">=</span> amount<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getUserId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> userId<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUserId<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> userId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userId</span> <span style="color: #339933;">=</span> userId<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>With this mapping, the bids collection is managed by the Item, so saving the Item automatically saves the bid collection.</p>
<p>This example does follow the JPA standard of configuration by exception, so column names, etc., that are not explicitly called out follow the default standards.</p>
<p>What has been your trickiest Hibernate or javax.persistence mapping problem? How did you solve it?</p>
<p>&#8211;<br />
Edited to make mapping on Bids properly bidirectional. </p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/UwQLFiRL_A0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/10/20/annotation-mapping-for-ordered-lists-in-hibernate/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Finding selected checkbox items in a JSF dataTable</title>
		<link>http://www.stevideter.com/2008/10/09/finding-selected-checkbox-items-in-a-jsf-datatable/</link>
		<comments>http://www.stevideter.com/2008/10/09/finding-selected-checkbox-items-in-a-jsf-datatable/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 18:46:06 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jsf]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=35</guid>
		<description><![CDATA[This is one of those problems that I couldn&#8217;t find a complete example for when I needed it, so hopefully this will save somebody else the extra time it took me to piece it together. We frequently need to have data tables in our UI, and allow the user to select a subset of those [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>This is one of those problems that I couldn&#8217;t find a complete example for when I needed it, so hopefully this will save somebody else the extra time it took me to piece it together.</p>
<p>We frequently need to have data tables in our UI, and allow the user to select a subset of those items for action. In JavaServer Faces, this means having a DataTable, each row having its own checkbox. But when the action is triggered, how to we find which items the user has selected.</p>
<p>The first step is to add a boolean property to your objects that can represent the selection. If you have a lot objects in your domain that will need this property, you may want to consider adding this to an interface or parent bean, otherwise, you can add it directly to your domain object. As a caveat, I don&#8217;t like adding properties to my domain objects that are for UI use only, but in this case, I&#8217;m keeping this as simple as possible. Sometimes pragmatism wins.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.domain</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SelectableItem <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> id<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> selected<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> name<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isSelected<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> selected<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setSelected<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> selected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">selected</span> <span style="color: #339933;">=</span> selected<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
In your view, you&#8217;ll use the dataTable to display the items, including the checkbox:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="jsp" style="font-family:monospace;">&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot;%&gt;
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot;%&gt;
&nbsp;
&lt;f:view&gt;&lt;html&gt;&lt;body&gt;
&lt;h:form&gt;
&lt;h:dataTable id=&quot;itemsTable&quot; 
    value=&quot;#{SelectionBean.selectedItems}&quot; var=&quot;item&quot;  &gt;
&nbsp;
&lt;f:facet name=&quot;header&quot;&gt;
  &lt;h:outputText value=&quot;Items&quot; /&gt;
&lt;/f:facet&gt; 
&lt;h:column&gt;
  &lt;f:facet name=&quot;header&quot;&gt;
    &lt;h:outputText value=&quot;Select&quot; /&gt;
  &lt;/f:facet&gt;
  &lt;h:selectBooleanCheckbox value=&quot;#{item.selected}&quot; /&gt;
&lt;/h:column&gt;
&lt;h:column&gt;
  &lt;f:facet name=&quot;header&quot;&gt;
    &lt;h:outputText value=&quot;name&quot; /&gt;  
  &lt;/f:facet&gt; 
    &lt;h:outputText value=&quot;#{item.name}&quot;&gt;&lt;/h:outputText&gt;
&lt;/h:column&gt;
&lt;/h:dataTable&gt;
&lt;h:commandButton title=&quot;selectItems&quot; 
    value=&quot;Select Items&quot;
    actionListener=&quot;#{SelectionBean.submitSelections}&quot; /&gt;
&lt;/h:form&gt;
&lt;/body&gt;&lt;/html&gt;&lt;/f:view&gt;</pre></td></tr></table></div>

<p>
Now when you click the command button to trigger the submitSelections event, the boolean values for selected items will be set, and you can iterate through your list to find the selected items and act on them as needed.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.stevideter.BackingBean</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.faces.event.ActionEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.faces.model.DataModel</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.faces.model.ListDataModel</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.domain.SelectableItem</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.stevideter.manager.DomainManager</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SelectionBean <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> DataModel selectableItems<span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">DomainManager</span> manager<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> populateSelectableItems<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    selectableItems <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ListDataModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    selectableItems.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>manager.<span style="color: #006633;">getSelectableItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> submitSelections<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    List<span style="color: #339933;">&lt;</span>SelectableItem<span style="color: #339933;">&gt;</span> items <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>SelectableItem<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#41;</span>selectableItems.<span style="color: #006633;">getWrappedData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    List<span style="color: #339933;">&lt;</span>SelectableItem<span style="color: #339933;">&gt;</span> selectedItems <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>SelectableItem<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>SelectableItem item <span style="color: #339933;">:</span> items<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>item.<span style="color: #006633;">isSelected</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        selectedItems.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>item<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// do what you need to do with selected items</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> DataModel getSelectableItems<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> selectableItems<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setSelectableItems<span style="color: #009900;">&#40;</span>DataModel selectableItems<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">selectableItems</span> <span style="color: #339933;">=</span> selectableItems<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>
As you can see, this is a very simple solution. Have you seen any other approaches that work?</p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/3EWHdORrJ8w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/10/09/finding-selected-checkbox-items-in-a-jsf-datatable/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>First actual case of bug being found</title>
		<link>http://www.stevideter.com/2008/09/09/first-actual-case-of-bug-being-found/</link>
		<comments>http://www.stevideter.com/2008/09/09/first-actual-case-of-bug-being-found/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 16:43:48 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[coding life]]></category>
		<category><![CDATA[girl geeks]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[grace hopper]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=30</guid>
		<description><![CDATA[On September 9, 1947, the Harvard University Mark II Aiken Relay Calculator started having problems. The operators opened it up, and discovered a moth between the points of Relay #70, in Panel F. The moth was removed at taped into the log book with the comment &#8220;First actual case of bug being found.&#8221; When told [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>On September 9, 1947, the Harvard University Mark II Aiken Relay Calculator started having problems. The operators opened it up, and discovered a moth between the points of Relay #70, in Panel F. The moth was removed at taped into the log book with the comment <a href="http://americanhistory.si.edu/collections/object.cfm?key=35&#038;objkey=30" title="Log book with bug" target="_blank">&#8220;First actual case of bug being found.&#8221;</a></p>
<p>When told of the event, <a href="http://en.wikipedia.org/wiki/Grace_hopper">Grace Murray Hopper</a> was reported to have quipped they were &#8220;debugging&#8221; the machine. There is plenty of evidence the term &#8220;bug&#8221; for a flaw in electronics had been around for decades before this event, this usage helped bring it into the modern popular terminology. </p>
<p>This is also the first introduction that many of us have to Rear Admiral Hopper, a truly remarkable woman. She wrote the first compiler for an electronic computer, <a href="http://en.wikipedia.org/wiki/A-0_programming_language" target="_blank" title="A-0">A-0</a>. She championed the idea that computer languages should be more like English instead of machine code. And she helped establish standards for testing systems and components. </p>
<p>The next time I have to debug a program written in a <a href="http://en.wikipedia.org/wiki/Third-generation_programming_language" title="Third Generation Language" target="_blank">3GL</a>, I&#8217;ll take a moment to thank Grace Hopper for laying the groundwork that made it easier for me. Thank you, Amazing Grace!</p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/vTi6_OXGZMM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/09/09/first-actual-case-of-bug-being-found/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to configure a secure JMS connection using Spring</title>
		<link>http://www.stevideter.com/2008/09/05/how-to-configure-a-secure-jms-connection-using-spring/</link>
		<comments>http://www.stevideter.com/2008/09/05/how-to-configure-a-secure-jms-connection-using-spring/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 19:13:56 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jms]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=29</guid>
		<description><![CDATA[In a comment to my previous post about configuring JMS via Spring, Vikas Kadam asked about configuring a connection to a secure TIBCO EMS topic or queue. As fate would have it, the next issue I dealt with was adding this to my own application. What worked for me was using Spring&#8217;s UserCredentialsConnectionFactoryAdapter as my [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>In a comment to my previous post about <a title="Simplifying Spring’s JMS configuration for JndiTemplate" href="http://www.stevideter.com/2008/08/25/simplifying-spring%e2%80%99s-jms-configuration-for-jnditemplate/">configuring JMS via Spring</a>, Vikas Kadam asked about configuring a connection to a secure TIBCO EMS topic or queue. As fate would have it, the next issue I dealt with was adding this to my own application. What worked for me was using Spring&#8217;s <a title="Spring API" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.html" target="_blank">UserCredentialsConnectionFactoryAdapter</a> as my connection factory for my JmsTemplate. The final configuration looked like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyConfigurer&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;location&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;file:${catalina.home}/conf/jms.properties&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;messageSender&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.stevideter.spring.jms.MessageSender&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jmsTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;jmsTemplate&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jmsTemplate&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jms.core.JmsTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connectionFactory&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;userCredentialsConnectionFactory&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;defaultDestinationName&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jms.defaultdestinationname}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pubSubDomain&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jms.istopic}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;userCredentialsConnectionFactory&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;targetConnectionFactory&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;topicConnectionFactory&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jms.username}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jms.password}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;topicConnectionFactory&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jndiTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;jndiTemplate&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jndiName&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${jms.connectionfactory}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jndiTemplate&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jndi.JndiTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;environment&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;java.naming.factory.initial&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
          com.tibco.tibjms.naming.TibjmsInitialContextFactory
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;java.naming.provider.url&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
          ${jms.jndicontexturl}
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/rOQsPtx6PUw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/09/05/how-to-configure-a-secure-jms-connection-using-spring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simplifying Spring’s JMS configuration for JndiTemplate</title>
		<link>http://www.stevideter.com/2008/08/25/simplifying-spring%e2%80%99s-jms-configuration-for-jnditemplate/</link>
		<comments>http://www.stevideter.com/2008/08/25/simplifying-spring%e2%80%99s-jms-configuration-for-jnditemplate/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 23:33:37 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jms]]></category>
		<category><![CDATA[jndi]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=28</guid>
		<description><![CDATA[I&#8217;ve spent several days, off and on, wrestling with a chicken-and-egg configuration issue. I have an application that uses Spring 2.0 and is deployed to Tomcat 5.5. We make heavy use of Tomcat&#8217;s JNDI for configuring things like our database connections. We&#8217;re adding JMS functionality to our application; at this point, we merely need to [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve spent several days, off and on, wrestling with a chicken-and-egg configuration issue.</p>
<p>I have an application that uses Spring 2.0 and is deployed to Tomcat 5.5. We make heavy use of Tomcat&#8217;s JNDI for configuring things like our database connections.</p>
<p>We&#8217;re adding JMS functionality to our application; at this point, we merely need to send events to an existing Tibco EMS 4.4 Topic.</p>
<p>Following the various online tutorials, I was able to use Spring to make my JMS code very lightweight. I was pretty happy with things overall, until I encountered the final problem of setting up the configuration.</p>
<p>The Tibco EMS Server provides its own JNDI services, which I need to connect to the correct topic connection factory. I can use Spring&#8217;s JndiTemplate to configure this additional JNDI connection, but I kept hitting one problem. In every environment I&#8217;m going to deploy to, the value for java.naming.provider.url will be different. Because JndiTemplate is using</p>
<p>for setting the environment, I can&#8217;t use a separate JNDI lookup to populate that value out of Tomcat&#8217;s JNDI.</p>
<p>I needed to abstract this value out of my war file, into a configuration file that can stay on each server, so I don&#8217;t have to change it every time. This is an application that gets deployed fresh each new revision, and the client wasn&#8217;t going to be happy to have to extract the war file and then edit a config file, when that&#8217;s never been needed in the past. In addition, each server we&#8217;re deploying to already has a JNDI configuration for the Tibco EMS server. But, no matter how I tried, I could not find a way to configure the Tomcat JNDI to let me access those values from the Spring configuration file within the application.</p>
<p>The solution I found that finally worked was to use a PropertyPlaceholderConfigurer that pointed to a file in the tomcat conf directory. The final hurdle I had to jump was the correct configuration. If I used property=&#8221;location&#8221; value=&#8221;${catalina.home}/conf/jms.properties&#8221;, Spring would attempt to resolve the value from the servlet container by prepending a slash in front of the catalina.home directory. If I attempted to use a relative path, tomcat wouldn&#8217;t allow me open and read the file. I finally hit on prefixing the path with &#8220;file:&#8221; which was the magic to let Spring know I meant an absolute file path.</p>
<p>I am annoyed I have to add a configuration file, but at least it&#8217;s one more place where we can set the value and forget about it for future deployments.</p>
<p>In case anybody hits this combination of problems, here&#8217;s what finally worked:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/beans&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xmlns:jee</span>=<span style="color: #ff0000;">&quot;http://www.springframework.org/schema/jee&quot;</span></span>
<span style="color: #009900;">       <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;</span>
<span style="color: #009900;">       http://www.springframework.org/schema/beans </span>
<span style="color: #009900;">       http://www.springframework.org/schema/beans/spring-beans-2.0.xsd</span>
<span style="color: #009900;">       http://www.springframework.org/schema/jee </span>
<span style="color: #009900;">       http://www.springframework.org/schema/jee/spring-jee-2.0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;propertyConfigurer&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;locations&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>file:${catalina.home}/conf/jms.properties<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/jdbc.properties<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;messageSender&quot;</span>  </span>
<span style="color: #009900;">             <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.stevideter.spring.jms.MessageSender&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jmsTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;jmsTemplate&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jmsTemplate&quot;</span> </span>
<span style="color: #009900;">              <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jms.core.JmsTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;connectionFactory&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;topicConnectionFactory&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;defaultDestinationName&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jee:jndi-lookup</span> <span style="color: #000066;">jndi-name</span>=<span style="color: #ff0000;">&quot;java:comp/env/jms/eventdestname&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pubSubDomain&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;topicConnectionFactory&quot;</span> </span>
<span style="color: #009900;">             <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jndi.JndiObjectFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jndiTemplate&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;jndiTemplate&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jndiName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;FTTopicConnectionFactory&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;jndiTemplate&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jndi.JndiTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;environment&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;java.naming.factory.initial&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                            com.tibco.tibjms.naming.TibjmsInitialContextFactory
                         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;java.naming.provider.url&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                            ${jms.jndicontexturl}
                         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/WAXdy7na6yk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/08/25/simplifying-spring%e2%80%99s-jms-configuration-for-jnditemplate/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Picking the right .NET Framework Version with Specific Reference</title>
		<link>http://www.stevideter.com/2008/08/14/picking-the-right-net-framework-version-with-specific-reference/</link>
		<comments>http://www.stevideter.com/2008/08/14/picking-the-right-net-framework-version-with-specific-reference/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 17:38:02 +0000</pubDate>
		<dc:creator>stevi</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[csharp]]></category>

		<guid isPermaLink="false">http://www.stevideter.com/?p=26</guid>
		<description><![CDATA[This morning I needed to work on a long-standing ASP.NET web application project. I haven&#8217;t had to run it locally for quite a while. I updated my source from TFS, cleaned and built the solution, and started the project in debug mode. After logging in, I went to a page, and was suddenly staring at [...]<div class='yarpp-related-rss yarpp-related-none'>

No related posts.
</div>
]]></description>
				<content:encoded><![CDATA[<p>This morning I needed to work on a long-standing ASP.NET web application project. I haven&#8217;t had to run it locally for quite a while. I updated my source from TFS, cleaned and built the solution, and started the project in debug mode. After logging in, I went to a page, and was suddenly staring at an unexpected and confusing exception:</p>
<pre>The base class includes the field 'ScriptManager1', 
but its type (System.Web.UI.ScriptManager) 
is not compatible with the type of control 
(System.Web.UI.ScriptManager).</pre>
<p>
I put aside the surprise that a type was not compatible with itself, and checked the source control history. The specific page hadn&#8217;t been changed since the last time I&#8217;d tried it. I know the project is under active development, including a recent deployment of the latest version at the client site, so I had ever reason to believe the build should work. </p>
<p>Before sending a panicked email to my team, I did a quick Google search. I found a couple links of similar people with this problem in VS2008, but I&#8217;m still running VS2005. </p>
<p>I realized, however, that I had installed Framework versions 3.0 and 3.5 since I had last had to work on this project. I went to the project references, and checked that for System.Web.Extensions, and noticed that &#8220;Specific Reference&#8221; was set to false. I set this to true, rebuilt the project, and started the debugger again. </p>
<p>This time, success! The page displayed as expected. </p>
<p>What problems have you encountered from having multiple .NET Frameworks installed? </p>
<div class='yarpp-related-rss yarpp-related-none'>
<p>No related posts.</p>
</div>
<img src="http://feeds.feedburner.com/~r/MovingTheCurve/~4/ayJTa6bL6LI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.stevideter.com/2008/08/14/picking-the-right-net-framework-version-with-specific-reference/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
