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

<channel>
	<title>englishteeth.co.uk</title>
	<atom:link href="http://www.englishteeth.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.englishteeth.co.uk</link>
	<description>... the weblog of Ian "English Teeth" Robinson</description>
	<pubDate>Wed, 22 Oct 2008 20:43:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Grails: Role based security on Jetty &#038; JBoss</title>
		<link>http://www.englishteeth.co.uk/2008/10/22/grails-security/</link>
		<comments>http://www.englishteeth.co.uk/2008/10/22/grails-security/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 20:43:48 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=81</guid>
		<description><![CDATA[Todays challenge.. Security!
Hardly a challenge at all really, the JSecurity Plugin - Quick Start takes you through everything you need to do and there&#8217;s also a AcegiSecurity Plugin, if that&#8217;s your bag.
There you go, post done. 
Well&#8230; unless you want/need to use JEE role based authentication at the application server level. That&#8217;s a little more [...]]]></description>
			<content:encoded><![CDATA[<p>Todays challenge.. Security!</p>
<p>Hardly a challenge at all really, the <a href="http://www.grails.org/JSecurity+Plugin+-+Quick+Start">JSecurity Plugin - Quick Start</a> takes you through everything you need to do and there&#8217;s also a <a href="http://www.grails.org/AcegiSecurity+Plugin">AcegiSecurity Plugin</a>, if that&#8217;s your bag.</p>
<p>There you go, post done. </p>
<p>Well&#8230; unless you want/need to use JEE role based authentication at the application server level. That&#8217;s a little more involved.</p>
<p>Unfortunately, this involves a little jiggery pokery in grails itself, but this is only really to have the bundled <a href="http://docs.codehaus.org/display/JETTY/How+to+Configure+Security+with+Embedded+Jetty">jetty server </a> include some security configuration. The intention here is after all, having the authentication at the application server level. </p>
<p>The task has been covered admirably at <a href="http://www.thecoderscorner.com/">the coders corner</a> in the article <a href="http://www.thecoderscorner.com/articleGen/show/10">Setting up Grails to work with JEE role based authentication</a>. This then goes on expand on how to expose the grails project&#8217;s web.xml, in order to configure the access.<br />
<code>grails install-templates</code><br />
And what you need to put in src/templates/web.xml to configure the access is covered in <a href="http://thecoderscorner.com/articleGen/show/9">Using Role based security</a>, in much greater  detail than I would want to duplicate here.</p>
<p>There really is nothing to add so far, the steps described just work.</p>
<p>The next step took a bit more digging and looking outside of grails oriented guides. The actual deployment environment I have to target is <a href="http://www.englishteeth.co.uk/2008/10/17/deplyoing-a-grails-application-to-jboss/">JBoss</a>, but the best description of the security configuration I found was in the article <a href="http://www.fusioncube.net/index.php/jboss-role-based-security">JBoss Role-Based Security</a>. </p>
<p>This got me 90% there. To bend it to grails, I had to add a little bit more to the <a href="http://www.englishteeth.co.uk/2008/10/17/deplyoing-a-grails-application-to-jboss/">jboss-web.xml file I added for deploying to JBoss</a>:</p>
<pre class="syntax-highlight:xml">
    &lt;context-root&gt;/my_app&lt;/context-root&gt;
    &lt;security-domain&gt;java:/jaas/my_app_policy&lt;/security-domain&gt;
</pre>
<p>Obviously making sure the domain matched what I had put in the JBoss configuration.</p>
<p>I also happened to include two properties files for roles and users in src\java so they were deployed with the application and reference these in the JBoss configuration file login-config.xml:</p>
<pre class="syntax-highlight:xml">
  &lt;application-policy name =&quot;my_app_policy&quot;&gt;
    &lt;authentication&gt;
      &lt;login-module code=&quot;org.jboss.security.auth.spi.UsersRolesLoginModule&quot; flag=&quot;required&quot;&gt;
        &lt;module-option name=&quot;usersProperties&quot;&gt;my_app-users.properties&lt;/module-option&gt;
        &lt;module-option name=&quot;rolesProperties&quot;&gt;my_app-roles.properties&lt;/module-option&gt;
      &lt;/login-module&gt;
    &lt;/authentication&gt;
  &lt;/application-policy&gt;
</pre>
<p>This has worked for me locally, but as I describe it, I feel that it is a bit odd having a dependency between the server configuration and specific files in a deployed application; even though their absence doesn&#8217;t seem to cause a problem. I think I might move those into the folder along with login-config.xml </p>
<p>I also believe that these could be just as easily be the default files JBoss expects by not specifying the above module-option elements.</p>
<p>All this done&#8230;</p>
<p><strong>It didn&#8217;t work!</strong></p>
<p>As soon as I tried to access a protected resource, I got a 404 error trying to locate the authentication controller actions I have in my application!</p>
<p>I couldn&#8217;t find a clear reference to this problem, but the following entry on the struts issues dashboard -<br />
<a href="https://issues.apache.org/struts/browse/WW-2025">Action&#8217;s can&#8217;t be used for web.xml declarative security URL&#8217;s</a> certainly describes the problem and also provided me with a <del datetime="2008-10-22T15:14:57+00:00">fudge</del> solution.</p>
<p>I edited my web.xml to point at a jsp:</p>
<pre class="syntax-highlight:xml">
    &lt;login-config&gt;
        &lt;auth-method&gt;FORM&lt;/auth-method&gt;
        &lt;form-login-config&gt;
            &lt;form-login-page&gt;/login_redirect.jsp&lt;/form-login-page&gt;
            &lt;form-error-page&gt;/login_redirect.jsp?success=false&lt;/form-error-page&gt;
        &lt;/form-login-config&gt;
    &lt;/login-config&gt;
</pre>
<p>and added a login_redirect.jsp:</p>
<pre class="syntax-highlight:java">
   &lt;%
        if (&quot;false&quot;.equals(request.getParameter(&quot;success&quot;))) {
            response.sendRedirect( request.getContextPath() + &quot;/auth/failed&quot; );
        } else {
            response.sendRedirect( request.getContextPath() + &quot;/auth/login&quot; );
        }
    %&gt;
</pre>
<p>Now it works!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/10/22/grails-security/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Deplyoing a Grails application to JBoss</title>
		<link>http://www.englishteeth.co.uk/2008/10/17/deplyoing-a-grails-application-to-jboss/</link>
		<comments>http://www.englishteeth.co.uk/2008/10/17/deplyoing-a-grails-application-to-jboss/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 11:53:37 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=82</guid>
		<description><![CDATA[So it seems that every month or so I am able to blow the dust off my little Groovy on Grails project and progress it a little. A little frustrating, since the elapsed time of this belies the gains in using grails.
I have a working application. It has a few rough edges, but for all [...]]]></description>
			<content:encoded><![CDATA[<p>So it seems that every month or so I am able to blow the dust off my little <a href="http://grails.org/">Groovy on Grails</a> project and progress it a little. A little frustrating, since the elapsed time of this belies the gains in using grails.</p>
<p>I have a working application. It has a few rough edges, but for all intents and purposes, it&#8217;s there. I just needed to see if creating war and deploying to the target environment, <a href="http://www.jboss.org/">JBoss</a>.</p>
<p>Surely it can&#8217;t be as simple as&#8230;<br />
<code>C:\local\groovy\my_app> grails war</code></p>
<p>No, it isn&#8217;t&#8230; But nearly!</p>
<p>Deploying into JBoss, the problem I hit was down to log4j and the jar within the deployed grails application conflicting with the one in JBoss.</p>
<p>Obviously this has all been covered before and a few alternatives are offered on the <a href="http://grails.org/FAQ">grails faq</a>.<br />
<a href="http://grails.org/FAQ#Q:%20I%27m%20getting%20errors%20when%20deploying%20on%20JBoss%204.0.x%20What%20do%20I%20do?">Q: I&#8217;m getting errors when deploying on JBoss 4.0.x What do I do?</a></p>
<p>First off I had to scope the application classloader. To do this for a war, create a file called jboss-web.xml with content like the following:</p>
<pre class="syntax-highlight:xml">
&lt;jboss-web&gt;
    &lt;class-loading java2ClassLoadingCompliance = &quot;false&quot;&gt;
        &lt;loader-repository&gt;
            my_app:loader=my_app-0.1.war
            &lt;loader-repository-config&gt;java2ParentDelegation=false&lt;/loader-repository-config&gt;
        &lt;/loader-repository&gt;
    &lt;/class-loading&gt;
&lt;/jboss-web&gt;
</pre>
<p>and place it in the web-app\WEB-INF folder.</p>
<p>This still isn&#8217;t quite enough to get it to work though, since the log4j.properties file used by JBoss still results in a conflict of interest. </p>
<p>Luckily enough I was able to take the preferred solution of renaming JBoss&#8217; log4j.xml to jboss-log4j.xml and editing the jboss-service.xml file such that the <em>ConfigurationURL</em> of <em>org.jboss.logging.Log4JService</em> points to the renamed file.</p>
<p>Et voila!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/10/17/deplyoing-a-grails-application-to-jboss/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Groovy on Grails and my &#8220;Test First&#8221; impasse</title>
		<link>http://www.englishteeth.co.uk/2008/09/04/groovy-on-grails-impasse/</link>
		<comments>http://www.englishteeth.co.uk/2008/09/04/groovy-on-grails-impasse/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 08:08:41 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=80</guid>
		<description><![CDATA[I&#8217;ve hit what would be a test first impasse (if I had tried to write my test first). So in an attempt to leave it alone, I&#8217;ll record where I got to and the resources that I think nearly got me to a solution&#8230;
I have a domain object for which I want to return a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve hit what would be a <em>test first</em> impasse (if I had tried to write my test first). So in an attempt to leave it alone, I&#8217;ll record where I got to and the resources that I think nearly got me to a solution&#8230;</p>
<p>I have a domain object for which I want to return a filtered set. I know that this can be done as a closure to the list method of <a href="http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Criteria.html">hibernate criteria</a> and having figured out <a href="http://www.englishteeth.co.uk/2008/08/29/grails-unit-testing-how-to-mock-a-closure/">how to mock a closure</a> I can assert that a filter has indeed been applied.</p>
<pre class="syntax-highlight:java">
 def criteria = Customer.createCriteria()
 items = criteria.list(params) {
   or {
     ilike (&#039;surname&#039;, &quot;%${params.filter}%&quot;)
     ilike (&#039;forename&#039;, &quot;%${params.filter}%&quot;)
     ilike (&#039;emailAddress&#039;, &quot;%${params.filter}%&quot;)
   }
 }
---
def customerCriteria = new MockFor(org.hibernate.Criteria)
customerCriteria.demand.list { Map params, Closure cls -&gt; testItems }
Customer.metaClass.static.createCriteria = { org.hibernate.Criteria }
</pre>
<p>But how can I assert that the filter closure contains/does what I want?<br />
Having mocked the closure call, I now want to define what it is supposed to do in my unit test. </p>
<p>I just can&#8217;t figure out how and I have started delving much deeper into how closures work than I originally wanted to. Unfortunately, I don&#8217;t seem to get any further than the <a href="http://groovy.codehaus.org/api/groovy/lang/ExpandoMetaClass.html">MetaClass</a>, where everything is still a little abstract. There must be some representation of the code to be run/resolved in there somewhere!?</p>
<p>I&#8217;ve poured over the <a href="http://groovy.codehaus.org/api/index.html?groovy/lang/package-tree.html">hierarchy for package groovy.lang</a> and pages on <a href="http://groovy.codehaus.org/Closures">Closures</a> and the <a href="http://groovy.codehaus.org/ExpandoMetaClass+-+GroovyObject+Methods">ExpandoMetaClass - GroovyObject Methods</a>.</p>
<p>Kick started by <a href="http://hartsock.blogspot.com/2007/12/fun-with-groovy-and-reflection-api.html">Fun with Groovy and the Reflection API</a> and definitely helped by <a href="http://naleid.com/blog/2008/05/07/what-methods-does-my-groovygrails-class-have/">What methods does my Groovy/Grails class have?</a> I distilled my problem to a script and proceeded to dump anything and everything I could think of or come across&#8230;</p>
<pre class="syntax-highlight:java">
class MyClassUnderTest {

  def foo() { return &quot;foo&quot; }
  def bar() { return &quot;bar&quot; }
  def ray() { return &quot;ray&quot; }

  def someMethod(Closure val) {

      println(&quot;Closure:&quot;)
      println(val.dump())
      println(&quot;-----------------------------------------------------------------&quot;)
      println(&quot;My Closure: &quot;)
      println(val.getMyClosure().dump())
      println(&quot;-----------------------------------------------------------------&quot;)
      println(&quot;Meta Class: &quot;)
      println(val.getMyClosure().metaClass.dump())
      println(&quot;-----------------------------------------------------------------&quot;)
      println(&quot;My Meta Class: &quot;)
      println(val.getMyClosure().metaClass.myMetaClass.dump())
      println(&quot;-----------------------------------------------------------------&quot;)
      println(&quot;My Meta Class Methods Index: &quot;)
      println(val.getMyClosure().metaClass.myMetaClass.metaMethodIndex.table*.name.sort().unique() )
      println(&quot;-----------------------------------------------------------------&quot;)
      println(val.getMyClosure().metaClass.inheritedMetaMethods*.name.sort().unique())
      println(val.getMyClosure().metaClass.methods*.name.sort().unique())
      println(&quot;-----------------------------------------------------------------&quot;)
      println(val.getMyClosure().metaClass.theClass.dump())
      println(&quot;-----------------------------------------------------------------&quot;)
      println(&quot;Constructors:&quot;)
      val.getMyClosure().metaClass.theClass.declaredConstructors.each { println it.toGenericString() }
      println(&quot;-----------------------------------------------------------------&quot;)
      println(&quot;Methods:&quot;)
      val.getMyClosure().metaClass.theClass.declaredMethods.each { println it.toGenericString() }
      println(&quot;-----------------------------------------------------------------&quot;)

      return &#039;result!&#039;
  }

}

def cut = new MyClassUnderTest()
def myClosure = {
    foo (&#039;valueOne&#039;)
    bar (&#039;valueTwo&#039;)
    ray (&#039;valueThree&#039;)
    &#039;valueFour&#039;
}
cut.someMethod { myClosure }
</pre>
<p>I thought I might have struck lucky when came across a post by <a href="http://shemnon.com/speling/">Danno Ferrin</a> who had learned <a href="http://shemnon.com/speling/2008/06/more-than-i-wanted-to-know-abo-1.html">more than he wanted to know about groovy.lang.Closure</a>. This cleared up a great deal about scope and lead me to a post by <a href="http://glaforge.free.fr/">Guillaume Laforge</a> on <a href="http://glaforge.free.fr/weblog/index.php?itemid=247">knowing which variables are bound or not in a Groovy script</a>.</p>
<p>Unfortunately the actual contents of the closure still allude me, but I&#8217;ve got work to do and this has had far more of my time than I can justify!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/09/04/groovy-on-grails-impasse/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails Unit Testing: How to mock a closure</title>
		<link>http://www.englishteeth.co.uk/2008/08/29/grails-unit-testing-how-to-mock-a-closure/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/29/grails-unit-testing-how-to-mock-a-closure/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 12:07:49 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=78</guid>
		<description><![CDATA[I have found numerous resources on testing in grails, unit testing and Using MockFor and StubFor in groovy. However, given that closures are one of the key features of groovy, I found very little on how to accommodate them in testing.
The following is a simple controller with a list action that returns a set of [...]]]></description>
			<content:encoded><![CDATA[<p>I have found numerous resources on <a href="http://www.grails.org/doc/1.0.x/guide/9.%20Testing.html">testing in grails</a>, <a href="http://blogs.bytecode.com.au/glen/2008/03/12/mockfor-march---unit-testing-grails-controllers.html">unit testing</a> and <a href="http://docs.codehaus.org/display/GROOVY/Using+MockFor+and+StubFor">Using MockFor and StubFor</a> in groovy. However, given that closures are one of the key features of groovy, I found very little on how to accommodate them in testing.</p>
<p>The following is a simple controller with a list action that returns a set of Customer domain objects from a database and this action applies some simple filter criteria (thanks to <a href="http://www.nabble.com/list.gsp-with-filter-and-pagination-td18995105.html">this post</a> I came across):</p>
<pre class="syntax-highlight:java">
   def list = {
        def items

        if(!params.max) params.max = 10
        if(!params.sort) params.sort = &quot;lastUpdated&quot;
        if(!params.order) params.order= &quot;desc&quot;
        if (params?.filter) {
            def criteria = Customer.createCriteria()
            items = criteria.list(params) {
                or {
                        ilike (&#039;surname&#039;, &quot;%${params.filter}%&quot;)
                        ilike (&#039;forename&#039;, &quot;%${params.filter}%&quot;)
                        ilike (&#039;emailAddress&#039;, &quot;%${params.filter}%&quot;)
                }
            }
        }
        else {
            items = Customer.list (params)
        }

        render (view: &#039;list&#039;, model: [ customerList: items, filter:params.filter ], params: params)
    }
</pre>
<p>This action uses the <a href="http://grails.org/Builders">Hibernate Criteria Builder</a> to construct the query.</p>
<p>When unit testing Grails does not inject any of the dynamic methods and so these must be provided for. For this I covered the dynamic controller methods in the set up and tear down operations (thanks wholly to Glen Smith&#8217;s <a href="http://blogs.bytecode.com.au/glen/2008/03/12/mockfor-march---unit-testing-grails-controllers.html">MockFor(March): Unit Testing Grails Controllers</a>&#8230;</p>
<pre class="syntax-highlight:java">
    def redirectParams
    def renderParams
    def params

    /** Setup metaclass fixtures for mocking. */
    void setUp() {

        params = [ : ]
        CustomerController.metaClass.getParams = { -&gt; params }

        redirectParams = [ : ]
        CustomerController.metaClass.redirect = { Map args -&gt; redirectParams = args  }

        renderParams= [ : ]
        CustomerController.metaClass.render = { Map args -&gt; renderParams = args  }

    } 

    /** Remove metaclass fixtures for mocking. */
    void tearDown() {
        def remove = GroovySystem.metaClassRegistry.&amp;removeMetaClass
        remove CustomerController
    }
</pre>
<p>The dynamic methods for the domain class I covered in the test where they were used.</p>
<pre class="syntax-highlight:java">
    void testNoFilterReturnsList() {

        def testItems = [ &#039;x&#039;, &#039;y&#039;, &#039;z&#039; ]

        params[&#039;filter&#039;] = null ;

        // mock the static list and count methods
        Customer.metaClass.static.list = { Map params -&gt; testItems } 

        CustomerController cc = new CustomerController()
        cc.list()

        assertNull renderParams.model.filter
        assertEquals testItems, renderParams.model.customerList

    }
</pre>
<p>This could hardly be simpler and is covered in much more detail elsewhere. Where I ran into difficulty was testing the the criteria was applied.</p>
<p>I wanted to provide a mock object for the org.hibernate.Criteria object returned for the domain.<br />
<code>def customerCriteria = new MockFor(org.hibernate.Criteria)</code><br />
Defining expectations on the mock object is straight forward too, just <em>demand it</em>!<br />
<code>customerCriteria.demand.list { -> testItems }</code><br />
Except that what ever I seemed to try would not match the signature of the call to <em>list</em> that I was trying to do in the filter test above.</p>
<p>Despite being a little elusive, the answer was simple enough. The closure defining the search criteria is a parameter to the call. There must be a list method declared with  a signature along the lines of<br />
<code>def list (Map params, Closure criteria)</code>(At least, that&#8217;s what I had to do in a test class to mimic that results I was seeing.)</p>
<p>So, to define a demand to match that&#8230; well, just treat it as such.</p>
<pre class="syntax-highlight:java">
    void testFilterAppliedToCriteria() {

        def testItems = [ &#039;x&#039;, &#039;y&#039;, &#039;z&#039; ]

        params[&#039;filter&#039;] = &#039;search on something&#039; ;

        def customerCriteria = new MockFor(org.hibernate.Criteria)
        customerCriteria.demand.list { Map params, Closure cls -&gt; testItems }
        Customer.metaClass.static.createCriteria = { org.hibernate.Criteria }
        customerCriteria.use{
        	CustomerController cc = new CustomerController()
        	cc.list()

        	assertEquals params.filter, renderParams.model.filter
        	assertEquals testItems, renderParams.model.customerList
        }
    }
</pre>
<p>I continue to stumble through, though I&#8217;m becoming more convinced that I don&#8217;t know what I am doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/29/grails-unit-testing-how-to-mock-a-closure/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails ClassCastException for Application</title>
		<link>http://www.englishteeth.co.uk/2008/08/21/grails-classcastexception-for-application/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/21/grails-classcastexception-for-application/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 10:29:22 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=76</guid>
		<description><![CDATA[Having persevered with mapping my existing database in grails, it actually made for much cleaner domain objects.
I never much liked when hibernate started creeping out of configuration and into the code via Java annotations, so on the same score, it was cathartic to remove the database aware gorm mappings from my domain classes.
Adding the hibernate [...]]]></description>
			<content:encoded><![CDATA[<p>Having persevered with mapping my <a href="http://www.englishteeth.co.uk/2008/08/20/grails-on-an-existing-database-revisited/">existing database</a> in <a href="http://grails.org/">grails</a>, it actually made for much cleaner domain objects.</p>
<p>I never much liked when <a href="http://www.hibernate.org/">hibernate</a> started creeping out of configuration and into the code via Java annotations, so on the same score, it was cathartic to remove the database aware <a href="http://grails.org/GORM">gorm</a> mappings from my domain classes.</p>
<p>Adding the hibernate configuration was straight forward and clean and tucked away in the <em>conf/hibernate</em> directory; an <em>hibernate.cfg.xml</em> file listing the mapping resources and an <em>hbm.xml</em> resource file for each entity.</p>
<p>All was going swimmingly until I was adding my last domain class; modelling an <em>Application</em>.</p>
<p>As soon as I wanted to &#8220;show&#8221; a particular <em>Application</em> I was getting a ClassCastException.</p>
<p>It would appear that I&#8217;m not the first to hit this, so luckily I didn&#8217;t have waste too much time trying to figure out why:</p>
<p><a href="http://jira.codehaus.org/browse/GRAILS-2348">application/create throws java.lang.ClassCastException: Application cannot be cast to javax.servlet.ServletContext</a></p>
<p>Apparently&#8230;<br />
<blockquote>there is a variable in the GSP binding called &#8216;application&#8217; that is the ServletContext this gets overridden when you return the model from the controller</p></blockquote>
<p>The bug is on create, but I guess as I am coming from the legacy database angle, I didn&#8217;t have to &#8220;create&#8221; before I tried to &#8220;show&#8221;.</p>
<p>Mmm.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/21/grails-classcastexception-for-application/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails on an existing database revisited</title>
		<link>http://www.englishteeth.co.uk/2008/08/20/grails-on-an-existing-database-revisited/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/20/grails-on-an-existing-database-revisited/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 11:24:08 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=75</guid>
		<description><![CDATA[Some time ago I looked at what was necessary to have Grails work on an existing database rather than the green field scenario painted in most examples.
It seemed straight forward enough, but beyond curiosity, I didn&#8217;t have anything I was particularly trying to achieve, so I moved along.
Yesterday, once again messing around with grails, I [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I looked at what was necessary to have <a href="http://www.englishteeth.co.uk/2008/05/19/grails-on-an-existing-database/">Grails work on an existing database</a> rather than the green field scenario painted in most examples.</p>
<p>It seemed straight forward enough, but beyond curiosity, I didn&#8217;t have anything I was particularly trying to achieve, so I moved along.</p>
<p>Yesterday, once again messing around with <a href="http://grails.org/">grails</a>, I found something I couldn&#8217;t seem to achieve via <a href="http://grails.org/doc/1.0.x/guide/single.html#5.%20Object%20Relational%20Mapping%20(GORM)">gorm</a>.</p>
<p>Basically, I couldn&#8217;t define the column mapping for an embedded class (where instead of mapping classes onto separate tables a class can be &#8220;embedded&#8221; within the current table).</p>
<p>I had hoped it would be a straight forward as defining the column mappings in the embedded class definition, but unfortunately not. Any mappings appear to be ignored.</p>
<p>I tried in the embedding class. No. I even experimented with the embedded property, but that was a long shot I didn&#8217;t expect to work anyway.</p>
<p>It would seem I will have to define the mapping in the old fashioned hibernate configuration file way.</p>
<p>One useful thing I did find in this frustrating experiment is that the configuration setting &#8230;<br />
<code>dataSource {<br />
     logSql = "true"<br />
}<br />
</code><br />
&#8230; provides a more readable format than &#8230;<br />
<code>hibernate {<br />
     show_sql = "true"<br />
}<br />
</code></p>
<p>Not a total loss then!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/20/grails-on-an-existing-database-revisited/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scrollable tables, CSS and fetaures of IE6</title>
		<link>http://www.englishteeth.co.uk/2008/08/18/css-scrollable-tables/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/18/css-scrollable-tables/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 10:05:27 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

		<category><![CDATA[java script]]></category>

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=73</guid>
		<description><![CDATA[I couldn&#8217;t leave this alone. A colleague was wrestling with some css to have a number scrollable tables within a larger scrolling area hold their column headers in place.
There were the plenty resources out there that nearly provided the solution, but each step had a draw back.
Did I mention that the target was IE6?
This post [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t leave this alone. A colleague was wrestling with some css to have a number scrollable tables within a larger scrolling area hold their column headers in place.</p>
<p>There were the plenty resources out there that nearly provided the solution, but each step had a draw back.</p>
<p>Did I mention that the target was IE6?</p>
<p>This <a href="http://rcswebsolutions.wordpress.com/2007/01/02/scrolling-html-table-with-fixed-header/">post</a> got us most of the way there.</p>
<p>Unfortunately, scrolling a table caused the header to bounce around horribly. Which through a bit of trial and error turned out to be caused by setting the background colour of the scrolling div containing the table. <em>(Obvious! How didn&#8217;t I see that one straight off?)</em></p>
<p>Next there was the scroll bars.<br />
<code><br />
    	overflow: scroll;<br />
</code><br />
Causes both scrollbars to be always visible. Disabled if they don&#8217;t do anything,but always there.<br />
<code><br />
    	overflow: auto;<br />
</code><br />
Causes just the necessary scrollbar to show. </p>
<p>This was preferable for tables which were only ever going to have vertical scrolling. Unfortunately, when the table only had a couple of rows, there was a scrollbar sized gap on the right.</p>
<p>The fix for that&#8230;<br />
<code><br />
 div.scrollTableContainer table {<br />
	width: expression(offsetParent.clientWidth+"px");<br />
}<br />
</code><br />
A bit of javascript, dug up from <a href="http://www.javascriptkit.com/domref/elementproperties.shtml">here</a>, to set the width to the visible width.</p>
<p>But these shorter tables also left blank space below them and as found before, we could not set the colour of this space without the horrible jumpy headers!</p>
<p>Searching around, if became apparent very quickly that css flickering in IE6 was a common problem with possible solutions. </p>
<ul>
<li><a href="http://evil.che.lu/2006/9/25/no-more-ie6-background-flicker">No more IE6 background flicker</a></li>
<li><a href="http://www.mister-pixel.com/index.php?Content__state=is_that_simple">Fixing the abominable</a></li>
</ul>
<p>But not quite&#8230; everything I found addressed the issues of images flickering, but although the <a href="http://fivesevensix.com/studies/ie6flicker/">causes of the flicker</a> were the same, the jumping header as a side effect was not.</p>
<p>So, in order to have the desired colour while maintaining&#8230;<br />
<code><br />
    background-color: transparent;<br />
    background-repeat: repeat;<br />
</code><br />
&#8230;was to add a small background gif of the desired colour. </p>
<p>No. Jumping headers are back! Seems that there is another IE6 bug whereby the the <a href="http://www.evotech.net/blog/2008/08/css-background-properties/#bg1">default background attachment is not implemented correctly</a>.<br />
<code><br />
    background-image: url(colour.gif);<br />
    background-attachment: fixed;<br />
</code><br />
Should handle that.</p>
<p>So in summary, we needed a bit of <a href="http://rcswebsolutions.wordpress.com/2007/01/02/scrolling-html-table-with-fixed-header/">Scrolling HTML Table with Fixed Header</a>, followed by a touch of <a href="http://evil.che.lu/2006/9/25/no-more-ie6-background-flicker">No more IE6 background flicker</a> and topped off with <a href="http://www.evotech.net/blog/2008/08/css-background-properties/">Everything you could possibly want to know about CSS Background Properties, including default values, browser support, targeting the DOM, and what to look for in CSS3</a>.</p>
<p>Not much then.</p>
<p>Next time, I&#8217;ll mind my own business.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/18/css-scrollable-tables/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Selenium RC in the build</title>
		<link>http://www.englishteeth.co.uk/2008/08/11/selenium-rc-in-the-build/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/11/selenium-rc-in-the-build/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 15:19:09 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[development]]></category>

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=69</guid>
		<description><![CDATA[I had to rediscover a bit of lost knowledge last Friday, namely integrating Selenium RC into a set of integration tests. Pretty straight forward really, but I thought I&#8217;d better record it for the next time I can&#8217;t remember how to start and stop the server from ant.

&#60;project name=&#34;Selenium RC Server&#34;&#62;

	&#60;target name=&#34;start_selenium_rc&#34; description=&#34;Start the Selenium [...]]]></description>
			<content:encoded><![CDATA[<p>I had to rediscover a bit of lost knowledge last Friday, namely integrating <a href="http://selenium-rc.openqa.org/">Selenium RC</a> into a set of integration tests. Pretty straight forward really, but I thought I&#8217;d better record it for the next time I can&#8217;t remember how to start and stop the server from <a href="http://ant.apache.org/">ant</a>.</p>
<pre class="syntax-highlight:xml">
&lt;project name=&quot;Selenium RC Server&quot;&gt;

	&lt;target name=&quot;start_selenium_rc&quot; description=&quot;Start the Selenium RC server&quot;&gt;
		&lt;java
			jar=&quot;selenium-server.jar&quot;
			fork=&quot;true&quot; failonerror=&quot;true&quot;&gt;
			&lt;arg value=&quot;-Port&quot; /&gt;
			&lt;arg value=&quot;4440&quot; /&gt;
			&lt;arg value=&quot;-forcedBrowserMode&quot; /&gt;
			&lt;arg value=&quot;*iehta&quot; /&gt;
		&lt;/java&gt;
	&lt;/target&gt;

	&lt;target name=&quot;stop_selenium_rc&quot; description=&quot;Stop the Selenium RC server&quot;&gt;
		&lt;get taskname=&quot;selenium-shutdown&quot;
			src=&quot;http://localhost:4440/selenium-server/driver/?cmd=shutDown&quot;
			dest=&quot;junit_report/result.txt&quot; ignoreerrors=&quot;true&quot; /&gt;
	&lt;/target&gt;

&lt;/project&gt;
</pre>
<p>The forced browser mode is IE for project constraints, but I did have an issue with *iexplore not working due to some proxy error but the <a href="http://selenium-rc.openqa.org/experimental.html">experimental &#8220;elevated security privilege&#8221; browser</a> worked fine. </p>
<p>Not so fine is that the <a href="http://jira.openqa.org/browse/SRC-300">goBack() command does not work in SeleniumRC with &#8220;*iehta&#8221;</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/11/selenium-rc-in-the-build/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Freesat part 2</title>
		<link>http://www.englishteeth.co.uk/2008/08/10/freesat-part-2/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/10/freesat-part-2/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 15:29:14 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[miscellaneous]]></category>

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=70</guid>
		<description><![CDATA[Being the impatient sort, I ordered my BlackGold BGT3540 6in1 DVB-S tuner, even though I haven&#8217;t yet installed my satellite system. (Though I have convinced myself that it will work!)
However, I didn&#8217;t expect it to turn up the next day. This was quite frustrating since the lack of suitable weather and someone to hold the [...]]]></description>
			<content:encoded><![CDATA[<p>Being the impatient sort, I ordered my <a href="http://shop.blackgold.tv/product/3540.html">BlackGold BGT3540</a> 6in1 DVB-S tuner, even though I haven&#8217;t yet installed my satellite system. <a href="http://www.englishteeth.co.uk/2008/07/31/freesat/">(Though I have convinced myself that it will work!)</a></p>
<p>However, I didn&#8217;t expect it to turn up the next day. This was quite frustrating since the lack of suitable weather and someone to hold the ladder for me meant there was no way it was going to happen this weekend.</p>
<p>Spurred on though, I spent a couple of hours crawling around the loft routing the cable in readiness. The wind and rain were lashing the other side of the slates, so I was thankful to at least have an indoor task to complete. </p>
<p>My cunning plan to achieve the <a href="http://en.wikipedia.org/wiki/Woman_acceptance_factor">WAF</a> and keep the cables safe and out of site, I routed them down the cavity surrounding the soil stack running the full height of the house; from vent in the roof to the drains beneath. A little fiddly, but I think worth the effort. My living room set up is in the corner of the room backing on to this space and the stack itself is boxed in the kitchen. Thus allowing my shotgun cable to be ready for the BlackGold in my (recently updated) media center and a third cable for a tuner in the kitchen.</p>
<p>Now as soon as it stops raining, I&#8217;ll get up that ladder!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/10/freesat-part-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Vista Media Center</title>
		<link>http://www.englishteeth.co.uk/2008/08/08/vista-media-center/</link>
		<comments>http://www.englishteeth.co.uk/2008/08/08/vista-media-center/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 22:47:40 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[miscellaneous]]></category>

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

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.englishteeth.co.uk/?p=71</guid>
		<description><![CDATA[I&#8217;ve read numerous posts and articles on Vista and the majority of this seem to summarise that there is no compelling reason to upgrade from XP.
Since I first tried it out, I have been a fan XP Media Center Edition 2005. Despite it&#8217;s quirks, it delivers a simple and usable  media interface to the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve read numerous posts and articles on Vista and the majority of this seem to summarise that there is no compelling reason to upgrade from XP.</p>
<p>Since I first tried it out, I have been a fan <a href="http://www.winsupersite.com/reviews/windowsxp_mce2005.asp">XP Media Center Edition 2005</a>. Despite it&#8217;s quirks, it delivers a simple and usable  media interface to the living room. I don&#8217;t think I would care to go back to normal <em>just TV</em> and having looked at offerings such as <a href="http://en.wikipedia.org/wiki/Sky%2B">Sky+</a> and <a href="http://en.wikipedia.org/wiki/Virgin_Media_Television">Virgin Media Television</a>, I still feel there are things I would rather not compromise. <a href="http://www.microsoft.com/windows/products/winfamily/mediacenter/default.mspx">Vista Media Center</a> too, seemed to offer little incentive and too many headache tales of incompatibility and woe.</p>
<p>Yet upgrade I have!</p>
<p>It went really smoothly too. I didn&#8217;t even have to take the disks distributed with the motherboard or graphics card out of their sleeves. I installed the TV tuner card drivers and the few bits of software I have on my media center and the job seems done.</p>
<p>I almost think I&#8217;ve missed something!</p>
<p><a href="http://www.flickr.com/photos/epengfei/256680809/"><img src="http://farm1.static.flickr.com/93/256680809_274df45fa4.jpg?v=0" alt="Vista Media Center" /></a></p>
<p>First impressions. I&#8217;m not sure I like it! </p>
<p>Vista itself seems OK, different enough to be disconcerting but nothing major.<br />
(I&#8217;m surprised how long it has taken me to even see this OS)</p>
<p>The differences in VMC though, I&#8217;m not too sure&#8230;</p>
<ul>
<li>there is too much on the first screen</li>
<li>too many menu options, for things I wouldn&#8217;t want to use, hanging around</li>
<li>navigation is horizontal and vertical</li>
<li>pictures are bundled in with video</li>
<li>everything seems constrained to the strip across the middle of the screen</li>
<li>I don&#8217;t know if my wife is going to like it!</li>
</ul>
<p>But it&#8217;s late and it it&#8217;s done. I&#8217;ll live with it over the weekend and see where we are then.</p>
<p><em>The screen shot is not my own, its from <a href="http://www.flickr.com/photos/epengfei/256680809/">flickr</a>, because I&#8217;m tired and I really can&#8217;t be bothered to duplicate the effort.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.englishteeth.co.uk/2008/08/08/vista-media-center/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
