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

<channel>
	<title>dow.ngra.de &#187; tips</title>
	<atom:link href="http://dow.ngra.de/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://dow.ngra.de</link>
	<description>no buzzwords allowed</description>
	<lastBuildDate>Sun, 22 Jan 2012 14:52:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>VisualVM and jps Not Finding my Java Process</title>
		<link>http://dow.ngra.de/2011/05/27/visualvm-and-jps-not-finding-my-java-process/</link>
		<comments>http://dow.ngra.de/2011/05/27/visualvm-and-jps-not-finding-my-java-process/#comments</comments>
		<pubDate>Fri, 27 May 2011 10:07:54 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[cool]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=1429</guid>
		<description><![CDATA[Today I was hit by a weird problem and I thought I&#8217;ll share the problem and the solution (thanks for the solution goes to my colleague Lauri). Googling did not help me much (probably bad keywords or not much information about it) and hopefully this post will serve as future destination for a solution for [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was hit by a weird problem and I thought I&#8217;ll share the problem and the solution (thanks for the solution goes to my colleague Lauri). Googling did not help me much (probably bad keywords or not much information about it) and hopefully this post will serve as future destination for a solution for this problem.</p>
<h2>Problem</h2>
<p>You are running Mac OS X (maybe the problem is relevant on other platforms too) and even if you&#8217;ve started Tomcat and you can see the Java process in the Activity Monitor or with <code>ps</code> you <strong>can&#8217;t</strong> see the process with <code>jps</code>. You <strong>are not</strong> able to connect to the process with VisualVM nor JConsole. Bummer.<br />
<span id="more-1429"></span></p>
<h2>Solution</h2>
<p>Tomcat scripts have a variable called CATALINA_TMPDIR and the java process is forked with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">-Djava.io.tmpdir=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$CATALINA_TMPDIR</span>&quot;</span></pre></div></div>

<p> What happens is that jps and VisualVM/JConsole look for information about processes from the system TMP folder. Once you redefine this they cannot find their information. The solution is to eliminate this variable from the process.</p>
<p>Either execute the commandline that you can copy and paste from</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ps</span> aux <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> tomcat</pre></div></div>

<p> and exclude the -Djava.io.tmpdir part or modify the script for your debug session. Thats it.</p>
<p>You&#8217;re welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2011/05/27/visualvm-and-jps-not-finding-my-java-process/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WP Super Cache and 0 Byte Downloads</title>
		<link>http://dow.ngra.de/2010/10/28/wp-super-cache-and-0-byte-downloads/</link>
		<comments>http://dow.ngra.de/2010/10/28/wp-super-cache-and-0-byte-downloads/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 07:14:52 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=1314</guid>
		<description><![CDATA[You&#8217;re using WP Super Cache on your WordPress site and some of your downloads end up 0 bytes? Check your Apache log to see if you&#8217;re running out of memory. Look for a line similar to: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted &#40;tried to allocate 34953465 bytes&#41; in /var/www/yourwebsite.com/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re using <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> on your <a href="http://wordpress.org/">WordPress</a> site and some of your downloads end up 0 bytes? Check your Apache log to see if you&#8217;re running out of memory. Look for a line similar to:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">PHP Fatal error<span style="color: #339933;">:</span>  Allowed memory size of <span style="color: #cc66cc;">134217728</span> bytes exhausted <span style="color: #009900;">&#40;</span>tried to allocate <span style="color: #cc66cc;">34953465</span> bytes<span style="color: #009900;">&#41;</span> in <span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>www<span style="color: #339933;">/</span>yourwebsite.<span style="color: #006633;">com</span><span style="color: #339933;">/</span>public_html<span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>content<span style="color: #339933;">/</span>plugins<span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>super<span style="color: #339933;">-</span>cache<span style="color: #339933;">/</span>wp<span style="color: #339933;">-</span>cache<span style="color: #339933;">-</span>phase2.<span style="color: #006633;">php</span> on line <span style="color: #cc66cc;">286</span></pre></div></div>

<p>The reason is that WP Super Cache is doing its best to save your server from some load and the entry point for most of the requests is actually a PHP file from the WP Super Cache. Check your .htaccess file for more details. That script tries to cache your download file which might not fit into your memory limit. Download files are anyways static (unless you add some binary cookies, which you&#8217;re probably not) and don&#8217;t need another layer of caching.</p>
<h3>Solution</h3>
<p>In WP Super Cache options locate &#8220;Accepted Filenames &#038; Rejected URIs&#8221; section and add some extensions there. In this example I&#8217;ve added zip jar and exe. Mind the syntax.</p>
<p><a href="http://dow.ngra.de/wp-content/uploads/2010/10/wpsupercacheSettings.png"><img src="http://dow.ngra.de/wp-content/uploads/2010/10/wpsupercacheSettings-300x66.png" alt="" title="WP Super Cache Settings" width="300" height="66" class="aligncenter size-medium wp-image-1315" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2010/10/28/wp-super-cache-and-0-byte-downloads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to waste couple of hours with the Play! Framework</title>
		<link>http://dow.ngra.de/2010/10/26/how-to-waste-couple-of-hours-with-the-play-framework/</link>
		<comments>http://dow.ngra.de/2010/10/26/how-to-waste-couple-of-hours-with-the-play-framework/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 12:33:02 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[rant]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=1298</guid>
		<description><![CDATA[Quick rant (downgrade) of the Play! Framework, just wasted another hour trying to find out why my configuration is not applied. This is the second time this month so I need to let out some steam. Generally I&#8217;m a big fan of Play! It is easy to use, easy to setup and fast to develop [...]]]></description>
			<content:encoded><![CDATA[<p><em>Quick rant (downgrade) of the <a href="http://www.playframework.org/">Play! Framework</a>, just wasted another hour trying to find out why my configuration is not applied. This is the second time this month so I need to let out some steam.</em></p>
<p>Generally I&#8217;m a big fan of Play! It is easy to use, easy to setup and fast to develop with. Its like Struts with JRebel but feels more fresh. Okay, back to the rant.</p>
<blockquote><p>
Lets say you want to make sure that each time you run your application, the HSQLDB is initialized into the same location.
</p></blockquote>
<p>Well, you go to <code>application.conf</code>. Find the <code>db.url</code> field, comment it in, change it to</p>

<div class="wp_syntax"><div class="code"><pre class="ant" style="font-family:monospace;">db.url=jdbc:hsqldb:file:my/fav/static/location</pre></div></div>

<p> Done! 10 minutes you notice that</p>

<div class="wp_syntax"><div class="code"><pre class="ant" style="font-family:monospace;">/private/var/folders/Em/EmtX3-Q+EgOCv9GUy0k8dU+++TI/-Tmp-/Jetty_0_0_0_0_8080_webapp____.7fbo9s/webapp/WEB-INF/application/db/db</pre></div></div>

<p> is used as the DB location. After grepping, doublechecking, debugging and swearing you find in the internals of play that db.url, db.pass, db.user, db.driver are ignored if <code>db=fs</code> is set. WTF? No warning, no nothing that your configuration gets overwritten, aaargh!</p>
<blockquote><p>
Lets say your deployment is not Play! (they advise you to use <code>play run</code> to run apps written using Play! instead of a classic servlet container). Lets say you target Jetty instead.
</p></blockquote>
<p>Well, you deploy your WAR archive to Jetty and develop as you would before but then you discover that your files are no longer reloaded. You also discover that you get tons of database exceptions. After grepping, doublechecking, debuggin and swearing you find in the internals of play that once you ditch the <code>play run</code> and move to a classic container Play! will presume that you must have been smoking crack when you wrote <code>application.mode=dev</code> in your configuration file. It will just override it and make sure that you run in production mode this time. WTF? No warning, no nothing that your configuration gets overwritten, aaargh.</p>
<p>So next time you&#8217;re having problems with Play!, do some grepping, doublechecking, debuggin and swearing and find the location where your configuration options are overwritten by some Java code inside play.jar.</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2010/10/26/how-to-waste-couple-of-hours-with-the-play-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Somebody is stealing my website design &#8211; what are my options?</title>
		<link>http://dow.ngra.de/2010/04/23/somebody-is-stealing-my-website-design-what-are-my-options/</link>
		<comments>http://dow.ngra.de/2010/04/23/somebody-is-stealing-my-website-design-what-are-my-options/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 07:48:14 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[opinion]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=1219</guid>
		<description><![CDATA[The authors of this blog also run a software company called ZeroTurnaround. We monitor the mentions of the company name and its products with different tools. I personally use Google Alerts (you get an email when the interwebz mentions your monitored word). One day we stumbled upon a page that had stolen our website design. [...]]]></description>
			<content:encoded><![CDATA[<p>The authors of this blog also run a software company called <a href="http://www.zeroturnaround.com/">ZeroTurnaround</a>. We monitor the mentions of the company name and its products with different tools. I personally use <a href="http://www.google.com/alerts">Google Alerts</a> (you get an email when the interwebz mentions your monitored word).</p>
<p>One day we stumbled upon a page that had stolen our website design. It was not a question if they had borrowed ideas from us but they had literally stolen everything. The html, css, images and even had our logo up! Our website is <a href="http://www.zeroturnaround.com">zeroturnaround.com</a> and their, <a href="http://www.jbrute.info">jbrute.info</a> (the one which <b>stole</b> the design).</p>
<p><a href="http://dow.ngra.de/wp-content/uploads/2010/04/jbrute.info_.png"><img src="http://dow.ngra.de/wp-content/uploads/2010/04/jbrute.info_-150x150.png" alt="" title="JBrute 1st version" width="150" height="150" class="alignleft size-thumbnail wp-image-1223" /></a>My first reaction was that I&#8217;ll just drop them an email, make sure that they&#8217;re aware that it is a crime (is it?) and order them to take it down and problem solved. We have no interest of suing anybody. Maybe they were just playing around. Here is a picture how it looked at that time.</p>
<p>The plan was easy but getting contact information was not. At least they had taken down our contact information from the footer. Not finding even an email (then again, smart move, too many stories of criminals accidently leaving their card at the scene of the crime) from the webpage I turned to DNS whois. Whois records show</p>
<blockquote><p>
Domain ID:D32012015-LRMS<br />
Domain Name:JBRUTE.INFO<br />
Created On:24-Mar-2010 20:00:01 UTC<br />
Last Updated On:24-Mar-2010 20:15:33 UTC<br />
Expiration Date:24-Mar-2011 20:00:01 UTC<br />
Sponsoring Registrar:GoDaddy.com Inc. (R171-LRMS)<br />
Status:TRANSFER PROHIBITED<br />
Registrant ID:CR44517482<br />
Registrant Name:Conor Ryan<br />
Registrant Organization:Warlock 999 Development<br />
Registrant Street1:One Vernon Drive<br />
Registrant City:Vernon<br />
Registrant State/Province:New Jersey<br />
Registrant Postal Code:07976<br />
Registrant Country:US<br />
Registrant Phone:+1.5555555555<br />
Registrant *************@warlock999.info
</p></blockquote>
<p><a href="http://dow.ngra.de/wp-content/uploads/2010/04/jbrute.info-ver2.png"><img src="http://dow.ngra.de/wp-content/uploads/2010/04/jbrute.info-ver2-150x150.png" alt="" title="JBrute new version" width="150" height="150" class="alignleft size-thumbnail wp-image-1230" /></a>All emails sent to warlock.info or jbrute.info bounce. Googling the name and address does not bring much up. It&#8217;s like a dead end. I&#8217;ve also contacted the registrar and hosting, still waiting for replies. They&#8217;ve updated their website design today, removed the video, our logo and put up some text.</p>
<p>What are my options to deal with something like this? Proving that the design belongs to us should be easy (the html is too similar). How should I go about documenting this? I did make a screenshot when I first stumbled upon, but you could always say that I&#8217;m good in Photoshop.</p>
<p>Are there other options to contact a domain name owner besides information from website and WHOIS?</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2010/04/23/somebody-is-stealing-my-website-design-what-are-my-options/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Bleeding edge of development &#8211; upgrading system and ANT stops working</title>
		<link>http://dow.ngra.de/2009/12/28/bleeding-edge-of-development-upgrading-system-and-ant-stops-working/</link>
		<comments>http://dow.ngra.de/2009/12/28/bleeding-edge-of-development-upgrading-system-and-ant-stops-working/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 14:32:15 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[tips]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=1185</guid>
		<description><![CDATA[I run Debian Unstable as my main desktop system. I shoot myself in the foot couple of times a year with the upgrades but I like using the bleeding edge of development. Today after my &#8220;regular&#8221; upgrade I noticed that one of the ANT tasks did not perform as I would have expected. /home/toomasr/workspace/project/build.xml:459: The [...]]]></description>
			<content:encoded><![CDATA[<p>I run Debian <a href="http://www.debian.org/releases/unstable/">Unstable</a> as my main desktop system. I shoot myself in the foot couple of times a year with the upgrades but I like using the bleeding edge of development.</p>
<p>Today after my &#8220;regular&#8221; upgrade I noticed that one of the ANT tasks did not perform as I would have expected.</p>

<div class="wp_syntax"><div class="code"><pre class="ant" style="font-family:monospace;">/home/toomasr/workspace/project/build.xml:459: The following error occurred while executing this line:
/home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml</pre></div></div>

<p>A quick <code>ant -debug</code> did not help me much.</p>

<div class="wp_syntax"><div class="code"><pre class="ant" style="font-family:monospace;">/home/toomasr/workspace/project/build.xml:459: The following error occurred while executing this line:
/home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml                                                                                                                                       
        at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:508)                                                                                   
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:369)                                                                                                                  
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)                                                                                                     
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                                                              
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)                                                                                            
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)                                                                                    
        at java.lang.reflect.Method.invoke(Method.java:597)                                                                                                                         
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)                                                                                              
        at org.apache.tools.ant.Task.perform(Task.java:348)                                                                                                                         
        at org.apache.tools.ant.Target.execute(Target.java:357)                                                                                                                     
        at org.apache.tools.ant.Target.performTasks(Target.java:385)                                                                                                                
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: /home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml
        at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:142)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
        at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:367)
        ... 17 more
--- Nested Exception ---
/home/toomasr/workspace/project/changelogic-build.xml:72: Please check the correctness of the root url property. The server returned HTTP response code 300 or above for the URL http://172.17.57.242/lib/changelogic-build.xml
        at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:142)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
        at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:367)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
&nbsp;
Total time: 3 seconds</pre></div></div>

<p>The access log on the server did not show anything for the request. Browsing to the url with FireFox worked just fine. Where to even start debugging this? The simple <code>env</code> did not show any proxies configured either. Quite lost.</p>
<p>At last I decided to trace the problem with <a href="http://en.wikipedia.org/wiki/Strace">strace</a>. <code>strace -f ant my_target > result 2>&#038;1</code> produced 35 892 lines of output. Searching for the ip showed me the message</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">35596</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>pid <span style="color: #000000;">13544</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> connect<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">46</span>, <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #007800;">sa_family</span>=AF_INET6, <span style="color: #007800;">sin6_port</span>=htons<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">80</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, inet_pton<span style="color: #7a0874; font-weight: bold;">&#40;</span>AF_INET6, <span style="color: #ff0000;">&quot;::ffff:172.17.57.242&quot;</span>, <span style="color: #000000; font-weight: bold;">&amp;</span>sin6_addr<span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #007800;">sin6_flowinfo</span>=<span style="color: #000000;">0</span>, <span style="color: #007800;">sin6_scope_id</span>=<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>, <span style="color: #000000;">28</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> = <span style="color: #660033;">-1</span> ENETUNR      EACH <span style="color: #7a0874; font-weight: bold;">&#40;</span>Network is unreachable<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Weehah, I&#8217;m getting somewhere! Googling a bit showed me <a href="http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/ced099cf65123551">multiple</a> <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560142">solutions</a>. Either a system wide <code>sysctl -w net.ipv6.bindv6only=0</code> or just <code>-Djava.net.preferIPv4Stack=true</code> will do the trick. I hope this helps somebody.</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2009/12/28/bleeding-edge-of-development-upgrading-system-and-ant-stops-working/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hacking with IDE plugins &#8211; fun art of binary patching</title>
		<link>http://dow.ngra.de/2009/12/11/hacking-with-ide-plugins-fun-art-of-binary-patching/</link>
		<comments>http://dow.ngra.de/2009/12/11/hacking-with-ide-plugins-fun-art-of-binary-patching/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 15:34:26 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[cool]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Java Virtual Machine]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[patching]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=1158</guid>
		<description><![CDATA[Today&#8217;s software is so much about integration. You can have a cool Java utility but if you don&#8217;t have an Eclipse plugin for that, a large % of Eclipse users won&#8217;t adopt (IDEA &#38; NetBeans users require plugins just as much). In the consumer market the same goes for browser extensions and iPhone apps that [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s software is so much about integration. You can have a cool Java utility but if you don&#8217;t have an Eclipse plugin for that, a large % of Eclipse users won&#8217;t adopt (IDEA &amp; NetBeans users require plugins just as much).  In the consumer market the same goes for browser extensions and iPhone apps that support the main service with better accessibility.</p>
<p>There are different ways for integration. Usually it is done via an <a href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a>. The host platform offers some hooks into the system and you can use them to add some custom functionality on top of the host (or maybe just integrate your own product with the host). The result of this in the IDE world is a <b>plugin</b>. <a href="http://www.jrebel.com">JRebel</a> (the product our team is spending the most development time on) has plugins for application servers, frameworks and even IDEs.</p>
<p>If you&#8217;re in luck you can achieve everything with the API, if not you need other tricks. If the API does not offer certain public methods or access to some internal fields you can go in with <a href="http://en.wikipedia.org/wiki/Reflection_%28computer_science%29">reflection</a> and still use them (of course there are no guarantees if the internals stay the same on version changes).</p>
<p>One step further to the darkside is binary patching. By binary patching I mean adding/changing/removing methods/fields/classes in runtime. This is the approach that we had to take when writing the JRebel <a href="http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=22254">NetBeans plugin</a>.</p>
<p>On NetBeans startup we lookup a debugger class and on success try to patch it. In 2009 and using the JVM (not native apps) it is quite an easy task, at least for the most part. No assembler involved (of course you could be using a bytecode generation library), no need to do jumps to correct offsets or even read assembler (or bytecode).</p>
<p>In our case we use the <a href="http://en.wikipedia.org/wiki/Javassist">Javassist</a> library. It is a matter of inserting Java code embedded into a String to methods looked up via reflection. For example the following code adds some new code into the beginning of a method.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">ctc.<span style="color: #006633;">getDeclaredMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;setRequests&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">insertAfter</span><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">&quot;org.netbeans.api.debugger.jpda.LineBreakpoint _breakpoint = getBreakpoint();&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;java.lang.String _className = _breakpoint.getPreferredClassName();&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;if (_className == null) {&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;  _className = reader.findCachedClassName(_breakpoint);&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;  if (_className == null) {&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;    _className = org.netbeans.modules.debugger.jpda.EditorContextBridge.getContext().getClassName (&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;      _breakpoint.getURL (),&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;      lineNumber);&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;    if (_className != null &amp;amp;&amp;amp; _className.length() &amp;gt; 0) {&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;      reader.storeCachedClassName(_breakpoint, _className);&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;    }&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;  }&quot;</span> <span style="color: #339933;">+</span>
  <span style="color: #0000ff;">&quot;}&quot;</span></pre></div></div>

<p>For the complete source code of the patch see the src folder of the <a href="http://repos.zeroturnaround.com/svn/jr-ide-support/nb-plugin/">nb-plugin</a>.</p>
<p>In conclusion, the best way to integrate with any system is via the API it provides. If it does not cut it then look into reflection and start using internals. You will lose on maintainability of course. Still not happy? Look into binary patching and have your fingers crossed whenever the target platform releases a new version.</p>
<div style="margin-top: 10px; height: 15px;" class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/ab7f8433-9fe0-4f91-bee1-521e253034c3/" title="Reblog this post [with Zemanta]"><img style="border: medium none ; float: right;" class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=ab7f8433-9fe0-4f91-bee1-521e253034c3" alt="Reblog this post [with Zemanta]"></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2009/12/11/hacking-with-ide-plugins-fun-art-of-binary-patching/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Waiting for GMail themes? Log out and log back in</title>
		<link>http://dow.ngra.de/2008/11/21/waiting-for-gmail-themes-log-out-and-log-back-in/</link>
		<comments>http://dow.ngra.de/2008/11/21/waiting-for-gmail-themes-log-out-and-log-back-in/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 23:40:28 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=475</guid>
		<description><![CDATA[I was waiting for the Gmail themes tab to appear on the settings page but it never did. I run Gmail under Prism and I hardly ever log out. Once I did do that and logged back in I finally got the themes tabs. Running terminal right now, nooooot.]]></description>
			<content:encoded><![CDATA[<p>I was waiting for the Gmail themes tab to appear on the settings page but it never did. I run Gmail under <a href="https://wiki.mozilla.org/Prism">Prism</a> and I hardly ever log out. Once I did do that and logged back in I finally got the themes tabs. Running terminal right now, nooooot.</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2008/11/21/waiting-for-gmail-themes-log-out-and-log-back-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to waste 3GB of traffic on 404 pages</title>
		<link>http://dow.ngra.de/2008/11/06/how-to-waste-3gb-of-traffic-on-404-pages/</link>
		<comments>http://dow.ngra.de/2008/11/06/how-to-waste-3gb-of-traffic-on-404-pages/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 16:25:13 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=450</guid>
		<description><![CDATA[The previous post on dow.ngra.de generated tons of traffic. That tons of traffic generated 120 000 requests to a style sheet file that did not exist. WordPress will display a semi fancy page for 404 files that weighs about 25 KB. 25 KB times 120 000 is 3 000 000 KB :). Actually the same [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://dow.ngra.de/2008/11/04/script-kiddies-have-awesome-tools/">previous post</a> on dow.ngra.de generated tons of traffic. That tons of traffic generated 120 000 requests to a style sheet file that did not exist. WordPress will display a semi fancy page for 404 files that weighs about 25 KB. 25 KB times 120 000 is 3 000 000 KB :).</p>
<p>Actually the same happened to favicon.ico and a few others. So either have your referred files and favicon.ico on your server or rework WordPress mod_rewrite configuration not to handle css/js/ico/png/gif/jpg files. This will save you money!</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2008/11/06/how-to-waste-3gb-of-traffic-on-404-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux, Windows and exit codes &#8211; the debug story</title>
		<link>http://dow.ngra.de/2008/10/22/linux-windows-and-exit-codes-the-debug-story/</link>
		<comments>http://dow.ngra.de/2008/10/22/linux-windows-and-exit-codes-the-debug-story/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 18:07:54 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=343</guid>
		<description><![CDATA[While running a test framework I was very pleased to see all the tests pass. The problem was that I was the only one that lucky. The logic of the framework is quite simple, ANT build.xml starts up, runs a test as a separate java task, gathers the result code and tests for equality of [...]]]></description>
			<content:encoded><![CDATA[<p>While running a test framework I was very pleased to see all the tests pass. The problem was that I was the <strong>only</strong> one that lucky.</p>
<p>The logic of the framework is quite simple, ANT build.xml starts up, runs a test as a separate java task, gathers the result code and tests for equality of -1. The test was failing for no reason.</p>
<p>Checking the source code of the java task it was obvious that it was returning -1. Quick grep and a debugger session showed that ANT was not mangling the return code. So System.exit(-1) was returning 255. System.exit(42) then again returned 42.</p>
<p>Quick google shows that this is how it is supposed to work. Quoting from <a href="http://steve-parker.org/sh/exitcodes.shtml">steve-parker.org</a></p>
<blockquote><p>
Exit codes are a number between 0 and 256, which is returned by any Unix command when it returns control to its parent process. Other numbers can be used, but these are treated modulo 256, so exit -10 is equivalent to exit 246, and exit 257 is equivalent to exit 1.
</p></blockquote>
<p>And then we have Windows where -1 is a valid exit code (well, at least it works). Something to remember when have to exit on multiple platforms.</p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2008/10/22/linux-windows-and-exit-codes-the-debug-story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and microbenchmarks</title>
		<link>http://dow.ngra.de/2008/08/01/php-and-microbenchmarks/</link>
		<comments>http://dow.ngra.de/2008/08/01/php-and-microbenchmarks/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 01:40:30 +0000</pubDate>
		<dc:creator>Toomas Römer</dc:creator>
				<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dow.ngra.de/?p=131</guid>
		<description><![CDATA[Microbenchmarks always have to be taken with a grain of salt. I do know that but I happened to stumble upon a PHP optimization tip <a href="http://hudzilla.org/phpwiki/index.php?title=Avoid_overusing_function_calls">Avoid overusing function calls</a>.]]></description>
			<content:encoded><![CDATA[<p>Microbenchmarks always have to be taken with a grain of salt. I do know that but I happened to stumble upon a PHP optimization tip <a href="http://hudzilla.org/phpwiki/index.php?title=Avoid_overusing_function_calls">Avoid overusing function calls</a>.</p>
<p>The test is fairly simple. 4 million iterations of <code>$j = 1</code> and 4 million iterations of <code>some_func()</code>, a function wrapping the same <code>$j = 1</code>.</p>
<p>The results? Function calls are so expensive that inlined version takes <b>2</b> seconds to execute and invoking the function takes <b>16</b>. 8 time difference, whoah!</p>
<p><i>The test environment: PHP 5.2.6-2+b1 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 22 2008 21:03:43) running on a P4@3ghz</i></p>
]]></content:encoded>
			<wfw:commentRss>http://dow.ngra.de/2008/08/01/php-and-microbenchmarks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

