<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mike Desjardins&#039; Series of Tubes &#187; spring</title>
	<atom:link href="http://www.mikedesjardins.net/content/category/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikedesjardins.net/content</link>
	<description>freelance software developer consultant in portland, maine</description>
	<lastBuildDate>Wed, 02 Feb 2011 00:14:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Configure Spring to automatically re-connect to your EJBs</title>
		<link>http://www.mikedesjardins.net/content/2008/10/configure-spring-to-automatically-re/</link>
		<comments>http://www.mikedesjardins.net/content/2008/10/configure-spring-to-automatically-re/#comments</comments>
		<pubDate>Fri, 24 Oct 2008 15:21:00 +0000</pubDate>
		<dc:creator>Mike Desjardins</dc:creator>
				<category><![CDATA[ejb]]></category>
		<category><![CDATA[ejb3]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://mikedesjardins.us/wordpress/2008/10/configure-spring-to-automatically-re-connect-to-your-ejbs/</guid>
		<description><![CDATA[If you have a service that is a client of a remote EJB, you may have run into the situation where the EJB server shuts down and restarts. When this happens your EJB client may need to be restarted as well, in order to re-discover and reconnect to the EJBs; otherwise you&#8217;ll end up with [...]]]></description>
			<content:encoded><![CDATA[<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://mikedesjardins.us/blog/uploaded_images/beans-777004.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 240px;" src="http://mikedesjardins.us/blog/uploaded_images/beans-776973.jpg" alt="" border="0" /></a>If you have a service that is a client of a remote EJB, you may have run into the situation where the EJB server shuts down and restarts.  When this happens your EJB client may need to be restarted as well, in order to re-discover and reconnect to the EJBs; otherwise you&#8217;ll end up with connection exceptions in the client.</p>
<p>If you&#8217;re using Spring to autowire your EJB clients, it&#8217;s quite easy to configure the service so that the home interface will refresh on connection failures.  Note that if you&#8217;re using EJB3, you will need to upgrade to at least version 2.5.5 of Spring.  There is a <a href="http://jira.springframework.org/browse/SPR-4801">bug</a> in earlier versions of Spring which prevented this technique from working with EJB3.</p>
<p>In your spring file, make sure you configure your slsb references to have cache-home disabled, and refresh-home-0n-connect-failure thusly:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jee:remote-slsb</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myService&quot;</span> <span style="color: #000066;">jndi-name</span>=<span style="color: #ff0000;">&quot;MyService/remote&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">business-interface</span>=<span style="color: #ff0000;">&quot;us.mikedesjardins.services.MyService&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">cache-home</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">lookup-home-on-startup</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">home-interface</span>=<span style="color: #ff0000;">&quot;us.mikedesjardins.services.MyService&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">resource-ref</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">refresh-home-on-connect-failure</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;jee:environment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
           <span style="color: #808080; font-style: italic;">&lt;!-- Include any relevant environment settings here --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jee:environment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jee:remote-slsb<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>With this, you should be able to restart your EJB hosts without needing to restart your EJB clients!</p>
<p><i>Photo Credit: <a href="http://flickr.com/people/wanko/">Wanko</a></i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikedesjardins.net/content/2008/10/configure-spring-to-automatically-re/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

