<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<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/"
	>

<channel>
	<title>Reiner Saddey's Place</title>
	<link>http://blog.saddey.net</link>
	<description>Just another WordPress weblog for Reiner Saddey</description>
	<pubDate>Sun, 18 Dec 2011 13:00:05 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>Grails and Microsoft SQL Server - Not so painless when using Unique Constraints - A Pragmatic Work-Around</title>
		<link>http://blog.saddey.net/2011/12/18/grails-and-microsoft-sql-server-not-so-painless-when-using-unique-constraints-a-pragmatic-work-around/</link>
		<comments>http://blog.saddey.net/2011/12/18/grails-and-microsoft-sql-server-not-so-painless-when-using-unique-constraints-a-pragmatic-work-around/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 10:19:35 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Hibernate]]></category>

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

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

		<guid isPermaLink="false">http://blog.saddey.net/2011/12/18/grails-and-microsoft-sql-server-not-so-painless-when-using-unique-constraints-a-pragmatic-work-around/</guid>
		<description><![CDATA[When porting your Grails application from just about any database to MS SQL Server, four areas come to my mind that require your immediate attention:

Primary key generation strategy (not covered here)
Case sensitivity and collation issues (not covered here)
Storage and retrieval of Unicode data (not covered here)
Handling of unique constraints on columns that allow nulls

With MS [...]]]></description>
			<content:encoded><![CDATA[<p>When porting your Grails application from just about any database to MS SQL Server, four areas come to my mind that require your immediate attention:</p>
<ul>
<li>Primary key generation strategy (not covered here)</li>
<li>Case sensitivity and collation issues (not covered here)</li>
<li>Storage and retrieval of Unicode data (not covered here)</li>
<li><strong>Handling of unique constraints on columns that allow nulls</strong></li>
</ul>
<p>With MS SQL Server you&#8217;ll notice your unique constraints defined within Grails domain classes may no longer work as expected if null values are allowed (either explicitly or when using table per hierarchy inheritance).</p>
<p>Today I&#8217;ll present a work-around for MS SQL Server 2008 that does not require any manual intervention.</p>
<p>When using unique clauses within the constraints sections of your domain classes, Grails will do <em>both</em>:</p>
<ul>
<li>Perform lookups on every insert or update in order to be able to create meaningful messages within the errors collection, and</li>
<li>by virtue of Hibernate hbm2ddl, create unique constraints within your database to enforce uniqueness even when validation is bypassed.</li>
</ul>
<h2>What&#8217;s so special about MS SQL Server?</h2>
<p>Microsoft SQL Server has always been special when it comes to null values. There are several options (suspiciously named ANSI_xxx) controlling the handling of null values, e.g. whether null = null yields true a.s.o., but all those <strong>fail to take <em>any</em> effect on unique constraints</strong>.</p>
<p>With Microsoft SQL Server <strong>unique constraints treat null values just as if they were ordinary values</strong> - a uniquely constrained column does <strong>at most allow for a single row to have the value null</strong>. This appears to be in violation of ANSI SQL standards and there are (as yet futile) <a href="https://connect.microsoft.com/SQLServer/feedback/details/299229/change-unique-constraint-to-allow-multiple-null-values#details" target="_blank" title="Microsoft Connect - Change UNIQUE constraint to allow multiple NULL values">requests to (optionally) alter MS SQL Server behavior</a>.</p>
<p>Depending on your business rules, not-null properties (e.g. nullable:false, blank:false, unique:true) may be appropriate. But watch out for <a href="http://grails.org/doc/1.3.7/guide/5.%20Object%20Relational%20Mapping%20(GORM).html#5.2.3%20Inheritance%20in%20GORM" target="_blank" title="Grails 1.3.7 Guide - 5.2.3 Inheritance in GORM">object inheritance when using table-per-hierarchy mapping</a> (Grails default). As a single table is used to store different kinds of objects, a property defined as <em>nullable:false</em> within a sub class must be mapped to a <em>nullable</em> table column as other sub classes do not share this property (i.e. they have no value for this particular column at all). And if such a property has been constrained by <em>unique:true</em>, your application is bound to fail with SQL Server, as it will at most allow a single row where the value of this property is null.</p>
<p>There are several <a href="http://stackoverflow.com/questions/191421/how-to-create-a-unique-index-on-a-null-column" target="_blank" title="stackoverflow - How to create a unique index on a NULL column?">work-arounds in the wild</a>, most of them exceedingly awkward to handle and maintain - with one notable exception: Starting with <strong>MS SQL Server 2008 indexes can be filtered</strong>, i.e. a (simple) where clause can be applied to the definition of an index. Thus a <strong>unique index that ignores null values can be used in place of a unique constraint</strong> to enforce uniqueness of non-null values.</p>
<h2>What you&#8217;ll need to run or use the Grails MsSqlConstraints project sample code</h2>
<ul>
<li>The Grails demo project <a href="https://docs.google.com/open?id=0B5F8upNsB6rGY2Y4NmRkZTMtNmNjZS00OTUwLTg0NjEtNDc0NGQwZjdmMTJi" title="MsSqlConstraints.zip" target="_blank"><strong>MsSqlConstraints</strong></a> (Select File, Download original to get hold of the .zip on your PC).</li>
<li><strong>MS SQL Server 2008</strong> (express edition will do, I used 2008 R2) allowing SQL Server authentication (i.e. user and password). The demo project accesses a database named demo at your local SQL Server using demo for both login and password. Best to have a look at DataSource.groovy first.</li>
<li><strong><a href="http://grails.org/" target="_blank" title="Grails">Grails</a> 1.3.7</strong></li>
<li><strong>Java 6</strong> - Java 6 Update 29 has a bug that prevents it to connect to MS SQL Server 2008 <strong>R2</strong>. Either upgrade to Java 6 Update 30 or replace jsse.jar with the one included in Update 30 (as I had to because Update 30 was not yet available from Apple).</li>
<li><a href="http://www.springsource.com/developer/sts" title="SpringSource Tool Suite" target="_blank">Springsource Tool Suite 2.8+</a> or <a href="http://www.jetbrains.com/idea/" title="IntelliJ IDEA" target="_blank">IntelliJ 10+</a> (not really required, but allow attached demo project to be run out-of-the-box).</li>
<li>Disclaimer: Note that the <strong>demo project is provided as is without any warranty or obligation</strong> and (to give you a head start) as well includes a copy of the <strong>Microsoft JDBC Type 4 Driver Version 3 which is to be used with this demo project only and whose use is restricted as explained in <a href="http://msdn.microsoft.com/en-us/data/aa937726?ppud=4" title="MICROSOFT SQL SERVER JDBC DRIVER REDISTRIBUTION LICENSE" target="_blank">MICROSOFT SQL SERVER JDBC DRIVER REDISTRIBUTION LICENSE</a></strong>.</li>
</ul>
<h2>How to change unique constraints to unique indexes?</h2>
<h3>Alter database DDL within BootStrap.groovy</h3>
<ul>
<li>Having looked into Hibernate 3.3.1 code (as used by Grails 1.3.7) it appears hard if not impossible to change the DDL generated by Hibernate&#8217;s hbm2ddl routines. Thus I resorted to altering table definitions within the BootStrap.groovy code. Please note that the code has been hacked away in a hurry and might fail with advanced usage patterns such as tables belonging to different owners a.s.o. For us it worked out-of-the-box, but use at your own risk.</li>
<li>The <strong>code</strong> within <a href="http://blog.saddey.net/wp-content/uploads/2011/12/bootstrap.groovy" title="BootStrap.groovy" target="_blank">BootStrap.groovy</a> is straight forward. It queries constraint data from MS SQL Server information schema and replaces unique constraints that encompass nullable columns with unique filtered indexes.</li>
</ul>
<h3>Supply Hibernate dialect for MS SQL Server 2008</h3>
<ul>
<li>When a unique <em>index</em> violation occurs, an Exception different from the one when violating a unique <em>constraint</em> will be thrown. MinimalSQLServer2008Dialect contains code to map unique index violations to DataIntegrityViolationExceptions just as if a constraint violation had occurred.</li>
<li>The demo project has been implemented using <a href="http://msdn.microsoft.com/en-us/sqlserver/aa937724" target="_blank" title="Microsoft JDBC Driver for SQL Server">Microsoft JDBC Type 4 Driver for SQL Server</a>. This driver returns JDBC type codes (e.g. NVARCHAR for certain information schema columns) Hibernate 3.3 fails to understand. Thus the MinimalSQLServer2008Dialect supplied with this demo project as well provides minimal type declarations in order to successfully query SQL Server information schemas. Another post within this blog will focus on both how to store Unicode strings and how to take advantage of MS SQL Server BIT and xxx(MAX) columns using an enhanced Hibernate dialect.</li>
<li>The <strong>code</strong> referenced from DataSource.groovy is contained within class demo.<a href="http://blog.saddey.net/wp-content/uploads/2011/12/minimalsqlserver2008dialect.java" title="MinimalSQLServer2008Dialect.java" target="_blank">MinimalSQLServer2008Dialect</a> which derives from org.hibernate.dialect.SQLServerDialect. It defines NCHAR and NVARCHAR data types and translates unique index violations to (Spring) ConstraintViolationExceptions.</li>
</ul>
<h2>How to run the code?</h2>
<ul>
<li>Get the Grails demo project <a href="https://docs.google.com/open?id=0B5F8upNsB6rGY2Y4NmRkZTMtNmNjZS00OTUwLTg0NjEtNDc0NGQwZjdmMTJi" title="MsSqlConstraints.zip" target="_blank"><strong>MsSqlConstraints</strong></a> (Select File, Download original to get hold of the .zip on your PC).</li>
<li>Running it using <strong>grails test-app integration:spock</strong> will perform <a href="http://code.google.com/p/spock/" target="_blank" title="spock - the enterprise ready specification framework">Spock</a> test <a href="http://blog.saddey.net/wp-content/uploads/2011/12/mssqlconstraintsspec.groovy" target="_blank" title="MsSqlConstraintsSpec.groovy">MsSqlConstraintsSpec.groovy</a> and produce output similar to <a href="http://blog.saddey.net/wp-content/uploads/2011/12/mssqlconstraints.txt" title="MsSqlConstraints.txt" target="_blank">this</a>.</li>
</ul>
<p>Have fun,<br />
Reiner</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2011/12/18/grails-and-microsoft-sql-server-not-so-painless-when-using-unique-constraints-a-pragmatic-work-around/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Episodes from the Life of a Mac Convert - How to install Apache?</title>
		<link>http://blog.saddey.net/2011/09/05/episodes-from-the-life-of-a-mac-convert-how-to-install-apache/</link>
		<comments>http://blog.saddey.net/2011/09/05/episodes-from-the-life-of-a-mac-convert-how-to-install-apache/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 17:23:53 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Mac OS X]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2011/09/05/episodes-from-the-life-of-a-mac-convert-how-to-install-apache/</guid>
		<description><![CDATA[Yes, I shout it out to all my fellow brothers - after having led a sinful life of Windows miseries, I now have become a true and humble Apple believer  
I wanted to install a web server on my Snow Leopard MacBook Pro in order to hand out some documents and thus ventured into [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I shout it out to all my fellow brothers - after having led a sinful life of Windows miseries, I now have become a true and humble Apple believer <img src='http://blog.saddey.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I wanted to install a web server on my Snow Leopard MacBook Pro in order to hand out some documents and thus ventured into googling for <em>mac install apache</em>. I was quite dissatisfied most articles appeared to be rather involved, requiring to either install by source or mandating other system wide packages to be fetched.</p>
<p>It was no sooner than half an hour I discovered that all that was required is just a <strong>single tick</strong> within a System Preferences Panel:</p>
<ol>
<li>Open <strong>Sharing</strong> from <strong>System Preferences</strong></li>
<li>Tick <strong>Web Sharing</strong></li>
</ol>
<p>Apache is included off-the-shelf and started immediately after Web Sharing has been enabled <img src='http://blog.saddey.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.youtube.com/user/macmostvideo" title="macmost's video channel on Youtube" target="_blank">MacMost</a> has a video that includes PHP as well:</p>
<p><iframe src="http://www.youtube.com/embed/OtRUV1bjznw" frameborder="0" height="231" width="411"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2011/09/05/episodes-from-the-life-of-a-mac-convert-how-to-install-apache/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mac OS X (Snow Leopard): 1-2-3 Minimal Tomcat Install for Developers</title>
		<link>http://blog.saddey.net/2011/08/02/mac-os-x-snow-leopard-1-2-3-minimal-tomcat-install-for-developers/</link>
		<comments>http://blog.saddey.net/2011/08/02/mac-os-x-snow-leopard-1-2-3-minimal-tomcat-install-for-developers/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 18:41:24 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Mac OS X]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2011/08/02/mac-os-x-snow-leopard-1-2-3-minimal-tomcat-install-for-developers/</guid>
		<description><![CDATA[This will install Tomcat for developer use - i.e. within your user home path, using your login, not as a service:

Get the tar.gz for Tomcat Core from Apache Tomcat
Change to your private Library: cd ~/Library
Unpack Tomcat, e.g. tar xvfz ~/Downloads/apache-tomcat-6.0.32.tar.gz
Create symbolic link to remain stable even when upgrading: ln -s apache-tomcat-6.0.32 Tomcat

Then:

Start Tomcat: ~/Library/Tomcat/bin/startup.sh
Stop Tomcat: ~/Library/Tomcat/bin/shutdown.sh

Configure at your leasure, [...]]]></description>
			<content:encoded><![CDATA[<p>This will install Tomcat for developer use - i.e. within your user home path, using your login, <em>not</em> as a service:</p>
<ol>
<li>Get the tar.gz for Tomcat Core from <a href="http://tomcat.apache.org/index.html" title="Apache Tomcat" target="_blank">Apache Tomcat</a></li>
<li>Change to your private Library: <code>cd ~/Library</code></li>
<li>Unpack Tomcat, e.g. <code>tar xvfz ~/Downloads/apache-tomcat-6.0.32.tar.gz</code></li>
<li>Create symbolic link to remain stable even when upgrading: <code>ln -s apache-tomcat-6.0.32 Tomcat</code></li>
</ol>
<p>Then:</p>
<ul>
<li>Start Tomcat: <code>~/Library/Tomcat/bin/startup.sh</code></li>
<li>Stop Tomcat: <code>~/Library/Tomcat/bin/shutdown.sh</code></li>
</ul>
<p>Configure at your leasure, e.g. look here for enabling Tomcat Manager Login: <a href="Look here for enabling Tomcat Manager Login: http://www.mkyong.com/tomcat/tomcat-default-administrator-password/" title="What is Tomcat default administrator password ?" target="_blank">http://www.mkyong.com/tomcat/tomcat-default-administrator-password/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2011/08/02/mac-os-x-snow-leopard-1-2-3-minimal-tomcat-install-for-developers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Deploy a Grails Application to GlassFish</title>
		<link>http://blog.saddey.net/2010/03/27/how-to-deploy-a-grails-application-to-glassfish/</link>
		<comments>http://blog.saddey.net/2010/03/27/how-to-deploy-a-grails-application-to-glassfish/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 17:02:54 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Grails]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/03/27/how-to-deploy-a-grails-application-to-glassfish/</guid>
		<description><![CDATA[Article describing and complete Grails sample application prepared for GlassFish deployment, including a diagram sketching Grails logging architecture tailored to use native GlassFish logging.]]></description>
			<content:encoded><![CDATA[<p>As outlined at <a href="http://blog.saddey.net/2010/03/06/how-to-deploy-a-grails-application-to-jboss-5/" title="Reiner's Place - How to Deploy a Grails Application to JBoss 5">How to Deploy a Grails Application to JBoss 5</a>, deploying to JBoss 5 just requires to remove some logging jars and disable Grails logging configuration. With GlassFish however, it is required to supply certain logging jars (e.g. within your war file) in order to use its native logging system.</p>
<p>I&#8217;ll give a full source example on how to achieve this, using Grails 1.2.1 and GlassFish v3. The code should as well run a-is with Grails 1.2.2 and GlassFish v2 (and even with Tomcat 6 using its default Java Util Logging configuration). <strong>Watch-out: GlassFish currently refuses to deploy Grails 1.2.2 applications - see Links below.</strong></p>
<p>I won&#8217;t cover using JNDI data sources here, as their implementation is straight forward and nicely covered by GlassFish&#8217;s administration console. You should always use JNDI and JDBC pools provided by GlassFish though, as they offer superior reliability and shield your application from deployment site details.</p>
<p>Note that with GlassFish v3, it may be feasible to deploy skinny wars, i.e. instead of including them within your war, let GlassFish supply the jars required for running a Grails application. This pattern reduces resource usage when running multiple Grails applications within a single GlassFish instance. I haven&#8217;t looked into this, as for me the potential gain did not justify the effort when building and keeping track of possibly conflicting Grails versions.</p>
<p>GlassFish uses Java Util Logging as its native logging implementation. Thus your Grails war should delegate its logging to Jul as well in order take advantage of GlassFish built-in web administration and alert features. Components shown in green have to be added to your war and the ones in red are to be removed:</p>
<p><img src="http://yuml.me/diagram/scruffy;scale:82/class/%5BREMOVE;jul-to-slf4j%7Bbg:crimson%7D%5Duses%20-.-%3E%5Bslf4j-api%5D,%20%5BADD;log4j-over-slf4j%7Bbg:forestgreen%7D%5Duses%20-.-%3E%5Bslf4j-api%5D,%20%5BYour%20Code;log.warn%5Duses%20-.-%3E%5Bjcl-over-slf4j%5D,%20%5Bjcl-over-slf4j%5Duses%20-.-%3E%5Bslf4j-api%5D,%20%5Bslf4j-api%5Duses%20-.-%3E%5BADD;slf4j-jdk14%7Bbg:forestgreen%7D%5D,%20%5Bslf4j-api%5Duses%20-.-%3E%5BREMOVE;slf4j-log4j12%7Bbg:crimson%7D%5D,%20%5BADD;slf4j-jdk14%7Bbg:forestgreen%7D%5Duses%20-.-%3E%5Bjul%5D,%20%5BREMOVE;slf4j-log4j12%7Bbg:crimson%7D%5Duses%20-.-%3E%5BREMOVE;log4j%7Bbg:crimson%7D%5D,%20%5BGlassFish%5Dconfigures%20-.-%3E%5Bjul%5D" style="background: #c0c0c0 none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" title="Grails logging stack for GlassFish" alt="Grails logging stack for GlassFish" width="407" /></p>
<p>How to achieve this? Just supplying an additional Grails configuration file and changing a single configuration attribute will do the trick.</p>
<p>First within <em>scripts/_Events.groovy</em> we&#8217;ll <strong>remove offending jars</strong>,  <strong>add  required jars</strong>  and <strong>disable Grails logging configuration</strong> components:</p>
<pre>import groovy.xml.StreamingMarkupBuilder

/**
 *** TODO GLASSFISH - Remove log4j configuration stuff (when running with JBoss or GlassFish a.s.o) ***
 */
eventWebXmlEnd = {String tmpfile -&gt;

    def root = new XmlSlurper().parse(webXmlFile)

    // When running with JBoss (or GlassFish a.s.o) remove log4j configuration stuff
    def log4j = root.listener.findAll {node -&gt;
        node.'listener-class'.text() == 'org.codehaus.groovy.grails.web.util.Log4jConfigListener'
    }
    log4j.replaceNode {}

    def log4jFile = root.'context-param'.findAll {node -&gt;
        node.'param-name'.text() == 'log4jConfigLocation'
    }
    log4jFile.replaceNode {}

    webXmlFile.text = new StreamingMarkupBuilder().bind {
        mkp.declareNamespace("": "http://java.sun.com/xml/ns/j2ee")
        mkp.yield(root)
    }
}

/**
 *** TODO GLASSFISH Remove log4j and use jul as used by GlassFish instead ***
 */
eventCreateWarStart = { warName, stagingDir -&gt;

    if (grailsEnv == "production") {

        String log4jVer = "1.2.15"
        String slf4jVer = "1.5.8"

        [
          "lib/log4j-${log4jVer}.jar", // log4j not used with GlassFish
          "classes/log4j.properties", // logging conf done in GlassFish Admin only
          "lib/slf4j-log4j12-${slf4jVer}.jar", // log4j not used with Glassfish
          "lib/jul-to-slf4j-${slf4jVer}.jar", // not required, native JUL with by GlassFish
            // you might want to remove JDBC drivers when using server supplied JNDI...
            //          "lib/hsqldb-1.8.0.10.jar",
        ].each {
            println "*** GLASSFISH *** _Events.groovy removing ${it}"
            Ant.delete(file: "${stagingDir}/WEB-INF/$it")
        }

        // Grails+Ivy (as yet) do not provide war-only dependencies - thus we fetch them manually
        Ant.mkdir(dir: "${basedir}/glassfishlibs") // to this dir (in case your internet breaks down)

        [
          "slf4j-jdk14", // from http://repo1.maven.org/maven2/org/slf4j/slf4j-jdk14/1.5.8/slf4j-jdk14-1.5.8.jar
          "log4j-over-slf4j", // from http://repo1.maven.org/maven2/org/slf4j/log4j-over-slf4j/1.5.8/log4j-over-slf4j-1.5.8.jar
        ].each { artifactId -&gt;
            String fileName = "${artifactId}-${slf4jVer}.jar"

            if (!(new File("${basedir}/glassfishlibs/${fileName}")).file ) {
                println "*** GLASSFISH *** _Events.groovy getting ${fileName}"
                Ant.get(dest: "${basedir}/glassfishlibs/${fileName}",
                        src: "http://repo1.maven.org/maven2/org/slf4j/${artifactId}/${slf4jVer}/${fileName}")
            }

            println "*** GLASSFISH *** _Events.groovy copying ${fileName}"
            Ant.copy(file: "${basedir}/glassfishlibs/${fileName}",
                     tofile: "${stagingDir}/WEB-INF/lib/${fileName}")
        }

    }
}</pre>
<p>Unfortunately, I found no way to cause Grails+Ivy dependency resolution to include artifacts solely when building a war (the other way around appears to be feasible though). Thus the script outlined above uses Ant to fetch the required Jars from Maven&#8217;s Central repository and saves them to a folder within your project (<em>glassfishlibs</em>) in order to have subsequent project builds succeed, even if there&#8217;s no connectivity to the Internet.</p>
<p>Watch out: The jar versions as stated within the script might need to be adopted for Grails versions other than 1.2.1 or 1.2.2.</p>
<p>Next, within <em>grails-app/conf/Config.groovy</em> we&#8217;ll <strong>instruct Grails not to enable the Jul-to-Slf4j bridge</strong>, as this bridge would either alter GlassFishs loggings setup and cause  infinite looping or class-not-found errors (as we removed the bridge jar from our war):</p>
<pre>// *** TODO GLASSFISH doesn't use jul bridge, as GlassFish uses native jul ***
grails.logging.jul.usebridge = false // instead of true</pre>
<p>You are now set to control logging using GlassFish&#8217;s excellent Web GUI.</p>
<p>Links:</p>
<ul>
<li>18-aug-10: See <a href="http://blog.saddey.net/2010/03/27/how-to-deploy-a-grails-application-to-glassfish/#WillKrespan" title="Will Krespan - Grails + Glassfish + Maven Build">this comment</a> for a straight-forward <strong>approach when using Maven</strong> to build your Grails app.</li>
<li><a href="https://docs.google.com/leaf?id=0B5F8upNsB6rGZjA1NzcyYmYtMDNhMC00OTY4LThkNjYtMzk1N2IwOTg1Mjlk&amp;hl=en" title="Source Code and war for this post" target="_blank">Source Code and war</a></li>
<li>Grails User: <a href="http://n4.nabble.com/Switch-from-Config-groovy-to-BuildConfig-groovy-tp1375610p1375611.html" title="Grails User - Re: Switch from Config.groovy to BuildConfig.groovy" target="_blank">Peter Ledbrook explains how to use the <em>eventCreateWarStart</em> event within <em>_Events.groovy</em></a></li>
<li><a href="http://wiki.glassfish.java.net/Wiki.jsp?page=GroovyGrails" title="Glassfish Wiki - Groovy &amp; Grails in GlassFish" target="_blank">Glassfish Wiki - Groovy &amp; Grails in GlassFish</a></li>
<li><a href="http://n4.nabble.com/grails-1-2-2-and-glassfish-tp1691815p1694119.html" title="Grails User - grails 1.2.2 and glassfish" target="_blank">Grails User - grails 1.2.2 and glassfish</a> (won&#8217;t deploy - work-around avail)</li>
<li><a href="http://yuml.me/diagram/scruffy;/class/edit/[REMOVE;jul-to-slf4j%7Bbg:crimson%7D]uses%20-.-%3E[slf4j-api],%20[ADD;log4j-over-slf4j%7Bbg:forestgreen%7D]uses%20-.-%3E[slf4j-api],%20[Your%20Code;log.warn]uses%20-.-%3E[jcl-over-slf4j],%20[jcl-over-slf4j]uses%20-.-%3E[slf4j-api],%20[slf4j-api]uses%20-.-%3E[ADD;slf4j-jdk14%7Bbg:forestgreen%7D],%20[slf4j-api]uses%20-.-%3E[REMOVE;slf4j-log4j12%7Bbg:crimson%7D],%20[ADD;slf4j-jdk14%7Bbg:forestgreen%7D]uses%20-.-%3E[jul],%20[REMOVE;slf4j-log4j12%7Bbg:crimson%7D]uses%20-.-%3E[REMOVE;log4j%7Bbg:crimson%7D],%20[GlassFish]configures%20-.-%3E[jul]" title="Edit diagram above" target="_blank">This diagram</a> has been prepared using <a href="http://yuml.me/" title="yUML - Create UML diagrams online in seconds, no special tools needed." target="_blank">yUML</a> (avoid IE, if you can, as it might have difficulties handling the long URL contained within the first link)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/03/27/how-to-deploy-a-grails-application-to-glassfish/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bananen Republik Deutschland - heute: Wie Banken Sie vor Kontonummern schützen</title>
		<link>http://blog.saddey.net/2010/03/20/bananen-republik-deutschland-heute-wie-banken-sie-vor-kontonummern-schutzen/</link>
		<comments>http://blog.saddey.net/2010/03/20/bananen-republik-deutschland-heute-wie-banken-sie-vor-kontonummern-schutzen/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 14:36:25 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Deutsch]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/03/20/bananen-republik-deutschland-heute-wie-banken-sie-vor-kontonummern-schutzen/</guid>
		<description><![CDATA[Bei einer - aus rechtlichen Gründen - hier nicht namentlich genannten - Bank reicht das Gedächtnis für Kontoauszüge nur 3 Monate zurück. Und selbst für in diesem Zeitraum ausgeführte Dauerüberweisungen sind keinerlei Kontodaten des Begünstigten mehr verfügbar, sobald die Dauerüberweisung endet.]]></description>
			<content:encoded><![CDATA[<p>Abstrakt: Bei einer - aus rechtlichen Gründen - hier nicht namentlich genannten - Bank reicht das Gedächtnis für Kontoauszüge nur 3 Monate zurück. Und selbst für in diesem Zeitraum ausgeführte Dauerüberweisungen sind keinerlei Kontodaten des Begünstigten mehr verfügbar, sobald die Dauerüberweisung endet.</p>
<p>Ich muss mir hier meine Wut und mein Entsetzen vom der Seele schreiben&#8230;</p>
<p>Ok, Stefan bekommt noch meinen Anteil am gemeinsamen Urlaubsflug (den er gebucht und bezahlt hat) von mir. Nichts einfacher, als das - dachte ich.</p>
<p>Also schnell ins Online-Banking und in den <strong>Kontoauszügen</strong> nach den letzten Überweisungen an Stefan gesucht.</p>
<p>Huch, was ist das? <strong>Keine Kontonummer, nirgends?!</strong> Das Online-Gedächtnis meiner Bank ist dem Wählerverhalten angepasst und hat (trotz stetig fallender Preise für Massenspeicher) nur Platz für 3 Monate. Egal&#8230;</p>
<p>Krieg ich schon - denke ich - da ist ja erst vor ein paar Wochen noch ein Dauerauftrag ausgeführt worden. Fehlanzeige! Es gibt den zugehörigen Dauerauftrag gar nicht mehr, da er jetzt bereits abgelaufen ist - im Ergebnis habe ich <strong>mein Geld einem schwarzen Loch übereignet!</strong></p>
<p>Papierauszugsstapel durchwühlt - auch da: Bei Daueraufträgen gibt&#8217;s keine Kontonummer. Die, die ich <em>selbst </em>irgendwann mal eingetippt hatte, wurde in bester Ministry-of-Truth-Manier aus der Weltgeschichte <a href="http://en.wikipedia.org/wiki/Memory_hole" title="Wikipedia (en) - Memory hole" target="_blank">getilgt</a>. Und das, obwohl die aktuellen AGB der Banken die Ausführung <em>nur </em>noch nach BLZ+Konto ausführen - Namen sind inzwischen nur noch völlig überflüssiges Beiwerk - <strong>nur BLZ und Kontonummer sind für die Ausführung verbindlich</strong>.</p>
<p>Im Ergebnis <strong>kann ich an Hand des Kontoauszugs nicht mal prüfen, an wen ich denn nun wirklich Geld überwiesen habe</strong>.</p>
<p>Ich wünsche mir eine Google-Bank. Und bis dahin: Nur Bares ist Wahres <img src='http://blog.saddey.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/03/20/bananen-republik-deutschland-heute-wie-banken-sie-vor-kontonummern-schutzen/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Deploy a Grails Application to JBoss 5</title>
		<link>http://blog.saddey.net/2010/03/06/how-to-deploy-a-grails-application-to-jboss-5/</link>
		<comments>http://blog.saddey.net/2010/03/06/how-to-deploy-a-grails-application-to-jboss-5/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 09:27:47 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Hibernate]]></category>

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

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/03/06/how-to-deploy-a-grails-application-to-jboss-5/</guid>
		<description><![CDATA[Complete Grails sample application prepared for JBoss 5 deployment and a diagram sketching Grails logging architecture. Bonus track: Work-around for Hibernate issue which prevents a Grails 1.2.0 and 1.2.1 applications from starting.]]></description>
			<content:encoded><![CDATA[<p>As outlined at <a href="http://blog.saddey.net/2010/02/07/grails-how-to-use-native-server-logging-configuration-eg-tomcat-glassfish-jboss/" title="Reiner Saddey's Place - Grails - How to Use Native Server Logging Configuration (e.g. Tomcat GlassFish JBoss)" target="_blank">Grails - How to Use Native Server Logging Configuration (e.g. Tomcat GlassFish JBoss)</a>, it may be advisable to remove any conflicting logging implementation when deploying a Grails application into a production environment. I&#8217;ll give a full source example on how to achieve this and how to work-around an issue which prevents a Grails 1.2.0 and 1.2.1 applications from starting.</p>
<p>Unfortunately, each server provides a distinct set of logging frameworks. Still worse, servers can be reconfigured to use alternate logging frameworks (e.g. JBoss can be configured to use Java Logging instead of its default Log4J implementation and Tomcat 6 can be configured to use Log4J instead of its default Java Logging implementation).</p>
<p>Thus you either have to prepare a war which has been set-up for a specific target environment or completely remove <em>any</em> logging implementation from your Grails war and add missing jars to the lib directory of your target server instead.  Which one to choose may depend on whether access to the server configuration is permitted (e.g. its lib directory), how many different servers your application is to be deployed to and how hard it is for your build process to reliably produce variants specifically tailored for a particular deployment site.</p>
<p>Before presenting the code for a deployment to JBoss 5.1.0GA, let&#8217;s have a look at <strong>Grails&#8217; logging architecture</strong>. In its infancy Grails just used Apache Commons Logging (JCL) to provide an abstraction level and Log4J to implement the actual logging. Although even now, all <em>log</em> instances injected into Grails applications still implement org.appache.commons.logging.Log, Grails no longer uses JCL, but meanwhile has moved on to SLF4J:</p>
<p><img src="http://yuml.me/diagram/scruffy;scale:80/class/%5B%3C%3CInterface%3E%3E%3Bcommons.logging.Log%5D%5E-.-%20implements%5Bjcl-over-slf4j%5D%2C%20%5B%3C%3CUtility%3E%3E%3Bcommons.logging.LogFactory%5D1-++%5Bjcl-over-slf4j%5D%2C%20%5Bjcl-over-slf4j%5Duses%20-.-%3E%5Bslf4j-api%5D%2C%20%5Bslf4j-api%5Duses%20-.-%3E%5Bslf4j-log4j12%5D%2C%20%5Bslf4j-log4j12%5Duses%20-.-%3E%5Blog4j%5D" style="background: #c0c0c0 none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" title="Grails logging architecture" alt="Grails logging architecture" width="403" /></p>
<p>Starting with Grails 1.2, an additional bridge <em>jul-to-slf4j</em> which delegates Java Logging (Jul) to Slf4j is enabled by setting <em>grails.logging.jul.usebridge = true</em>. Be warned though, that for performance reasons <a href="http://www.slf4j.org/legacy.html#jul-to-slf4j" title="Bridging legacy APIs - JUL to SLF4J" target="_blank">this bridge should not be used when expecting heavy logging</a>.</p>
<p>Now for the good news: With <strong>JBoss 5</strong>, all of the above (but excluding jul-to-slf4j) has <strong>already been integrated into the server configuration and libraries</strong>. In order to deploy a Grails application to JBoss 5, we&#8217;ll just need to get rid of the jars within your war and prevent Grails from trying to configure the logging. How to achieve this?</p>
<p>Within <em>grails-app/conf/BuildConfig.groovy</em> we&#8217;ll <strong>remove offending jars</strong> when building the war:</p>
<pre>// TODO JBOSS - Remove own log4j and use the one supplied by JBoss instead
grails.war.resources = {stagingDir -&gt;
    def toRemove = [
          "$stagingDir/WEB-INF/lib/log4j-1.2.14.jar", // log4j supplied by JBoss
          "$stagingDir/WEB-INF/lib/log4j-1.2.15.jar", // log4j supplied by JBoss
          "$stagingDir/WEB-INF/classes/log4j.properties", // logging conf done in JBoss only
          "$stagingDir/WEB-INF/lib/slf4j-api-1.5.6.jar", // slf4j supplied by JBoss 5+
          "$stagingDir/WEB-INF/lib/slf4j-api-1.5.8.jar", // slf4j supplied by JBoss 5+
          "$stagingDir/WEB-INF/lib/slf4j-log4j12-1.5.6.jar", // slf4j supplied by JBoss 5+
          "$stagingDir/WEB-INF/lib/slf4j-log4j12-1.5.8.jar", // slf4j supplied by JBoss 5+
          "$stagingDir/WEB-INF/lib/jcl-over-slf4j-1.5.6.jar", // jcl supplied by JBoss as well
          "$stagingDir/WEB-INF/lib/jcl-over-slf4j-1.5.8.jar", // jcl supplied by JBoss as well
        // see also Config.grails.logging.jul.usebridge - shouldn't be used
        //     http://www.slf4j.org/legacy.html#jul-to-slf4j
        //          "$stagingDir/WEB-INF/lib/jul-to-slf4j-1.5.6.jar",
        //          "$stagingDir/WEB-INF/lib/jul-to-slf4j-1.5.8.jar",
        // you might want to remove JDBC drivers when using server supplied JNDI...
        //          "$stagingDir/WEB-INF/lib/hsqldb-1.8.0.5.jar",
    ].each {
        delete(file: it)
    }
}</pre>
<p>Within <em>scripts/_Events.groovy</em> we&#8217;ll <strong>disable Grails logging configuration</strong> components:</p>
<pre>import groovy.xml.StreamingMarkupBuilder

/**
 * TODO JBOSS - Remove log4j configuration stuff (when running with JBoss or GlassFish a.s.o)
 */
eventWebXmlEnd = {String tmpfile -&gt;

    def root = new XmlSlurper().parse(webXmlFile)

    // When running with JBoss (or GlassFish a.s.o) remove log4j configuration stuff
    def log4j = root.listener.findAll {node -&gt;
        node.'listener-class'.text() == 'org.codehaus.groovy.grails.web.util.Log4jConfigListener'
    }
    log4j.replaceNode {}

    def log4jFile = root.'context-param'.findAll {node -&gt;
        node.'param-name'.text() == 'log4jConfigLocation'
    }
    log4jFile.replaceNode {}

    webXmlFile.text = new StreamingMarkupBuilder().bind {
        mkp.declareNamespace("": "http://java.sun.com/xml/ns/j2ee")
        mkp.yield(root)
    }
}</pre>
<p>You are now set to control logging within JBoss jboss-log4j.xml.</p>
<p>If you&#8217;re using Grails 1.2.0 or 1.2.1, JBoss <strong>still refuses</strong> to deploy your war. This is caused by version conflicts within <strong>Hibernate </strong>jars (used to be work-arounded by deleting all Hibernate jars from JBoss lib directory) and they have been fixed by <a href="http://jira.codehaus.org/browse/GRAILS-5606?focusedCommentId=212135&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_212135" title="GRAILS-5606 - Deploy on JBoss 5.1.0 GA" target="_blank">GRAILS-5606</a> for (not yet released) Grails 1.2.2.</p>
<p>Graeme Rocher as well supplies a work-around for 1.2.x:</p>
<blockquote><p><em>Fixed in latest hibernate plugin 1.3.0.BUILD-SNAPSHOT</em></p>
<p><em>It seems in order to use the latest version of Hibernate on JBoss you must include Hibernate validator otherwise you run into this classloading error. This means the hibernate plugin is forced to include hibernate-validator as a dependency even if we don&#8217;t use it which is a pretty annoying.</em></p>
<p><em>Anyway you can fix this yourselves in 1.2.x by adding the following dependency to BuildConfig.groovy:</em></p>
<pre>runtime('org.hibernate:hibernate-validator:3.1.0.GA') {
    excludes 'sl4j-api', 'hibernate.core',
             'hibernate-commons-annotations', 'hibernate-entitymanager'
    }</pre>
<p><em>Be sure to uncomment the jboss maven repository so the dependency resolvers</em></p></blockquote>
<p>This work-around is included within sample sources. Just search for <em>TODO</em> tags.</p>
<p>Links:</p>
<ul>
<li><a href="https://docs.google.com/leaf?id=0B5F8upNsB6rGYjZhYzQ3YWEtYjQ3OC00ZTMxLWJkYTYtZTNjZmU5NjcxOTdj&amp;hl=en" title="Source Code and war for this post" target="_blank">Source Code and war</a></li>
<li><a href="http://buildchimp.com/wordpress/?p=249" title="Build Lackey Blog - Using Log4j with Grails Apps on JBoss" target="_blank">Build Lackey Blog - Using Log4j with Grails Apps on JBoss</a></li>
<li><a href="http://www.thejavajar.com/2009/11/03/grails-on-jboss-as-510-ga/" title="thejavajar Blog - Grails on JBoss AS 5.1.0 GA" target="_blank">thejavajar Blog - JBoss AS 5.1.0 GA</a></li>
<li><a href="http://jira.codehaus.org/browse/GRAILS-5606?focusedCommentId=212135&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_212135" title="Grails Issues - GRAILS-5606 - Deploy on JBoss 5.1.0 GA" target="_blank">GRAILS-5606 - Deploy on JBoss 5.1.0 GA</a></li>
<li><a href="http://yuml.me/diagram/scruffy/class/edit/[%3C%3CInterface%3E%3E;commons.logging.Log]%5E-.-%20implements[jcl-over-slf4j],%20[%3C%3CUtility%3E%3E;commons.logging.LogFactory]1-++[jcl-over-slf4j],%20[jcl-over-slf4j]uses%20-.-%3E[slf4j-api],%20[slf4j-api]uses%20-.-%3E[slf4j-log4j12],%20[slf4j-log4j12]uses%20-.-%3E[log4j]" target="_blank">This diagram</a> has been prepared using <a href="http://yuml.me/" title="yUML - Create UML diagrams online in seconds, no special tools needed." target="_blank">yUML</a> (avoid IE, if you can)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/03/06/how-to-deploy-a-grails-application-to-jboss-5/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Teaching Mavenized Grails to Survive mvn release:prepare release:perform with Hudson</title>
		<link>http://blog.saddey.net/2010/02/10/teaching-mavenized-grails-to-survive-mvn-releaseprepare-releaseperform-with-hudson/</link>
		<comments>http://blog.saddey.net/2010/02/10/teaching-mavenized-grails-to-survive-mvn-releaseprepare-releaseperform-with-hudson/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 17:06:13 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Maven]]></category>

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

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/02/10/teaching-mavenized-grails-to-survive-mvn-releaseprepare-releaseperform-with-hudson/</guid>
		<description><![CDATA[A mavenized Grails project has 2 competing sources stating the version of the application

&#60;version&#62; within pom.xml
app.version within application.properties

If 2. does not match 1. the grails-maven-plugin will abort the build, urging you to manually fix the version mismatch. Although somewhat clumsy, the release will still succeed if you edit application.properties and re-start the failing mvn release:prepare. [...]]]></description>
			<content:encoded><![CDATA[<p>A mavenized Grails project has 2 competing sources stating the version of the application</p>
<ol>
<li>&lt;version&gt; within pom.xml</li>
<li>app.version within application.properties</li>
</ol>
<p>If 2. does not match 1. the grails-maven-plugin will abort the build, urging you to manually fix the version mismatch. Although somewhat clumsy, the release will still succeed if you edit application.properties and re-start the failing mvn release:prepare. However, you&#8217;re somewhat stuck, if the release is to be performed from within a continous integration server (e.g. Hudson).</p>
<p>Thus I devised a work-around, that will compare both versions and update the version within application.properties if required. My work-around is far from perfect, as I was unable to integrate it within the Maven lifecycle defined by the grails-maven-plugin. This lifecycle will always and unconditionally bind its own code to the validate phase first (aborting on version mismatches). Therefore I resorted to binding my repair action to the clean phase and changed the goals of the maven-release-plugin to perform a clean before invoking the deploy. Note that this will produce a consistent war (both pom and application.properties set to the release version), but will <em>not</em> resolve the discrepancy within the tagged sources (i.e. application.properties will still state the snapshot version).</p>
<p>Here&#8217;s my code. It uses a profile, which is only activated, if the file application.properties is actually present. Thus the code can be included within a parent pom.xml that might be used with non-Grails projects as well:</p>
<pre>&lt;profiles&gt;
 &lt;profile&gt;
  &lt;id&gt;enable-reset.application.properties&lt;/id&gt;
  &lt;activation&gt;
   &lt;activeByDefault&gt;false&lt;/activeByDefault&gt;
   &lt;file&gt;
    &lt;exists&gt;application.properties&lt;/exists&gt;
   &lt;/file&gt;
  &lt;/activation&gt;
  &lt;build&gt;
   &lt;pluginManagement&gt;
    &lt;plugins&gt;
     &lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-release-plugin&lt;/artifactId&gt;
      &lt;configuration&gt;
       &lt;!-- invoke clean first - see below --&gt;
       &lt;goals&gt;clean deploy&lt;/goals&gt;
      &lt;/configuration&gt;
     &lt;/plugin&gt;
    &lt;/plugins&gt;
   &lt;/pluginManagement&gt;

   &lt;plugins&gt;
    &lt;!--
     Allow release:prepare/perform to succeed with Grails
     app. Reset application.properties.app.version to
     project.version Sorta hack on clean, as
     grails-maven-plugin:validate ALWAYS runs first and
     connot be preceeded by any other execution
    --&gt;
    &lt;plugin&gt;
     &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
     &lt;version&gt;1.3&lt;/version&gt;
     &lt;executions&gt;
      &lt;execution&gt;
       &lt;id&gt;reset.application.properties&lt;/id&gt;
       &lt;phase&gt;clean&lt;/phase&gt;
       &lt;goals&gt;
        &lt;goal&gt;run&lt;/goal&gt;
       &lt;/goals&gt;
       &lt;configuration&gt;
        &lt;tasks&gt;
         &lt;taskdef resource="net/sf/antcontrib/antlib.xml"
          classpathref="maven.plugin.classpath" /&gt;
         &lt;if&gt;
          &lt;available file="application.properties" /&gt;
          &lt;then&gt;
           &lt;property file="application.properties"
            prefix="application.properties" /&gt;
           &lt;if&gt;
            &lt;not&gt;
             &lt;equals arg1="${project.version}"
              arg2="${application.properties.app.version}" /&gt;
            &lt;/not&gt;
            &lt;then&gt;
             &lt;propertyfile file="application.properties"
              comment="Grails Metadata file"&gt;
              &lt;entry operation="=" type="string" key="app.version"
               value="${project.version}" /&gt;
             &lt;/propertyfile&gt;
            &lt;/then&gt;
           &lt;/if&gt;
          &lt;/then&gt;
         &lt;/if&gt;
        &lt;/tasks&gt;
       &lt;/configuration&gt;
      &lt;/execution&gt;
     &lt;/executions&gt;

     &lt;dependencies&gt;
      &lt;dependency&gt;
       &lt;groupId&gt;org.apache.ant&lt;/groupId&gt;
       &lt;artifactId&gt;ant&lt;/artifactId&gt;
       &lt;version&gt;1.7.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
       &lt;groupId&gt;org.apache.ant&lt;/groupId&gt;
       &lt;artifactId&gt;ant-nodeps&lt;/artifactId&gt;
       &lt;version&gt;1.7.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
       &lt;groupId&gt;ant-contrib&lt;/groupId&gt;
       &lt;artifactId&gt;ant-contrib&lt;/artifactId&gt;
       &lt;version&gt;1.0b3&lt;/version&gt;
       &lt;exclusions&gt;
        &lt;exclusion&gt;
         &lt;groupId&gt;ant&lt;/groupId&gt;
         &lt;artifactId&gt;ant&lt;/artifactId&gt;
        &lt;/exclusion&gt;
       &lt;/exclusions&gt;
      &lt;/dependency&gt;
     &lt;/dependencies&gt;
    &lt;/plugin&gt;
   &lt;/plugins&gt;
  &lt;/build&gt;
 &lt;/profile&gt;
&lt;/profiles&gt;</pre>
<p>Links:</p>
<ul>
<li><a href="http://jira.codehaus.org/browse/GRAILS-5859?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel" title="GRAILS-5859 - maven release:prepare fails because of version not changed in application.properties" target="_blank">GRAILS-5859 - maven release:prepare fails because of version not changed in application.properties</a></li>
<li><a href="http://n4.nabble.com/maven-release-fails-because-of-app-version-td1366290.html" title="Grails User - maven release fails because of app.version" target="_blank">Grails User - maven release fails because of app.version</a></li>
<li><a href="http://wiki.hudson-ci.org/display/HUDSON/M2+Release+Plugin" title="Hudson - M2 Release Plugin" target="_blank">Hudson - M2 Release Plugin</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/02/10/teaching-mavenized-grails-to-survive-mvn-releaseprepare-releaseperform-with-hudson/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Maven - Never Say Never in an updatePolicy</title>
		<link>http://blog.saddey.net/2010/02/07/maven-never-say-never-in-an-updatepolicy/</link>
		<comments>http://blog.saddey.net/2010/02/07/maven-never-say-never-in-an-updatepolicy/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 13:36:42 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Maven]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/02/07/maven-never-say-never-in-an-updatepolicy/</guid>
		<description><![CDATA[I want to share a misconception that caused Maven to fail when looking for artifacts. Im my example I was upgrading from Grails 1.2.0 to 1.2.1 and including a dependency to grails.org:grails-core:[1.2.1,1.2.1]. Maven would just complain with Couldn&#8217;t find a version in &#8230;, although I verified that this particular version is indeed available at the [...]]]></description>
			<content:encoded><![CDATA[<p>I want to share a misconception that caused Maven to fail when looking for artifacts. Im my example I was upgrading from Grails 1.2.0 to 1.2.1 and including a dependency to grails.org:grails-core:[1.2.1,1.2.1]. Maven would just complain with <em>Couldn&#8217;t find a version in &#8230;</em>, although I verified that this particular version is indeed available at the remote repository.</p>
<p>My misconception was, that when declaring a remote release repository &lt;updatePolicy&gt;never&lt;/updatePolicy&gt; would only apply to <em>existing </em>artifacts, which - of course - need not be checked for remote changes (release artifacts must not change once they are released).</p>
<p>However, <strong>updatePolicy also applies to Maven meta data</strong>, i.e. which versions are available (and which one is the most current one). Thus, if there are any artifact versions already present in your local Maven repository, Maven will <strong>never</strong><em> </em>download any version that is not yet present in your local repository <img src='http://blog.saddey.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>See also <a href="http://jira.codehaus.org/browse/MNG-3006" title="[#MNG-3006] Maven does not always download artifacts from specified repos - jira.codehaus.org" target="_blank">Maven does not always download artifacts from specified repos</a>.</p>
<p>With release repositories, the default value for updatePolicy is &lt;updatePolicy&gt;daily&lt;/updatePolicy&gt;, which should be appropriate for most <em>external </em>Maven release repositories.</p>
<p>As we&#8217;re using a local <a href="http://nexus.sonatype.org/" title="Nexus | the repository manager" target="_blank">Nexus</a> for both hosting our own company repositories and for proxying external repositories as well, updatePolicy daily is too slow to avoid confusion when accessing internal releases from the Public Repositories group. So I chose to use &lt;updatePolicy&gt;always&lt;/updatePolicy&gt; instead and let Nexus settings determine the interval at which it refreshes external repository artifacts:</p>
<pre>&lt;repository&gt;
 &lt;!-- Use our local Nexus Public Repositories Group --&gt;
 &lt;id&gt;public&lt;/id&gt;
 &lt;name&gt;Public Repositories&lt;/name&gt;
 &lt;url&gt;http://ournexus.mycompany.com:8081/nexus/content/groups/public&lt;/url&gt;
 &lt;releases&gt;
  &lt;enabled&gt;true&lt;/enabled&gt;
  &lt;updatePolicy&gt;always&lt;/updatePolicy&gt;
  &lt;/releases&gt;
 &lt;snapshots&gt;
  &lt;enabled&gt;false&lt;/enabled&gt;
 &lt;/snapshots&gt;
&lt;/repository&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/02/07/maven-never-say-never-in-an-updatepolicy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails - How to Use Native Server Logging Configuration (e.g. Tomcat GlassFish JBoss)</title>
		<link>http://blog.saddey.net/2010/02/07/grails-how-to-use-native-server-logging-configuration-eg-tomcat-glassfish-jboss/</link>
		<comments>http://blog.saddey.net/2010/02/07/grails-how-to-use-native-server-logging-configuration-eg-tomcat-glassfish-jboss/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 12:18:11 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Grails]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/02/07/grails-how-to-use-native-server-logging-configuration-eg-tomcat-glassfish-jboss/</guid>
		<description><![CDATA[Grails comes complete with logging out-of-the-box. However, if a Grails application is being deployed to a  production servlet container, it may be advisable or even required for Grails to step aside and let the server admins do their jobs  
Update: There&#8217;s a follow up that includes full source and a ready-to-deploy war. See [...]]]></description>
			<content:encoded><![CDATA[<p>Grails comes complete with logging out-of-the-box. However, if a Grails application is being deployed to a  production servlet container, it may be advisable or even required for Grails to step aside and let the server admins do their jobs <img src='http://blog.saddey.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Update:</strong> There&#8217;s a follow up that includes full source and a ready-to-deploy war. See <a href="http://blog.saddey.net/2010/03/06/how-to-deploy-a-grails-application-to-jboss-5/" title="How to Deploy a Grails Application to JBoss 5">How to Deploy a Grails Application to JBoss 5</a>.</p>
<p>You need not avoid the loggers injected by Grails in order to use the native logging provided by servlet containers (e.g. Tomcat, GlassFish, JBoss). Grails loggers (always have implemented and now still) implement org.apache.commons.log.Log through jcl-over-slf4j delegating to some slf4j implementation adapter. You&#8217;re free to choose which logging system will ultimately perform the &#8220;real&#8221; logging. This is what we do:</p>
<ol>
<li>Use the slf4j Implementation adapter that delegates to the native logging supplied by the web server container, e.g. slf4j-log4j12 for JBoss or slf4j-jdk14 for GlassFish / standard Tomcat 6. One (and only one) of those must be packaged within the war.</li>
<li>Remove any logging implementation from our war (e.g. log4j), as it will be supplied by the  servlet container (e.g.  Log4j with JBoss or  Java-logging with GlassFish / standard Tomcat 6.x).</li>
<li>Disable Grails logging configurator.</li>
<li>Use whatever means the web server container offers to configure its logging.</li>
</ol>
<p>Step 2 can be implemented within grails-app/BuildConfig.groovy similar to:</p>
<pre>grails.war.resources = {stagingDir -&gt;
  def toRemove = [
          "$stagingDir/WEB-INF/lib/log4j-1.2.14.jar", // Logging -&gt; native GlassFish/Tomcat/JBoss
          "$stagingDir/WEB-INF/lib/log4j-1.2.15.jar", // "
          "$stagingDir/WEB-INF/classes/log4j.properties", // "
          "$stagingDir/WEB-INF/lib/slf4j-log4j12-1.5.6.jar", // "
          "$stagingDir/WEB-INF/lib/slf4j-log4j12-1.5.8.jar", // "
  ].each {
    delete(file: it)
  }
}</pre>
<p>Step 3 can be achieved by altering the web.xml, either verbatim or by means of a grails-app/scripts/_Events.groovy which might looks similar to:</p>
<pre>import groovy.xml.StreamingMarkupBuilder

eventWebXmlEnd = {String tmpfile -&gt;

 def root = new XmlSlurper().parse(webXmlFile)

 // remove some log4j stuff
 def log4j = root.listener.findAll {node -&gt;
   node.'listener-class'.text() == 'org.codehaus.groovy.grails.web.util.Log4jConfigListener'
 }
 log4j.replaceNode {}

 def log4jFile = root.'context-param'.findAll {node -&gt;
   node.'param-name'.text() == 'log4jConfigLocation'
 }
 log4jFile.replaceNode {}

 webXmlFile.text = new StreamingMarkupBuilder().bind {
   mkp.declareNamespace("": "http://java.sun.com/xml/ns/j2ee")
   mkp.yield(root)
 }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/02/07/grails-how-to-use-native-server-logging-configuration-eg-tomcat-glassfish-jboss/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Grails - UTF-8 Form Input Garbled when Running Within Tomcat</title>
		<link>http://blog.saddey.net/2010/02/06/grails-utf-8-form-input-garbled-when-running-within-tomcat/</link>
		<comments>http://blog.saddey.net/2010/02/06/grails-utf-8-form-input-garbled-when-running-within-tomcat/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 13:05:57 +0000</pubDate>
		<dc:creator>Reiner</dc:creator>
		
		<category><![CDATA[Grails]]></category>

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

		<guid isPermaLink="false">http://blog.saddey.net/2010/02/06/grails-utf-8-form-input-garbled-when-running-within-tomcat/</guid>
		<description><![CDATA[There are numerous articles describing charset problems when using Tomcat to run Grails applications that are supposed to accept UTF-8 characters (e.g. German umlauts äöüÄÖÜß). Most of them don&#8217;t mention a subtle cause that may jeopardize all your efforts to properly interpret UTF-8 form input. And fiddling around with Tomcat&#8217;s defaults was not an option [...]]]></description>
			<content:encoded><![CDATA[<p>There are numerous articles describing charset problems when using Tomcat to run Grails applications that are supposed to accept UTF-8 characters (e.g. German umlauts äöüÄÖÜß). Most of them don&#8217;t mention a subtle cause that may jeopardize all your efforts to properly interpret UTF-8 form input. And fiddling around with Tomcat&#8217;s defaults was not an option for me, as the same Tomcat instance is to run other non-Grails legacy applications that rely on ISO-8859-1 being the default character set.</p>
<p>It took me some time to find out that Grails applications (1.2.0) behave just as expected under Tomcat (6.x) without any modification whatsoever, provided you <strong>don&#8217;t use Tomcat&#8217;s RequestDumperValve</strong> within your server.xml or context.xml.</p>
<pre>&lt;!-- Reiner: If you include this in your context.xml or server.xml,
     form input will <strong>always</strong> be interpreted as ISO-8859-1 <img src='http://blog.saddey.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />
&lt;Valve className=&#8221;org.apache.catalina.valves.RequestDumperValve&#8221;/&gt;
&#8211;&gt;</pre>
<p>The reason for RequestDumperValve to garble form input is that it causes POST-parameters to be evaluated (using default ISO-8859-1) <strong>before</strong> Grails request filters have had a chance to set the request encoding to UTF-8. This behaviour is <a href="http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html#Request%20Dumper%20Valve" title="Apache Tomcat 5.5 Configuration - Request Dumper Valve" target="_blank">documented and RequestDumperValve is now deprecated due to its side effects</a>.</p>
<p>The ultimate cause to this problem is that most browsers do not bother to state the character set that has been used to encode POST-parameters, thus leaving it up to the server to guess. Grails does this out-of-the-box within its applicationContext.xml:</p>
<pre>&lt;bean id="characterEncodingFilter"
      class="org.springframework.web.filter.CharacterEncodingFilter"&gt;
      &lt;property name="encoding"&gt;
        &lt;value&gt;utf-8&lt;/value&gt;
      &lt;/property&gt;
&lt;/bean&gt;</pre>
<p>Credits: <a href="http://n4.nabble.com/UTF-8-issues-tomcat-vs-jetty-behaving-differently-tp1386332p1386333.html" title="Grails User - UTF-8 issues, tomcat vs jetty behaving differently" target="_blank">Ales at Grails User forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.saddey.net/2010/02/06/grails-utf-8-form-input-garbled-when-running-within-tomcat/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 4.887 seconds -->
<!-- Cached page served by WP-Cache -->
<!-- Compression = gzip/x-gzip -->
