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

<channel>
	<title>devLL&#039;s Blog</title>
	<atom:link href="http://devll.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://devll.wordpress.com</link>
	<description>developer lessons learned</description>
	<lastBuildDate>Wed, 30 Mar 2011 12:04:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devll.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>devLL&#039;s Blog</title>
		<link>http://devll.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devll.wordpress.com/osd.xml" title="devLL&#039;s Blog" />
	<atom:link rel='hub' href='http://devll.wordpress.com/?pushpress=hub'/>
		<item>
		<title>WKBReader: ParseException: Unknown WKB type x</title>
		<link>http://devll.wordpress.com/2011/03/29/wkbreader-parsexception-unknown-wkb-type-x/</link>
		<comments>http://devll.wordpress.com/2011/03/29/wkbreader-parsexception-unknown-wkb-type-x/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 10:15:10 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JTS]]></category>
		<category><![CDATA[Thread]]></category>
		<category><![CDATA[WKB]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=180</guid>
		<description><![CDATA[I&#8217;m using the Java API JTS Topology Suite to do spatial operations. To convert a byte array into a Geometry object the following helper class was used: public class JTSHelper { static WKBReader wkbReader = new WKBReader(); public static Geometry bytesToGeometry(byte geometryBytes[]) throws ParseException { return wkbReader.read(geometryBytes); } } This seemed to work well, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=180&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using the Java API <a title="JTS Topology Suite" href="http://www.vividsolutions.com/jts/JTSHome.htm">JTS Topology Suite</a> to do spatial operations. To convert a byte array into a Geometry object the following helper class was used:</p>
<pre class="brush: java;">
public class JTSHelper {
	static WKBReader wkbReader = new WKBReader();

	public static Geometry bytesToGeometry(byte geometryBytes[]) throws ParseException {
		return wkbReader.read(geometryBytes);
	}
}
</pre>
<p>This seemed to work well, but in the logfile we saw intermittent failures caused by this class:<br />
<code>ParseException: Unknown WKB type 139<br />
ParseException: Unknown WKB type 0<br />
ParseException: Unknown WKB type 17</code><br />
The WKB type numbers were always different, but when checking the incoming byte arrays everything seems to be OK.</p>
<p>With <a title="ab - Apache HTTP server benchmarking tool" href="http://httpd.apache.org/docs/2.0/programs/ab.html">apache benchmark tool</a> the failures could be reproduced when increasing the number of concurrent requests:<br />
<code>ab -n 1000 -c 10 http://localhost:8080/project/test-action<br />
</code><br />
A look at JavaDoc of <a href="http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/io/WKBReader.html"><code>WKBReader</code></a> shows that this class is not thread-safe. Therefore the solution is to put <code>WKBReader</code> in <code>ThreadLocal</code>:</p>
<pre class="brush: java;">
public class JTSHelper {
	static ThreadLocal&lt;WKBReader&gt; wkbReader	= new ThreadLocal&lt;WKBReader&gt;() {
		protected WKBReader initialValue() { return new WKBReader(); };
	};

	public static Geometry bytesToGeometry(byte geometryBytes[]) throws ParseException {
		WKBReader reader = wkbReader.get();
		return reader.read(geometryBytes);
	}
}
</pre>
<p><em>Versions: JTS 1.8, JDK 5</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/180/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/180/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/180/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=180&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2011/03/29/wkbreader-parsexception-unknown-wkb-type-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>Tomcat: Getting the process ID</title>
		<link>http://devll.wordpress.com/2010/12/08/tomcat-getting-the-process-id/</link>
		<comments>http://devll.wordpress.com/2010/12/08/tomcat-getting-the-process-id/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 14:58:05 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Tomcat]]></category>
		<category><![CDATA[shutdown]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=164</guid>
		<description><![CDATA[If you want to get the process id (PID) of your tomcat you can do something like this: ps h -C java -o &#34;%p:%a&#34; &#124; grep catalina &#124; cut -d: -f1 If you want to kill this tomcat, because it didn&#8217;t shut down properly you can use the following: kill -9 `ps h -C java [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=164&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you want to get the process id (PID) of your tomcat you can do something like this:</p>
<pre class="brush: bash;">
ps h -C java -o &quot;%p:%a&quot; | grep catalina | cut -d: -f1
</pre>
<p>If you want to kill this tomcat, because it didn&#8217;t shut down properly you can use the following:</p>
<pre class="brush: bash;">
kill -9 `ps h -C java -o &quot;%p:%a&quot; | grep catalina | cut -d: -f1`
</pre>
<p>A better way is to set the environment variable <code>CATALINA_PID</code>. If this variable is set the PID is written in the specified file (here catalina.pid) on tomcat startup.</p>
<pre class="brush: bash;">
export CATALINA_PID=/opt/tomcat/catalina.pid
/opt/tomcat/bin/startup.sh
</pre>
<p>Now killing the tomcat is also easier: You can can stop tomcat with <code>-force</code>, which will kill the tomcat process after shutdown (<code>-force</code> only works if <code>CATALINA_PID</code> is set).</p>
<pre class="brush: bash;">
export CATALINA_PID=/opt/tomcat/catalina.pid
/opt/tomcat/bin/shutdown.sh -force
</pre>
<p>(If you set <code>CATALINA_PID</code> in your .bashrc you don&#8217;t have to set it before startup/shutdown)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/164/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/164/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/164/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=164&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2010/12/08/tomcat-getting-the-process-id/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>Eclipse open GSP-page: Editor could not be initialized</title>
		<link>http://devll.wordpress.com/2010/10/25/eclipse-open-gsp-page-editor-could-not-be-initialized/</link>
		<comments>http://devll.wordpress.com/2010/10/25/eclipse-open-gsp-page-editor-could-not-be-initialized/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 08:58:01 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[gsp]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[STS]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=154</guid>
		<description><![CDATA[I&#8217;m using Eclipse with the SpringSource Tool Suite. After importing a Grails Project, I wanted to open a GSP-page but got the following error in the Editor: Could not open the editor: Editor could not be initialized. The stacktrace looks as follows: java.lang.NullPointerException at com.springsource.sts.grails.editor.gsp.tags.GSPModelQueryCMProvider.(GSPModelQueryCMProvider.java:53) at com.springsource.sts.grails.editor.gsp.tags.GSPModelQueryImpl.(GSPModelQueryImpl.java:36) ... at org.eclipse.equinox.launcher.Main.main(Main.java:1287) The error occurs because Eclipse [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=154&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using Eclipse with the <a href="http://www.springsource.com/developer/sts">SpringSource Tool Suite</a>. After importing a Grails Project, I wanted to open a GSP-page but got the following error in the Editor:<code> Could not open the editor: Editor could not be initialized.</code></p>
<p>The stacktrace looks as follows:
<pre class="brush: plain;">
java.lang.NullPointerException
    at com.springsource.sts.grails.editor.gsp.tags.GSPModelQueryCMProvider.(GSPModelQueryCMProvider.java:53)
    at com.springsource.sts.grails.editor.gsp.tags.GSPModelQueryImpl.(GSPModelQueryImpl.java:36)
    ...
    at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
</pre>
<p>The error occurs because Eclipse (STS) wants to open GSP-files with the GSP Editor (because of File Associations) even if the project is not a Grails Project.</p>
<p>So the solution is to convert the project in a Grails Project: right click on your project →  &#8220;Configure&#8221; | &#8220;Convert to Grails-Project&#8221;.</p>
<p><strong>Resources:</strong></p>
<ul>
<li><a href="https://issuetracker.springsource.com/browse/STS-800">[grails] Opening a GSP Page creates a NullPointerException</a></li>
<li><a href="http://forum.springsource.org/showthread.php?t=82963">GSP Editor NullPointerException</a></li>
</ul>
<p><em>Versions: Eclipse 3.5, STS 2.3, Grails 1.1.1</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=154&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2010/10/25/eclipse-open-gsp-page-editor-could-not-be-initialized/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>Grails and UrlRewriteFilter: Problem with Params</title>
		<link>http://devll.wordpress.com/2010/07/20/grails-and-urlrewritefilter-problem-with-params/</link>
		<comments>http://devll.wordpress.com/2010/07/20/grails-and-urlrewritefilter-problem-with-params/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 11:50:30 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[UrlRewrite]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=125</guid>
		<description><![CDATA[I&#8217;m using UrlRewriteFilter to map some legacy URLs to our new Grails application. It&#8217;s configured as follows: web.xml ... &#60;filter&#62; &#60;filter-name&#62;rewriteFilter&#60;/filter-name&#62; &#60;filter-class&#62;org.tuckey.web.filters.urlrewrite.UrlRewriteFilter&#60;/filter-class&#62; &#60;/filter&#62; &#60;filter-mapping&#62; &#60;filter-name&#62;charEncodingFilter&#60;/filter-name&#62; &#60;url-pattern&#62;/*&#60;/url-pattern&#62; &#60;/filter-mapping&#62; &#60;filter-mapping&#62; &#60;filter-name&#62;sitemesh&#60;/filter-name&#62; &#60;url-pattern&#62;/*&#60;/url-pattern&#62; &#60;/filter-mapping&#62; &#60;filter-mapping&#62; &#60;filter-name&#62;rewriteFilter&#60;/filter-name&#62; &#60;url-pattern&#62;/*&#60;/url-pattern&#62; &#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62; &#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62; &#60;/filter-mapping&#62; urlrwrite.xml ... &#60;rule&#62; &#60;from&#62;^/legacy-search-url$&#60;/from&#62; &#60;to last=&#34;true&#34;&#62;/search/result&#60;/to&#62; &#60;set type=&#34;parameter&#34; name=&#34;pagesize&#34;&#62;5&#60;/set&#62; &#60;/rule&#62; Now I had the problem that the forward [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=125&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using <a href="http://www.tuckey.org/urlrewrite/">UrlRewriteFilter</a> to map some legacy URLs to our new Grails application. It&#8217;s configured as follows:</p>
<p><strong>web.xml</strong></p>
<pre class="brush: xml;">
...
&lt;filter&gt;
    &lt;filter-name&gt;rewriteFilter&lt;/filter-name&gt;
    &lt;filter-class&gt;org.tuckey.web.filters.urlrewrite.UrlRewriteFilter&lt;/filter-class&gt;
&lt;/filter&gt;

&lt;filter-mapping&gt;
    &lt;filter-name&gt;charEncodingFilter&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;

&lt;filter-mapping&gt;
    &lt;filter-name&gt;sitemesh&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;

&lt;filter-mapping&gt;
	&lt;filter-name&gt;rewriteFilter&lt;/filter-name&gt;
	&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
	&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
&lt;/filter-mapping&gt;
</pre>
<p><strong>urlrwrite.xml</strong></p>
<pre class="brush: xml;">
...
&lt;rule&gt;
	&lt;from&gt;^/legacy-search-url$&lt;/from&gt;
	&lt;to last=&quot;true&quot;&gt;/search/result&lt;/to&gt;
	&lt;set type=&quot;parameter&quot; name=&quot;pagesize&quot;&gt;5&lt;/set&gt;
&lt;/rule&gt;
</pre>
<p>Now I had the problem that the forward worked as expected (SearchController with action &#8220;result&#8221; was invoked), but in <code>params</code> parameter <code>pagesize</code> was missing.</p>
<p>After a while of debugging I found out the following:<br />
<code>GrailsWebRequest</code>, which holds the <code>params</code> is created with the <code>GrailsWebRequestFilter</code>. This filter is added to the <code>web.xml</code> in the controllers-plugin and the filter-mapping is placed at the end or after the <code>charEncodingFilter</code>. In my case after <code>charEncodingFilter</code> and so before the <code>rewriteFilter</code>:</p>
<p><strong>generated web.xml</strong></p>
<pre class="brush: xml;">
&lt;filter-mapping&gt;
    &lt;filter-name&gt;charEncodingFilter&lt;/filter-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&lt;filter-mapping&gt;
	&lt;filter-name&gt;grailsWebRequest&lt;/filter-name&gt;
	&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
	&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
&lt;/filter-mapping&gt;
&lt;filter-mapping&gt;
	&lt;filter-name&gt;sitemesh&lt;/filter-name&gt;
	&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
	&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
&lt;/filter-mapping&gt;
&lt;filter-mapping&gt;
	&lt;filter-name&gt;rewriteFilter&lt;/filter-name&gt;
	&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
	&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
	&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;
&lt;/filter-mapping&gt;
</pre>
<p>That means that the <code>params</code>-object is created before the rewriting happens, which explains that the <code>pagesize</code> parameter is not there. The solution is to place the <code>rewriteFilter</code> in first position of the filter-mapping or at least before the <code>charEncodingFilter</code> (if present).</p>
<p>Rethinking the problem I had the opinion that it should work regardless to the order, as the <code>grailsWebRequest</code>-filter has a forward dispatcher and should be called again after the rewriting. That&#8217;s correct so far, but as <code>GrailsWebRequestFilter</code> extends <code>OncePerRequestFilter</code> the <code>GrailsWebRequest</code> is not recreated on the second call.</p>
<p>Hint: If you are using the <a href="http://www.grails.org/plugin/urlrewrite">URL Rewrite Plugin</a>, you will have the same problems, as it is loaded after the controllers-Plugin.</p>
<p><em>Versions: Grails 1.1.1</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=125&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2010/07/20/grails-and-urlrewritefilter-problem-with-params/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>Error in Grails documentation of URL Mappings exclude</title>
		<link>http://devll.wordpress.com/2009/12/15/error-in-grails-documentation-of-url-mapping-exclude/</link>
		<comments>http://devll.wordpress.com/2009/12/15/error-in-grails-documentation-of-url-mapping-exclude/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 19:56:12 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[URL Mapping]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=101</guid>
		<description><![CDATA[In 6.4.6 Mapping Wildcards is written that you exclude URIs like this: static excludes = [&#34;/images/**&#34;, &#34;/css/**&#34;] But this didn&#8217;t work for me. Looking at the source code (UrlMappingsFilter) I found out, that the exclude is no wildcard pattern matching and only a startsWith matching: for (String excludePattern:excludePatterns){ if (uri.equals(excludePattern)&#124;&#124; (excludePattern.endsWith(&#34;*&#34;)&#38;&#38; excludePattern.substring(0,excludePattern.length()-1). regionMatches(0,uri,0,excludePattern.length()-1))){ processFilterChain(request, response, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=101&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://grails.org/doc/1.1.x/guide/6.%20The%20Web%20Layer.html#6.4.6%20Mapping%20Wildcards">6.4.6 Mapping Wildcards</a> is written that you exclude URIs like this:</p>
<pre class="brush: java;">
static excludes = [&quot;/images/**&quot;, &quot;/css/**&quot;]
</pre>
<p>But this didn&#8217;t work for me. Looking at the source code (<code>UrlMappingsFilter</code>) I found out, that the exclude is no wildcard pattern matching and only a startsWith matching:</p>
<pre class="brush: java;">
for (String excludePattern:excludePatterns){
    if (uri.equals(excludePattern)||
            (excludePattern.endsWith(&quot;*&quot;)&amp;&amp;
                    excludePattern.substring(0,excludePattern.length()-1).
                            regionMatches(0,uri,0,excludePattern.length()-1))){
        processFilterChain(request, response, filterChain);
        return;
    }
}
</pre>
<p>So the correct way is with one asterisk:</p>
<pre class="brush: java;">
static excludes = [&quot;/images/*&quot;, &quot;/css/*&quot;]
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=101&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2009/12/15/error-in-grails-documentation-of-url-mapping-exclude/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>Testing your Hibernate Annotation Mapping</title>
		<link>http://devll.wordpress.com/2009/11/17/testing-your-hibernate-annotation-mapping/</link>
		<comments>http://devll.wordpress.com/2009/11/17/testing-your-hibernate-annotation-mapping/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 15:08:45 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Annotation]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Mapping]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=74</guid>
		<description><![CDATA[To test if I my mappings are correct, I use the following Java Application which uses SchemaExport. It gives me the SQL-statements and executes them against a database. To protect the production database, you can either set the second parameter of create() to false and/or change the connection string to a test database. configuration.setProperty(Environment.URL, "jdbc:mysql://localhost/test"); [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=74&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To test if I my mappings are correct, I use the following Java Application which uses <code>SchemaExport</code>. It gives me the SQL-statements and executes them against a database.<br />
To protect the production database, you can either set the second parameter of <code>create()</code> to <code>false</code> and/or change the connection string to a test database.<code><br />
configuration.setProperty(Environment.URL, "jdbc:mysql://localhost/test");<br />
</code></p>
<pre class="brush: java;">
package starter;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Environment;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class SchemaTester {

    public static void main(String[] args) throws ClassNotFoundException {
        AnnotationConfiguration configuration = new AnnotationConfiguration();

        List&lt;Class&gt; classes = findClasses(new File(&quot;src/domain&quot;), &quot;domain&quot;);
        for (Class clazz : classes) {
            configuration.addAnnotatedClass(clazz);
        }

        configuration.configure();
        configuration.setProperty(Environment.URL, &quot;jdbc:mysql://localhost/test&quot;);

        SchemaExport schemaExport = new SchemaExport(configuration);
        schemaExport.create(true, true);
        // schemaExport.execute(true, false, false, true); // to see just create statements
    }

    private static List&lt;Class&gt; findClasses(File directory, String packageName)
                                                                throws ClassNotFoundException  {
        List&lt;Class&gt; classes = new ArrayList&lt;Class&gt;();
        if (!directory.exists()) {
            return classes;
        }
        File[] files = directory.listFiles();
        for (File file : files) {
            System.out.println(file);
            if (file.isDirectory()) {
                if(!file.getName().contains(&quot;.&quot;)) {
                    classes.addAll(findClasses(file, packageName + &quot;.&quot; + file.getName()));
                }
            } else if (file.getName().endsWith(&quot;.java&quot;)) {
                String javaName = file.getName().substring(0, file.getName().length() - &quot;.java&quot;.length());
                classes.add(Class.forName(packageName + '.' + javaName));
            }
        }
        return classes;
    }
}
</pre>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/ch01.html">Chapter 1. Setting up an annotations project</a></li>
<li><a href="http://snippets.dzone.com/posts/show/4831">Get all classes within a package</a> </li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=74&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2009/11/17/testing-your-hibernate-annotation-mapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>Why does MySQL not write the log file?</title>
		<link>http://devll.wordpress.com/2009/10/27/why-does-mysql-not-write-the-log-file/</link>
		<comments>http://devll.wordpress.com/2009/10/27/why-does-mysql-not-write-the-log-file/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 11:57:02 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=46</guid>
		<description><![CDATA[I wanted to switch on the query log of MySQL. So I added the following to /etc/my.cnf [mysqld] log = /var/log/mysql.log and restarted the server: sudo /etc/init.d/mysql restart, but no log file occured even if I executed some queries. The Problem was that mysql had no rights for /var/log. So the solution was to create [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=46&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to switch on the query log of MySQL. So I added the following to <code>/etc/my.cnf</code></p>
<pre class="brush: plain;">
[mysqld]
log = /var/log/mysql.log
</pre>
<p>and restarted the server: <code>sudo /etc/init.d/mysql restart</code>, but no log file occured even if I executed some queries.</p>
<p>The Problem was that mysql had no rights for <code>/var/log</code>. So the solution was to create an own directory for mysql</p>
<pre class="brush: plain;">
cd /var/log
sudo mkdir mysql
sudo chown mysql:mysql mysql/
</pre>
<p> and log into it:</p>
<pre class="brush: plain;">
log = /var/log/mysql/mysql.log
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=46&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2009/10/27/why-does-mysql-not-write-the-log-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery iframe-ThickBox removes parameter</title>
		<link>http://devll.wordpress.com/2009/10/01/jquery-iframe-thickbox-removes-parameter/</link>
		<comments>http://devll.wordpress.com/2009/10/01/jquery-iframe-thickbox-removes-parameter/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 11:10:24 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[ThickBox]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=37</guid>
		<description><![CDATA[I had a iframe-ThickBox link with a strange behaviour: Clicking on it leads to an application error (because the id param was missing), copying the url in a new browser tab worked well. &#60;a href=&#34;/controller/action?TB_iframe=true&#38;height=500&#38;width=650&#38;id=123&#34;&#62;link&#60;/a&#62; What happened? jQuery-Thickbox removes all parameters after TB as mentioned in the description: Important to Remember: Add all other query [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=37&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had a <a href="http://jquery.com/demo/thickbox/#sectione-1">iframe-ThickBox link</a> with a strange behaviour: Clicking on it leads to an application error (because the id param was missing), copying the url in a new browser tab worked well.</p>
<pre class="brush: xml;">
&lt;a href=&quot;/controller/action?TB_iframe=true&amp;height=500&amp;width=650&amp;id=123&quot;&gt;link&lt;/a&gt;
</pre>
<p>What happened? jQuery-Thickbox removes all parameters after TB as mentioned in the description:<br />
<cite>Important to Remember:<br />
Add all other query parameters before the TB_iframe parameters. Everything after the &#8220;TB&#8221; is removed from the URL.</cite></p>
<p>So rearranging the order fixed the problem.</p>
<pre class="brush: xml;">
&lt;a href=&quot;/controller/action?id=123&amp;TB_iframe=true&amp;height=500&amp;width=650&quot;&gt;link&lt;/a&gt;
</pre>
<p>The real problem was not so obvious, because we use a link-Tag which transformed the URL in a map to add parameters and transformed it back to a URL. In that transformation the order got lost. We fixed that problem with a <code>LinkedHashMap</code> instead of <code>HashMap</code>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=37&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2009/10/01/jquery-iframe-thickbox-removes-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
		<item>
		<title>@Transactional not always works on methods</title>
		<link>http://devll.wordpress.com/2009/09/17/transactional-not-always-works-on-methods/</link>
		<comments>http://devll.wordpress.com/2009/09/17/transactional-not-always-works-on-methods/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 08:47:44 +0000</pubDate>
		<dc:creator>Martin Hofmann</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[Annotation]]></category>
		<category><![CDATA[Transaction]]></category>

		<guid isPermaLink="false">http://devll.wordpress.com/?p=22</guid>
		<description><![CDATA[Although I had annoted my method as @Transactional no transaction was started. Situation was the following: applicationContext.xml ... &#60;!-- Enable @Transactional support --&#62; &#60;tx:annotation-driven transaction-manager=&#34;transactionManager&#34; /&#62; ... Test.java class Test { public static void main(String args[]) throws Exception { ... Test test = factory.getBean(&#34;test&#34;); test.run(); } public void run() { // code before transaction runTransactional(); [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=22&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Although I had annoted my method as <code>@Transactional</code> no transaction was started. Situation was the following:</p>
<p><code><strong>applicationContext.xml</strong></code></p>
<pre class="brush: xml;">
...
&lt;!-- Enable @Transactional support --&gt;
&lt;tx:annotation-driven transaction-manager=&quot;transactionManager&quot; /&gt;
...
</pre>
<p><code><strong>Test.java</strong></code></p>
<pre class="brush: java;">
class Test {
    public static void main(String args[]) throws Exception {
        ...
        Test test = factory.getBean(&quot;test&quot;);
        test.run();
    }

    public void run() {
        // code before transaction
        runTransactional();
        // code after transaction
    }

    @Transactional
    public void runTransactional() {
        // code in transaction
    }
}
</pre>
<p>I found the reason in a little hint in the Spring Documenation (<a href="http://static.springsource.org/spring/docs/2.5.x/reference/transaction.html#transaction-declarative-annotations">Using @Transactional</a>):</p>
<blockquote><p>
<em>Note: In proxy mode (which is the default), only &#8216;external&#8217; method calls coming in through the proxy will be intercepted.</em>  This means that &#8216;self-invocation&#8217;, i.e. a method within the target object calling some other method of the target object, won&#8217;t lead to an actual transaction at runtime even if the invoked method is marked with <code>@Transactional</code>!
</p></blockquote>
<p>So the solution is either to use <code>aspectj</code> instead of <code>proxy</code>-mode or to make an &#8216;external&#8217; method call. I used the second. So I head to move the code from <code>run()</code> to <code>main()</code> so that I have an &#8216;external&#8217; method call to <code>runTransactional()</code>.</p>
<p><code><strong>Test.java</strong></code></p>
<pre class="brush: java;">
class Test {
    public static void main(String args[]) throws Exception {
        ...
        Test test = factory.getBean(&quot;test&quot;);
        // code before transaction
        test.runTransactional();
        // code after transaction
    }

    @Transactional
    public void runTransactional() {
        // code in transaction
    }
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/devll.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/devll.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/devll.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/devll.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/devll.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/devll.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/devll.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/devll.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devll.wordpress.com&amp;blog=9004767&amp;post=22&amp;subd=devll&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devll.wordpress.com/2009/09/17/transactional-not-always-works-on-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/f28671c830f948ac7cff1fd9786cf3b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">developerll</media:title>
		</media:content>
	</item>
	</channel>
</rss>
