<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>A Software Guy&#039;s Blog</title>
	<atom:link href="http://asoftwareguy.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://asoftwareguy.com</link>
	<description></description>
	<lastBuildDate>Tue, 07 May 2013 16:46:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='asoftwareguy.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>A Software Guy&#039;s Blog</title>
		<link>http://asoftwareguy.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://asoftwareguy.com/osd.xml" title="A Software Guy&#039;s Blog" />
	<atom:link rel='hub' href='http://asoftwareguy.com/?pushpress=hub'/>
		<item>
		<title>The Agile Mindset</title>
		<link>http://asoftwareguy.com/2013/03/25/the-agile-mindset/</link>
		<comments>http://asoftwareguy.com/2013/03/25/the-agile-mindset/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 14:42:05 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Scrum]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[identity]]></category>
		<category><![CDATA[mindset]]></category>
		<category><![CDATA[scrum]]></category>
		<category><![CDATA[shift]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=357</guid>
		<description><![CDATA[I was thinking back on an interaction I had with one of my co-workers last week, and how that made me realize that I have personally had a shift with how I identify myself at work. This co-worker is relatively new to the company, only having been here for a few weeks, and I hadn&#8217;t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=357&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I was thinking back on an interaction I had with one of my co-workers last week, and how that made me realize that I have personally had a shift with how I identify myself at work. </p>
<p>This co-worker is relatively new to the company, only having been here for a few weeks, and I hadn&#8217;t had opportunity to introduce myself. The other piece of background here is to know that only part of our organization has operated under an Agile framework; the rest is still using a &#8220;traditional&#8221; system. We had the usual exchange of names. But when they asked me who I worked for, my first response is what made me have the epiphany. I didn&#8217;t say my manager&#8217;s name, I didn&#8217;t say &#8220;development&#8221; or even the project I am working on. I said &#8220;the Honey Badgers&#8221;, which is the name we have given to our Scrum team that started together back in 02/2012. </p>
<p>If asked that question before 02/2012, I can almost guarantee you I would have said &#8220;development&#8221; or &#8220;I&#8217;m a developer&#8221; or something to that effect. This is the change in mindset I am referring to. If you are like me, you will no longer find yourself identifying solely with your &#8220;silo&#8221; department; you will identify with the team you have been a part of and built a relationship with over the course of time. This is to take nothing away from my fellow developers or my respect for them. I actually think it is a good thing for the team and the organization when you start to identify yourself this way. It shows that you have invested yourself in your team and have dedicated yourself to the success of what your team produces.</p>
<p>What do you think? If you haven transitioned towards an Agile team from some other sort of management, have you also have this same shift in your mindset?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/357/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=357&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2013/03/25/the-agile-mindset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>Issue with Tomcat deployment after Grails upgrade 2.0.1 -&gt; 2.2.1</title>
		<link>http://asoftwareguy.com/2013/03/08/issue-with-tomcat-deployment-after-grails-upgrade-2-0-1-2-2-1/</link>
		<comments>http://asoftwareguy.com/2013/03/08/issue-with-tomcat-deployment-after-grails-upgrade-2-0-1-2-2-1/#comments</comments>
		<pubDate>Fri, 08 Mar 2013 20:33:17 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Deployments]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[apache tomcat]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[grails 2.0]]></category>
		<category><![CDATA[grails 2.2]]></category>
		<category><![CDATA[integration environment]]></category>
		<category><![CDATA[PeriodicEventListener]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=349</guid>
		<description><![CDATA[I have been in the process of upgrading all of our existing Grails applications from version 2.0.1 to version 2.2.1. On one particular project I upgraded earlier today, everything worked fine until I attempted to deploy the application to our dev. integration environment. At that point, Tomcat throw the following error when attempting to deploy: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=349&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have been in the process of upgrading all of our existing Grails applications from version 2.0.1 to version 2.2.1. On one particular project I upgraded earlier today, everything worked fine until I attempted to deploy the application to our dev. integration environment. At that point, Tomcat throw the following error when attempting to deploy:</p>
<p><code>java.lang.NoClassDefFoundError: org/apache/tomcat/PeriodicEventListener</code></p>
<p>After some <a href="http://stackoverflow.com/questions/13695527/grails-war-without-tomcat-plugin" target="_blank">research</a>, I looked again and realized that indeed the upgrade script had left the Tomcat plug-in installed via application.properties instead of placing a reference into BuildConfig.groovy, which is the recommended approach. (It also re-installed Hibernate, which we don&#8217;t use on this particular application. The upgrade script ALWAYS installs Hibernate!). Here is the correct BuuildConfig.groovy entry:</p>
<pre class="brush: groovy; title: ; notranslate">
plugins {
   // other plug-ins
   build &quot;:tomcat:$grailsVersion&quot;
   // ...
}
</pre>
<p>Once the deployment had failed via the Tomcat Manager, the application was no longer listed but it still resided on the filesystem, and later deployments could not overwrite the files. Here are the steps I had to take to resolve the deployment issue:</p>
<ol>
<li>Deleted the WAR and context directories off of the filesystem</li>
<li>Restarted Tomcat</li>
<li>Verified the application was no longer in filesystem and no longer listed in Tomcat manager</li>
<li>Checked the application into source control with the correct plug-in reference, which triggered CI build and deploy to dev. integration</li>
<li>Smoke test</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/349/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=349&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2013/03/08/issue-with-tomcat-deployment-after-grails-upgrade-2-0-1-2-2-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>Issue with inner classes in Grails 2.2.0</title>
		<link>http://asoftwareguy.com/2013/02/21/issue-with-inner-classes-in-grails-2-2-0/</link>
		<comments>http://asoftwareguy.com/2013/02/21/issue-with-inner-classes-in-grails-2-2-0/#comments</comments>
		<pubDate>Thu, 21 Feb 2013 05:03:40 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[command object]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[grails 2.2]]></category>
		<category><![CDATA[inner class]]></category>
		<category><![CDATA[java inner classes]]></category>
		<category><![CDATA[jsonHeader]]></category>
		<category><![CDATA[jsonHeader error]]></category>
		<category><![CDATA[VerifyError]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=335</guid>
		<description><![CDATA[I was working on a controller in a Grails 2.2.0 project, and it was a Groovy class structured something like this: I have used this pattern previously in Grails 1.3.7 and Grails 2.0.1, however when I invoked the closure which used the command object, I got the following error: errors.GrailsExceptionResolver ERROR VerifyError occurred when processing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=335&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I was working on a controller in a Grails 2.2.0 project, and it was a Groovy class structured something like this:</p>
<pre class="brush: groovy; title: ; notranslate">
package mypackage;

class MyController {
  // controller methods/closures/etc.
  // uses MyControllerCommand in a POST
}

class MyControllerCommand {
  // properties/methods/constraints/etc.
}
</pre>
<p>I have used this pattern previously in Grails 1.3.7 and Grails 2.0.1, however when I invoked the closure which used the command object, I got the following error:<br />
<code><br />
errors.GrailsExceptionResolver ERROR VerifyError occurred when processing request: [POST] /MyApp/myController/myMethod<br />
(class: mypackage/MyController$MyControllerCommand, method: jsonHeader signature: (Ljava/lang/Object;)V) Incompatible object argument for function call. Stacktrace follows: ...<br />
</code></p>
<p>After some head scratching and then remembering something <a href="http://vasya10.wordpress.com" title="Vasu's blog" target="_blank">my colleague</a> said, I moved the command object out to it&#8217;s own Groovy file and the problem went away. After some more searching, I found <a href="http://jira.grails.org/browse/GRAILS-9784" target="_blank">this error</a> in Grails related to using an anonymous inner class in a controller. </p>
<p>But how is this related to the code above? That&#8217;s not an inner class, right? Ah, but it is. Remember how I said this was a Groovy class that housed the controller? When there are multiple class definitions in a single Groovy file, groovyc creates the equivalent of Java inner classes. You can verify this by checking the target directory after compiling your Grails project. In this instance, you would find:<br />
<code>target/classes/mypackage/MyController$MyControllerCommand.class</code> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/335/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/335/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=335&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2013/02/21/issue-with-inner-classes-in-grails-2-2-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>JAX-WS and annotation overload</title>
		<link>http://asoftwareguy.com/2012/10/30/jax-ws-and-annotation-overload/</link>
		<comments>http://asoftwareguy.com/2012/10/30/jax-ws-and-annotation-overload/#comments</comments>
		<pubDate>Tue, 30 Oct 2012 13:22:59 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[jax-ws]]></category>
		<category><![CDATA[web service client]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=328</guid>
		<description><![CDATA[I have been utilizing JAX-WS to generate web service clients in my current Grails project. It is the best I have found so far in consuming SOAP-based web services within a Grails project. I do have one beef with the library though: annotation overload! I am not a huge fan of the overuse of annotations [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=328&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have been utilizing JAX-WS to generate web service clients in my current Grails project. It is the best I have found so far in consuming SOAP-based web services within a Grails project. I do have one beef with the library though: annotation overload! I am not a huge fan of the overuse of annotations that has happened over the last few years. JAX-WS seems to want to take this to a new level. For the most part the annotations do seem to stay out of the way, except for one scenario which we have in many of our XSD schemas: &lt;xsd:any&gt;. </p>
<p>For example, you have defined a complex type where one of the elements is defined to be &lt;xsd:any&gt;, so that different XML documents can be inserted at that element. The problem is that JAX-WS wants to know all of the possible types at compile-time via annotations! If you don&#8217;t provide the run-time classe during compile-time, you will end up with a message liek this when you attempt to marshall the XML:</p>
<p><code><br />
class example.package.MyType nor any of its super class is known to this context<br />
</code></p>
<p>This breaks all of the abstraction and defining the implementation at run-time. I have not found a simple way to get around this and still add classes to the JAXBContext like I used to be able to do. We have been able to work with it for the most part, but if anyone know of an easy way to add classes to the JAX-WS JAXBContext at run-time, feel free to let me know!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=328&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/10/30/jax-ws-and-annotation-overload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>Using GrailsApplication in UrlMappings.groovy</title>
		<link>http://asoftwareguy.com/2012/08/15/using-grailsapplication-in-urlmappings-groovy/</link>
		<comments>http://asoftwareguy.com/2012/08/15/using-grailsapplication-in-urlmappings-groovy/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 19:38:36 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[dynamic mapping]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[grailsApplication]]></category>
		<category><![CDATA[urlmappings]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=321</guid>
		<description><![CDATA[As of the current version of Grails we are using (2.0.1), the grailsApplication bean is not available for use in the UrlMappings class. However, the UrlMappingsHolderFactoryBean implements GrailsApplicationAware, so we can call getGrailsApplication() to do things such as base or mappings conditional on the configuration, like as follows:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=321&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>As of the current version of Grails we are using (2.0.1), the grailsApplication bean is not available for use in the UrlMappings class. However, the <a title="UrlMappingsHolderFactoryBean" href="http://grails.org/doc/2.1.0/api/org/codehaus/groovy/grails/web/mapping/UrlMappingsHolderFactoryBean.html" target="_blank">UrlMappingsHolderFactoryBean</a> implements GrailsApplicationAware, so we can call <code>getGrailsApplication()</code> to do things such as base or mappings conditional on the configuration, like as follows:</p>
<pre class="brush: groovy; title: ; notranslate">
class UrlMappings {
	
	static excludes = [...]

	static mappings = {
		if(getGrailsApplication().config.doA) {
			&quot;/**&quot; (view: '/a')
		} else {
			&quot;/**&quot; (view: '/b')
		}
	}
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/321/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/321/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=321&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/08/15/using-grailsapplication-in-urlmappings-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert a 32-bit JIRA install to 64-bit</title>
		<link>http://asoftwareguy.com/2012/07/03/convert-a-32-bit-jira-install-to-64-bit/</link>
		<comments>http://asoftwareguy.com/2012/07/03/convert-a-32-bit-jira-install-to-64-bit/#comments</comments>
		<pubDate>Tue, 03 Jul 2012 13:04:33 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[Atlassian]]></category>
		<category><![CDATA[heap space]]></category>
		<category><![CDATA[JIRA]]></category>
		<category><![CDATA[JIRA OutOfMemoryError]]></category>
		<category><![CDATA[OutOfMemoryError]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=316</guid>
		<description><![CDATA[Along with being a software developer on our project, I have also become the unofficial tools administrator. We utilize many of the Atlassian tools, among them being JIRA. When JIRA was installed, it was put an a Windows Server 2008 R2 server, but was installed with the JIRA Standalone 32-bit installer. Due to the Windows memory addressing space [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=316&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Along with being a software developer on our project, I have also become the unofficial tools administrator. We utilize many of the Atlassian tools, among them being JIRA. When JIRA was installed, it was put an a Windows Server 2008 R2 server, but was installed with the JIRA Standalone 32-bit installer. Due to the Windows memory addressing space when processes are running 32-bit, we could only allocate ~1GB of heap space to the JVM. Any more and the JVM would fail to start. Any less and the process would throw a java.lang.OutOf Memory error before it even started fully. Even at the magical 1GB heap size, we would only run stable for 0.5-1.0 day before we would blow the heap.</p>
<p>I contacted Atlassian support about getting our install running as a 64-bit process on a 64-bit JVM and their response was &#8220;Create a new database schema, install the 64-bit JIRA standalone pointing at that new schema and then migrate your data from the old schema to the new schema. No, not happening. I did some digging and figured out how to get the 32-bit install to run as a 64-bit process. Once I did this, the process started as a 64-bit Windows process and I was able to allocate more memory to the heap.</p>
<ol>
<li>Put a 64-bit JVM on the system, if it does not already have one.</li>
<li>Change the Tomcat process properties to point to the 64-bit JVM.</li>
<li>Rename tomcat.exe to tomcat.exe.x86</li>
<li>Rename tomcat.exe.x64 to tomcat.exe</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/316/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/316/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=316&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/07/03/convert-a-32-bit-jira-install-to-64-bit/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>MSDeploy and when it just stops working</title>
		<link>http://asoftwareguy.com/2012/05/03/msdeploy-and-when-it-just-stops-working/</link>
		<comments>http://asoftwareguy.com/2012/05/03/msdeploy-and-when-it-just-stops-working/#comments</comments>
		<pubDate>Fri, 04 May 2012 03:32:56 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Builds]]></category>
		<category><![CDATA[Deployments]]></category>
		<category><![CDATA[.IIS]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[failing]]></category>
		<category><![CDATA[failure]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[MSDeploy]]></category>

		<guid isPermaLink="false">https://asoftwareguy.wordpress.com/?p=298</guid>
		<description><![CDATA[On my current project, we have a Bamboo continuous integration server that deploys an ASP.net application packaged with MSBuild to our dev integration IIS server. This deployment happens via MSDeploy using the following command in the MSBuild script: Everything is good with the command and deployments to iisserver were happening many times a day for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=298&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>On my current project, we have a Bamboo continuous integration server that deploys an ASP.net application packaged with MSBuild to our dev integration IIS server. This deployment happens via MSDeploy using the following command in the MSBuild script:</p>
<pre class="brush: plain; title: ; notranslate">
&quot;C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe&quot; -source:package='path\to\the.zip' -dest:auto,wmsvc='https://iisserver:8172/msdeploy.axd?Site=MySite',userName='*****',password='*****',includeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:path\to\the.SetParameters.xml -allowUntrusted
</pre>
<p>Everything is good with the command and deployments to iisserver were happening many times a day for a few months. Then the other day, the dev integration deployment job started failing with the following error:<br />
<code><br />
Error: (build date) An error occurred when the request was processed on the remote computer.</p>
<p>Error: Unable to perform the operation. Please contact your server administrator to check authorization and delegation settings.<br />
</code></p>
<p>Nice error! Very informative. So I go ahead and check all the usual things: did a code change break something (no); did the user account represented by userName in the command get locked (no), or did its password expire (no); was the wmsvc agent running on the server (yes); were any Windows updates installed on the server (yes, on the same day the deployment started breaking); were there any changes to the Window or IIS server configuration (no)</p>
<p>With these checks done, the only one that seemed possible was one of the Windows updates might have done it. So I backed out the updates. But that didn&#8217;t fix the issue. Hmm, alright. After quite a bit of effort and time expended by myself and our systems administrators, I finally dug up <a title="StackOverflow MSDeploy issue" href="http://stackoverflow.com/questions/6939150/web-deployment-task-build-failed" target="_blank">this StackOverflow issue</a> that sounded similar. The answer is what caught me:<br />
<em><br />
&#8230;Turns out that when you install web deploy it sets up two local accounts WDeployConfigWriter and WDeployAdmin. These passwords on these accounts are set to expire&#8230;<br />
</em><br />
Ah ha! Wait, what?! In addition to the domain service account I use on the command line, there are 2 more local accounts required by the tool? That I didn&#8217;t know were there? And they had passwords set to expire after 90 days? Really? Awesome. In any case, after &#8220;fixing&#8221; those two accounts on the dev integration server, they deployments started working as they had before.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=298&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/05/03/msdeploy-and-when-it-just-stops-working/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>A Groovy temperature conversion with Categories</title>
		<link>http://asoftwareguy.com/2012/03/12/a-groovy-temperature-conversion-with-categories/</link>
		<comments>http://asoftwareguy.com/2012/03/12/a-groovy-temperature-conversion-with-categories/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 15:43:00 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[DSL]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[MOP]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[groovy categories]]></category>
		<category><![CDATA[groovy meta programming]]></category>
		<category><![CDATA[groovy MOP]]></category>
		<category><![CDATA[groovy temperature conversion]]></category>
		<category><![CDATA[temperature conversion]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=263</guid>
		<description><![CDATA[I have been getting more interested with the capabilities of the Groovy language since I have used it more and more as part of my daily work on a Grails web application. I have also been having some interesting conversations with one of my co-workers about the possibilities provided by Groovy&#8217;s MOP (Meta Object Protocol) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=263&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I have been getting more interested with the capabilities of the Groovy language since I have used it more and more as part of my daily work on a Grails web application. I have also been having some interesting conversations with <a title="Vasya's Weblog" href="http://vasya10.wordpress.com" target="_blank">one of my co-workers</a> about the possibilities provided by Groovy&#8217;s MOP (Meta Object Protocol) for creating new ways of expressing meaning in the contextual space of a given problem area using DSLs (Domain Specific Languages). I have seen a few examples of augmenting existing Java classes with new functionality by using Categories wrapped around the existing classes, but have mainly seen these related to distances and conversion of units of measure within that domain. I thought back to one of the first programs I wrote (can&#8217;t remember the language, maybe it was C) for doing temperature conversion between degrees Fahrenheit and Celsius. So, I thought I would give an example of using <a title="Groovy Categories" href="http://docs.codehaus.org/display/GROOVY/Groovy+Categories" target="_blank">Groovy Categories</a> to add new functionality to existing Java classes.</p>
<h2>The problem</h2>
<p>So let&#8217;s assume that you are tasked with writing a temperature conversion application. This converter should be able to convert temperatures given in either degrees Fahrenheit or Celsius and give the result in degrees Fahrenheit. Sounds easy enough, you can model things within the class(es) exactly how you need to solve the problem. But wait! There is another stipulation. You are told that there is already an existing class in some existing archaic Java library that was written ten years ago, and you have you use this class within your code. You think, alright, even if the class is wretched, I can write some new Java code and extend the existing class to offer the new functionality. Presenting the Java class you are required to use:</p>
<p>AncientTemperature.java</p>
<pre class="brush: java; title: ; notranslate">
package com.asoftwareguy.temperature;

/**
 * This is an &quot;old&quot; existing Java class representing temperature.
 * It assumes the unit of measure is degrees Fahrenheit.
 *
 */
public final class AncientTemperature {
	// in degrees Fahrenheit
	private int temp;

	public AncientTemperature(int temp) {
		this.temp = temp;
	}

	public String toString() {
		return new StringBuilder().append(&quot;The current temperature is &quot; + temp + &quot; degrees F.&quot;).toString();
	}
}
</pre>
<p>The class is declared final! So the creator of this class, a decade or so ago, found it in their infinite wisdom that their representation of temperature was perfect and no one would ever need to add any more functionality. Awesome! :/</p>
<h2>The solution</h2>
<p>You could obviously also create new functionality by creating a <a title="Decorator pattern" href="http://en.wikipedia.org/wiki/Decorator_pattern" target="_blank">decorator</a> class and using composition to delegate calls when necessary out to the existing class, but you are using Groovy, so why would you do that! Here the requirements stated above are as follows:</p>
<ol>
<li>We need to be able to give the temperature inputs in either degress Fahrenheit or Celsius.</li>
<li>We need to be able to give the resulting temperature in degrees Fahrenheit.</li>
<li>We have to use the existing AncientTemperature.java class.</li>
</ol>
<p>Requirement #3 is de facto by mandate, so let&#8217;s ignore that one. After looking at what we have to work with, it seems that we have requirement #2 already met by the functionality of the existing class. The toString() method spits out the temperature in degrees Fahrenheit:</p>
<pre class="brush: java; highlight: [7,8,9]; title: ; notranslate">
package com.asoftwareguy.temperature;

public final class AncientTemperature {

	// other methods

	public String toString() {
		return new StringBuilder().append(&quot;The current temperature is &quot; + temp + &quot; degrees F.&quot;).toString();
	}
}
</pre>
<p>Let&#8217;s look at how we can meet requirement #1 using Categories. Categories in Groovy are somewhat similar to the concept of <a title="Extension Methods in C#" href="http://msdn.microsoft.com/en-us/library/bb383977.aspx" target="_blank">static extension methods in C#</a> with one key difference: <em>In C#, you can only add new methods to the class which you are extending; you cannot override methods that already exist in the class. In Groovy, you can add new methods <strong>as well as override existing methods</strong> in the class you are extending!</em> This a powerful feature and one that I will use in this example. Let&#8217;s take a look at our Category:</p>
<p>TemperatureConversion.groovy</p>
<pre class="brush: groovy; title: ; notranslate">
package com.asoftwareguy.temperature

class TemperatureConversion {

	static AncientTemperature getFahrenheit(String fahrenheit) {
		new AncientTemperature(fahrenheit as int)
	}

	static AncientTemperature getCelsius(String celsius) {
		BigDecimal fahrenheit = (celsius.toInteger() *  (9/5) + 32)
		fahrenheit = fahrenheit.setScale(0, BigDecimal.ROUND_DOWN)
		new AncientTemperature(fahrenheit.toString() as int)
	}

	static AncientTemperature getFahrenheit(Integer fareheit) {
		new AncientTemperature(fareheit)
	}

	static AncientTemperature getCelsius(Integer celsius) {
		BigDecimal fahrenheit = (celsius *  (9/5) + 32)
		fahrenheit = fahrenheit.setScale(0, BigDecimal.ROUND_DOWN)
		new AncientTemperature(fahrenheit.toString() as int)
	}
}
</pre>
<p>If you have done any kind of temperature conversion before, the code above should look familiar. It uses the standard formulas for converting temperature between degrees Fahrenheit and Celsius, and vice-verse. With this code in place, it allows you to write code like the following, using a &#8216;use&#8217; block in Groovy:</p>
<p>TemperatureTest.groovy</p>
<pre class="brush: groovy; title: ; notranslate">
package com.asoftwareguy.temperature

use(TemperatureConversion) {
	assert  &quot;100&quot;.fahrenheit.toString() == 'The current temperature is 100 degrees F.'
	println &quot;100&quot;.fahrenheit

	assert 	&quot;50&quot;.fahrenheit.toString() == 'The current temperature is 50 degrees F.'
	println &quot;50&quot;.fahrenheit

	assert 	&quot;32&quot;.fahrenheit.toString() == 'The current temperature is 32 degrees F.'
	println &quot;32&quot;.fahrenheit

	assert 	&quot;100&quot;.celsius.toString() == 'The current temperature is 212 degrees F.'
	println &quot;100&quot;.celsius

	assert 	100.fahrenheit.toString() == 'The current temperature is 100 degrees F.'
	println 100.fahrenheit

	assert 	50.fahrenheit.toString() == 'The current temperature is 50 degrees F.'
	println 50.fahrenheit

	assert 	32.fahrenheit.toString() == 'The current temperature is 32 degrees F.'
	println 32.fahrenheit

	assert 	100.celsius.toString() == 'The current temperature is 212 degrees F.'
	println 100.celsius
}
</pre>
<p>All of the methods defined in TemperatureConversion.groovy only add new functionality to the AncientTemperature.java class. The &#8216;use&#8217; block is key to this working, as it provides that any types declared within the block expose the methods of the Category. I had mentioned earlier that in Groovy, you can also override existing methods and I also said I would give an example. So here is the version of the Category with overriding methods:</p>
<p>TemperatureConversion.groovy</p>
<pre class="brush: groovy; highlight: [7,8,9,10,11,12,13,14,15,16,17,18,19]; title: ; notranslate">
package com.asoftwareguy.temperature

class TemperatureConversion {

	// other methods

	static AncientTemperature plus(AncientTemperature first, AncientTemperature second) {
		int tempFirst = first.temp
		int tempSecond = second.temp;
		int newTemp = tempFirst + tempSecond
		return new AncientTemperature(newTemp)
	}

	static AncientTemperature minus(AncientTemperature first, AncientTemperature second) {
		int tempFirst = first.temp
		int tempSecond = second.temp;
		int newTemp = tempFirst - tempSecond
		return new AncientTemperature(newTemp)
	}
}
</pre>
<p>As you can see above, we have actually overrode the ability to add and subtract objects of AncientTemperature with each other. We can do this even though we do not have this ability in Java because by default, Groovy adds the plus and minus (along with many other methods) to all objects. So now we can write code like this:</p>
<pre class="brush: groovy; highlight: [6,7,9,10,12,13]; title: ; notranslate">
package com.asoftwareguy.temperature

use(TemperatureConversion) {
	// other methods

	assert (100.fahrenheit + 50.fahrenheit).toString() == 'The current temperature is 150 degrees F.'
	println 100.fahrenheit + 50.fahrenheit

	assert (100.fahrenheit + 0.celsius).toString() == 'The current temperature is 132 degrees F.'
	println 100.fahrenheit + 0.celsius

	assert (100.fahrenheit - 0.celsius).toString() == 'The current temperature is 68 degrees F.'
	println 100.fahrenheit - 0.celsius
}
</pre>
<p>Groovy Categories are a powerful tool in providing new functionality to existing types at run-time and for creating DSLs that can describe your problem space. Hopefully this has provided you with a good example of using Groovy Categories to add such functionality. </p>
<p>All of the source code for this post can be found in <a href="https://gist.github.com/2022678" title="Source code" target="_blank">this Gist</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/263/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/263/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=263&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/03/12/a-groovy-temperature-conversion-with-categories/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
		<item>
		<title>Implementing a Grails required interstitial form page</title>
		<link>http://asoftwareguy.com/2012/03/05/implementing-a-grails-required-interstitial-form-page/</link>
		<comments>http://asoftwareguy.com/2012/03/05/implementing-a-grails-required-interstitial-form-page/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 19:31:27 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[intermediate form]]></category>
		<category><![CDATA[interstitial form]]></category>
		<category><![CDATA[required form]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=230</guid>
		<description><![CDATA[Having shared functionality/pages across software modules in web application development seems to be a common occurrence (at least within the projects on which I am working) and is a problem that can be handled in a number of ways. Currently, I happen to be implementing two different user modules in a Grails 2.0.x application that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=230&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Having shared functionality/pages across software modules in web application development seems to be a common occurrence (at least within the projects on which I am working) and is a problem that can be handled in a number of ways. Currently, I happen to be implementing two different user modules in a Grails 2.0.x application that ended up needing such shared functionality, so I thought I would share my solution. I am going to describe how I initially developed the modules, and how I solved the problem of having a required common interstitial form page that is shared between the two or more page flows.</p>
<h2>The first module</h2>
<p>The page flow within the first module is as described in Figure 1 below:</p>
<div id="attachment_232" class="wp-caption alignnone" style="width: 507px"><a href="http://asoftwareguy.files.wordpress.com/2012/03/option1.png"><img class="size-full wp-image-232" title="Option1" src="http://asoftwareguy.files.wordpress.com/2012/03/option1.png?w=625" alt=""   /></a><p class="wp-caption-text">Figure 1</p></div>
<p>When developing the module, both web page forms represented by the 2nd and 3rd steps in the flow were implemented within the same controller class (following the practice of Agile development of implementing what you need right now, and refactoring when circumstances require you to do so). Everything good so far, this is all standard web application development. Story complete, so let&#8217;s look at the second module.</p>
<h2>The second module</h2>
<p>The page flow within the second module is as described in Figure 2 below:</p>
<div id="attachment_234" class="wp-caption alignnone" style="width: 507px"><a href="http://asoftwareguy.files.wordpress.com/2012/03/option2.png"><img class="size-full wp-image-234" title="Option2" src="http://asoftwareguy.files.wordpress.com/2012/03/option2.png?w=625" alt=""   /></a><p class="wp-caption-text">Figure 2</p></div>
<p>Note that the 2nd step in both Figure 1 and Figure 2 both note that some user input is required before the actual function can commence. As it turns out, the user input required is identical, meaning the exact same form data is captured from the user. This is depicted in Figure 3:</p>
<div id="attachment_233" class="wp-caption alignnone" style="width: 507px"><a href="http://asoftwareguy.files.wordpress.com/2012/03/option1-2.png"><img class="size-full wp-image-233" title="Option1-2" src="http://asoftwareguy.files.wordpress.com/2012/03/option1-2.png?w=625" alt=""   /></a><p class="wp-caption-text">Figure 3</p></div>
<p>In &#8220;traditional&#8221; (read: lazy) web development, I might just copy all of the logic for displaying the form and capturing the input from the Option1 controller(s) within Module A into the Option 2 controller(s) within Module B. But I figured it could be implemented so much more cleanly without the need for any code duplication. The solution I decided upon was to implement the logic for determining the need to direct the user to the interstitial page within a Grails <a title="Grails Filter" href="http://grails.org/doc/latest/guide/theWebLayer.html#6.6%20Filters" target="_blank">Filter</a>.</p>
<h2>The solution</h2>
<p>Let&#8217;s take a look at the Filter class that determines whether the user is required to be directed to the interstitial page.</p>
<p>RequiredAttributeFilters.groovy</p>
<pre class="brush: groovy; title: ; notranslate">
class RequiredAttributeFilters {
  def filters = {
    attributeRequiredforOptionA(controller: 'optionA', action: 'index') {
      before = {
        if(session.someAttribute == null) {
          // attribute not set, redirect user to collect data
          def targetUri = request.forwardURI.replace(request.contextPath, '')
          session.requiredAttributesFilterRedirectUri = targetUri
          redirect controller: 'requiredUserInput', action: 'index'
        }
      }
    }
    attributeRequiredforOptionB(controller: 'optionB', action: 'index') {
      before = {
	if(session.someAttribute == null) {
          // attribute not set, redirect user to collect data
          def targetUri = request.forwardURI.replace(request.contextPath, '')
          session.requiredAttributesFilterRedirectUri = targetUri
          redirect controller: 'requiredUserInput', action: 'index'
        }
      }
    }
    removeSomeAttribute(controller: 'user', action: 'menu') {
      before = {
        // user exited current function, remove required attribute
        session.someAttribute = null
      }
    }
  }
}
</pre>
<p>This is just a standard Grails filter class that intercepts requests to &#8220;/option1/index&#8221; and &#8220;/option2/index&#8221; and redirects the user to &#8220;/requiredUserInput/index&#8221; if the value of session.someAttribute is null. Before redirection, it stores the value of the URL that user initially requested in the session. It also removes the attribute from session if the user exits current function (in my case, goes back to their menu). Now that we have the filter is place, let&#8217;s look at the controller that captures the required user input.</p>
<p>RequiredUserInputController.groovy</p>
<pre class="brush: groovy; title: ; notranslate">
class RequiredUserInputController {
  def index = {
    // do stuff
    // render view
    render view: 'index'
  }
  def captureData = { 
    // check form errors etc.
    def someAttribute = null;
    // get the data and set the attribute in session
    session.someAttribute = someAttribute
    redirect uri: session.requiredAttributesFilterRedirectUri
  }
}
</pre>
<p>The above controller has two methods: the standard &#8220;index&#8221; method for rendering the form and the &#8220;captureData&#8221; method, which is called upon form submission. The latter performs any required form processing, and in addition, sets the value of session.someAttribute to the correct current value. It then redirects to the URL that was set in session by the filter that redirected here in the first place. The filter is called again, but session.someAttribute has a value so filter processing is skipped. I won&#8217;t detail the GSP code for the form page, but it contains a simple form whose action attribute points to the &#8220;captureData&#8221; URL.</p>
<p>That&#8217;s all there is to it. If in the future additional page flows need to same data in order to proceed, those controllers/actions/URIs just need to be added to the Filter class so that the interception occurs.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/230/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/230/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=230&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/03/05/implementing-a-grails-required-interstitial-form-page/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>

		<media:content url="http://asoftwareguy.files.wordpress.com/2012/03/option1.png" medium="image">
			<media:title type="html">Option1</media:title>
		</media:content>

		<media:content url="http://asoftwareguy.files.wordpress.com/2012/03/option2.png" medium="image">
			<media:title type="html">Option2</media:title>
		</media:content>

		<media:content url="http://asoftwareguy.files.wordpress.com/2012/03/option1-2.png" medium="image">
			<media:title type="html">Option1-2</media:title>
		</media:content>
	</item>
		<item>
		<title>Grails 2.0 mockFor() Gotcha</title>
		<link>http://asoftwareguy.com/2012/02/28/grails-2-0-mockfor-gotcha/</link>
		<comments>http://asoftwareguy.com/2012/02/28/grails-2-0-mockfor-gotcha/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 15:35:36 +0000</pubDate>
		<dc:creator>asoftwareguy</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[gmock]]></category>
		<category><![CDATA[grails]]></category>
		<category><![CDATA[grails 2.0]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[groovy mock]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[test mixin]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://asoftwareguy.com/?p=206</guid>
		<description><![CDATA[Update: When I was researching another Grails issue, I found out that what I encountered below looks to be fixed in Grails 2.0.1. I have yet to verify the fix, but if you also encounter this issue I urge you to try Grails 2.0.1 to see if it resolves the problem. I am working on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=206&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><em>Update: When I was researching another Grails issue, I found out that what I encountered below <a title="GRAILS-8511 JIRA" href="http://jira.grails.org/browse/GRAILS-8511" target="_blank">looks to be fixed</a> in Grails 2.0.1. I have yet to verify the fix, but if you also encounter this issue I urge you to try Grails 2.0.1 to see if it resolves the problem.</em></p>
<p>I am working on a Grails 2.0.x project and am quite enjoying some of the new features that are part of the current Grails release. The new test mixins that are part of Grails 2.0.x are awesome and really simplify the creation of your unit test classes. But I ran across a &#8220;gotcha&#8221; when using the test mixins.</p>
<p>I was writing a unit test class for a Grails controller, and was using the default template that gets created via:</p>
<p><code>grails create-controller com.asoftwareguy.example.Example</code></p>
<p>One of the helper methods exposed by the GrailsUnitTestMixin is the mockFor() method, which is a simplified way of creating a new Groovy mock. I though this to be much cleaner than needing to instantiate a new MockFor() every time I needed a mock proxy for an interface. However, I ran into an issue where the proxy instances created by the mockFor() method of the mixin are not cleaned up between test case runs. Let me give an example of what was failing.</p>
<p>ExampleController.groovy</p>
<pre class="brush: groovy; title: ; notranslate">

package com.asoftwareguy.example

class ExampleController {

  def exampleService

  def index() {
    def something = exampleService.doSomething()
    render (view: 'index', model: [something: something])
  }
}
</pre>
<p>ExampleService.groovy</p>
<pre class="brush: groovy; title: ; notranslate">
package com.asoftwareguy.example

interface ExampleService {
  List doSomething();
}
</pre>
<p>ExampleControllerTests.groovy</p>
<pre class="brush: groovy; title: ; notranslate">
package com.asoftwareguy.example

@TestFor(ExampleController)
class ExampleControllerTests {

  void testDoSomething_first_time() {
    def mockService = mockFor(ExampleService) //use the mixin
    mockService.demand.doSomething() { -&gt;
      return true
    }
    controller.exampleService = mockService.createMock()
    controller.index()
    // assertions
  }

  void testListStations_second_time() {
    def mockService = mockFor(ExampleService) //use the mixin
    mockService.demand.doSomething() { -&gt;
      return true
    }
    controller.exampleService = mockService.createMock()
    controller.index()
    // assertions
  }
}
</pre>
<p>With the above code in place, the first test case would always pass, but the second test case would fail with the following error:</p>
<pre>| Failure:  testListStations_second_time(com.asoftwareguy.example.ExampleControllerTests)
|  junit.framework.AssertionFailedError: No more calls to 'doSomething' expected at this point. End of demands.
at grails.test.MockClosureProxy.doBeforeCall(MockClosureProxy.java:66)
at grails.test.AbstractClosureProxy.call(AbstractClosureProxy.java:74)
at com.asoftwareguy.example.ExampleController.index(ExampleController.groovy:xx)
at com.asoftwareguy.example.ExampleControllerTests.testListStations_second_time(ExampleControllerTests.groovy:xx)
| Completed 2 unit tests, 1 failed</pre>
<p>After some troubleshooting and debugging the issue, I have concluded that there is a bug in the version of Grails I running (2.0.0) and hopefully it is fixed in the next release. As a workaround, I have reverted to instantiating new MockFor() instances within each test case.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/asoftwareguy.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/asoftwareguy.wordpress.com/206/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=asoftwareguy.com&#038;blog=15771260&#038;post=206&#038;subd=asoftwareguy&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://asoftwareguy.com/2012/02/28/grails-2-0-mockfor-gotcha/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cda4957610d4783269e691c926e4db4b?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">asoftwareguy</media:title>
		</media:content>
	</item>
	</channel>
</rss>
