<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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" version="2.0">

<channel>
	<title>OutOfMemory</title>
	
	<link>http://www.gregheidorn.com/wordpress</link>
	<description>Writing helps me remember!</description>
	<pubDate>Thu, 09 Jul 2009 22:10:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/outofmemory" type="application/rss+xml" /><item>
		<title>Formatting Dates Provided Via Twitter API</title>
		<link>http://www.gregheidorn.com/wordpress/2009/07/08/formatting-dates-provided-via-twitter-api/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/07/08/formatting-dates-provided-via-twitter-api/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 00:06:36 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Cocoa]]></category>

		<category><![CDATA[Objective-C]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[NSDateFormatter]]></category>

		<category><![CDATA[Twitter API]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=108</guid>
		<description><![CDATA[I was testing the Twitter API with an iPhone application and got stuck trying to format the timestamp of the statuses I was displaying.  From reading the Data Formatting Programming Guide for Cocoa I knew what to do, but I didn&#8217;t have the timestamp pattern handy.  So I took the example date from [...]]]></description>
			<content:encoded><![CDATA[<p>I was testing the Twitter API with an iPhone application and got stuck trying to format the timestamp of the statuses I was displaying.  From reading the <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369">Data Formatting Programming Guide for Cocoa</a> I knew what to do, but I didn&#8217;t have the timestamp pattern handy.  So I took the example date from the <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-user_timeline">Twitter API sample for user timelines</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;">Tue Apr <span style="color: #208080;">07</span> <span style="color: #0000dd;">22</span><span style="color: #339933;">:</span><span style="color: #0000dd;">52</span><span style="color: #339933;">:</span><span style="color: #0000dd;">51</span> <span style="color: #339933;">+</span><span style="color: #208080;">0000</span> <span style="color: #0000dd;">2009</span></pre></div></div>

<p>&#8230; and applied the <a href="http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns">Unicode guide to date format patterns</a> to come up with the format:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;">E MMM dd k<span style="color: #339933;">:</span>mm<span style="color: #339933;">:</span>ss Z yyyy</pre></div></div>

<p>Once I had the pattern, it was as simple as setting it onto a <code>NSDateFormatter</code> instance and using its API.</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;">NSDateFormatter <span style="color: #339933;">*</span>inputFormatter <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSDateFormatter alloc<span style="color: #009900;">&#93;</span> init<span style="color: #009900;">&#93;</span>;
<span style="color: #009900;">&#91;</span>inputFormatter setDateFormat<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;E MMM dd k:mm:ss Z yyyy&quot;</span><span style="color: #009900;">&#93;</span>;
NSDate <span style="color: #339933;">*</span>date <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>inputFormatter dateFromString<span style="color: #339933;">:</span>twitterTimestamp<span style="color: #009900;">&#93;</span>;
NSDateFormatter <span style="color: #339933;">*</span>outputFormatter <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>NSDateFormatter alloc<span style="color: #009900;">&#93;</span> init<span style="color: #009900;">&#93;</span>;
<span style="color: #009900;">&#91;</span>outputFormatter setDateFormat<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;M/d @ HH:mm&quot;</span><span style="color: #009900;">&#93;</span>;
NSString <span style="color: #339933;">*</span>formattedDate <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>outputFormatter stringFromDate<span style="color: #339933;">:</span>date<span style="color: #009900;">&#93;</span>;</pre></div></div>

<p>Hope this helps someone save a bit of time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/07/08/formatting-dates-provided-via-twitter-api/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Troubleshooting Tomcat/Spring Start-up Issues</title>
		<link>http://www.gregheidorn.com/wordpress/2009/06/06/troubleshooting-tomcatspring-start-up-issues/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/06/06/troubleshooting-tomcatspring-start-up-issues/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 20:58:47 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Eclipse]]></category>

		<category><![CDATA[Spring Framework]]></category>

		<category><![CDATA[Tomcat]]></category>

		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=99</guid>
		<description><![CDATA[I was working on a Spring project this morning and while I was re-writing my build script I ended up leaving out some key libraries during WAR builds.  When the application was deployed to Tomcat, I tried to start it up using the Tomcat admin manager and received an error regarding my application&#8217;s context [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on a Spring project this morning and while I was re-writing my build script I ended up leaving out some key libraries during WAR builds.  When the application was deployed to Tomcat, I tried to start it up using the Tomcat admin manager and received an error regarding my application&#8217;s context being invalid.  The server logs weren&#8217;t much help as there was merely a single line stating:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">SEVERE<span style="color: #339933;">:</span>  <span style="color: #003399;">Error</span> listnerStart</pre></div></div>

<p>After some GoogleFu, I found a <a href="http://forum.springsource.org/showthread.php?t=27967">thread on the SpringSource forums</a> with a great tip on where to debug the application to find the issue.  Dropping a break point in the <code>ContextLoaderListener</code> where you see:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">contextLoader</span>.<span style="color: #006633;">initWebApplicationContext</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Start your application using Tomcat&#8217;s admin manager and your break point will catch this line.  Allow one Step Return and view the &#8216;t&#8217; variable in your runtime variables (upper right-hand corner).  You&#8217;ll see the offending exception.</p>
<p>This listener class is acting as the bootstrap to start up the Spring container, so when this call fires, it rips through all the XML and builds your beans, etc.  This is why applications die before they start &#8230; any exception thrown during the bootstrap or bean creation phases will kill the application.</p>
<p>Thanks to SpringSource forum user &#8220;adam_jh&#8221;!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/06/06/troubleshooting-tomcatspring-start-up-issues/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Baby Born; Boxscore Junkie Updated</title>
		<link>http://www.gregheidorn.com/wordpress/2009/05/05/baby-born-boxscore-junkie-updated/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/05/05/baby-born-boxscore-junkie-updated/#comments</comments>
		<pubDate>Tue, 05 May 2009 06:12:58 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Google App Engine]]></category>

		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[Boxscore Junkie]]></category>

		<category><![CDATA[GAE]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=94</guid>
		<description><![CDATA[Owen Augustus was born on 4/20 @ 8:15pm!  He and Kristin are doing great &#8230; I couldn&#8217;t be more proud of my family.
As for my side projects, my iPhone application was nearly completed when I read about Blizzard sending cease &#38; desist letters to all active iPhone application authors who have done any work [...]]]></description>
			<content:encoded><![CDATA[<p>Owen Augustus was born on 4/20 @ 8:15pm!  He and Kristin are doing great &#8230; I couldn&#8217;t be more proud of my family.</p>
<p>As for my side projects, my iPhone application was nearly completed when I read about Blizzard sending cease &amp; desist letters to all active iPhone application authors who have done any work on their game-related property.  So much for tackling that niche community&#8230;oh well, it was a good learning experience.</p>
<p>On the web front, I spent some time during my paternity leave working on some design tweaks for my MLB boxscore website (<a href="http://boxscore-junkie.appspot.com">Boxscore Junkie</a>).  Still have a lot of ideas for it but I am also working on new iPhone application ideas so my time will be split once again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/05/05/baby-born-boxscore-junkie-updated/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java On Google App Engine, Stanford iPhone Class</title>
		<link>http://www.gregheidorn.com/wordpress/2009/04/08/java-on-google-app-engine-stanford-iphone-class/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/04/08/java-on-google-app-engine-stanford-iphone-class/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 22:34:23 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Google App Engine]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[GAE]]></category>

		<category><![CDATA[iPhone]]></category>

		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=88</guid>
		<description><![CDATA[Two bits of news today:

It&#8217;s here!  Java is now officially supported on GAE.  Exciting news and I&#8217;m ready to finally spend the time learning the datastore now.  Learn more from the source.
Standford is posting their iPhone Development course free online via iTunes.  Follow along at the course website.

There&#8217;s never enough time in the day, is [...]]]></description>
			<content:encoded><![CDATA[<p>Two bits of news today:</p>
<ol>
<li>It&#8217;s here!  Java is now officially supported on GAE.  Exciting news and I&#8217;m ready to finally spend the time learning the datastore now.  Learn more from the <a href="http://code.google.com/appengine/docs/java/overview.html">source</a>.</li>
<li>Standford is posting their iPhone Development course free online via iTunes.  Follow along at the <a href="http://www.stanford.edu/class/cs193p/cgi-bin/index.php">course website</a>.</li>
</ol>
<p>There&#8217;s never enough time in the day, is there?  So many things to learn&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/04/08/java-on-google-app-engine-stanford-iphone-class/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IBM Buying Sun?</title>
		<link>http://www.gregheidorn.com/wordpress/2009/03/19/ibm-buying-sun/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/03/19/ibm-buying-sun/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:01:37 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Miscellaneous]]></category>

		<category><![CDATA[WebSphere]]></category>

		<category><![CDATA[Eclipse]]></category>

		<category><![CDATA[Glassfish]]></category>

		<category><![CDATA[IBM]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[NetBeans]]></category>

		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=86</guid>
		<description><![CDATA[NYTimes.com has a story on IBM preparing to purchase Sun Microsystems for about $10 a share.  There are no confirmations from top executives, but Gartner&#8217;s analysis makes sense.
“The technologies of greatest interest to I.B.M. are Java and Solaris, and those are notably not hardware technologies,” said David M. Smith, an analyst at Gartner.
As a Java [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.nytimes.com/2009/03/19/technology/companies/19sun.html?_r=1&amp;ref=technology">NYTimes.com</a> has a story on IBM preparing to purchase Sun Microsystems for about $10 a share.  There are no confirmations from top executives, but Gartner&#8217;s analysis makes sense.</p>
<blockquote><p>“The technologies of greatest interest to I.B.M. are Java and Solaris, and those are notably not hardware technologies,” said David M. Smith, an analyst at Gartner.</p></blockquote>
<p>As a Java engineer, there are a couple of things that hit me right away.  What would this mean for the NetBeans and Eclipse?  They are completely separate IDEs with various pluses and minuses.  Personally, I like Eclipse for almost all web development thanks to open source plug-ins for PHP, Python, HTML/CSS/JavaScript.  Rich-Client Platform development is also a value-add Eclipse brings to the table as many companies are building RCP suites with reuseable components that operate both online and offline.  Where NetBeans excels (in my short experience with the product) is in their GUI editor for Swing development.  Any developer who has written AWT/Swing code can probably attest to the convenience of the drag-and-drop palettes opposed to prgrammatically aligning your GridBagLayout containter within a FlowLayout JFrame&#8230;but I digress.</p>
<p>Secondly, what will happen to Glassfish in the face of WebSphere?  Would IBM try to consolidate?  Would they let the Sun developers and researchers continue their work with the free application server?</p>
<p>As an infrastructure engineer, you need to ask the long-term question of why would IBM support Solaris when it is heavily into other flavors of Unix?  Currently it is competitive business between the two entities Sun and IBM.  But if they were to be owned by the same parent, would it be fiscally prudent to continue to develop both paths?  I can&#8217;t imagine it would be, which would reduce the rate at which we grow these technologies (given that competition is the greatest motivation for innovation).  Granted, there&#8217;s a lot of customers out there who will be impacted and a lot of contracts on the books for years to come that would prevent IBM from potentially shutting down the Solaris side of things.  Or maybe IBM moves their Linux resources into the Solaris space?  Interesting to ponder.</p>
<p>I&#8217;ve probably raised a lot of fantasy questions here, but it&#8217;s worth pondering.  The NYTimes article talks about IBM/Sun building a Java front against Microsoft&#8230;well&#8230;that would certainly be a formidable company for sure and would most likely ensure that Java stays at the forefront of software technologies for the next decade or two at least.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/03/19/ibm-buying-sun/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Cocoa and Objective-C</title>
		<link>http://www.gregheidorn.com/wordpress/2009/02/19/cocoa-and-objective-c/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/02/19/cocoa-and-objective-c/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 07:19:29 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Cocoa]]></category>

		<category><![CDATA[Objective-C]]></category>

		<category><![CDATA[Leopard]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=84</guid>
		<description><![CDATA[Been awhile since I posted, so I figure I&#8217;d chime in about the MacBook I bought at the end of January.
After getting used to way the deskop and applications interact, it&#8217;s pretty smooth to get around.  I really love the Command+Space Spotlight shortcut&#8230;Windows needs this feature in their next OS.  Finder is pretty solid, though [...]]]></description>
			<content:encoded><![CDATA[<p>Been awhile since I posted, so I figure I&#8217;d chime in about the MacBook I bought at the end of January.</p>
<p>After getting used to way the deskop and applications interact, it&#8217;s pretty smooth to get around.  I really love the Command+Space Spotlight shortcut&#8230;Windows needs this feature in their next OS.  Finder is pretty solid, though I&#8217;ve yet to figure out why sometimes I can see files in Finder and sometimes I can&#8217;t, or, sometimes I&#8217;ll see them on the file system using Terminal but still can&#8217;t find them in Spotlight or Finder.  Strange &#8230; I must be doing something wrong.</p>
<p>I&#8217;ve made it about halfway through Cocoa Programming for Mac OS X and half to say I am really enjoying it.  It&#8217;s definitely got the feel of the RCP dabbling I did in Eclipse but it feels like there is some stronger third party at work.</p>
<p>I also got Apache and PHP configured and running (comes with!), and installed MySQL.  In addition to LAMP, I installed the Google Application Engine and copied over my applications from my Vista machine.  I really like the GAE launcher that is installed&#8230;a nice GUI interface to launch applications from, look at logs, and manage multiple apps / port numbers running off the app server script.</p>
<p>Long story short, I am very impressed with the Mac and I haven&#8217;t even gotten into iMovie or iPhoto.  Next on my plate is to finish my first iPhone application and to setup my Java development environment here on Leopard.  Oh, and I need to figure out if I want a local SVN or try out this GIT version control system&#8230;to be continued!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/02/19/cocoa-and-objective-c/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Memory Leak with ELEvaluator and Dynamic Expressions</title>
		<link>http://www.gregheidorn.com/wordpress/2009/01/20/memory-leak-with-elevaluator-and-dynamic-expressions/</link>
		<comments>http://www.gregheidorn.com/wordpress/2009/01/20/memory-leak-with-elevaluator-and-dynamic-expressions/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 15:49:59 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web Hosting]]></category>

		<category><![CDATA[EL]]></category>

		<category><![CDATA[JSP]]></category>

		<category><![CDATA[JSTL]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=77</guid>
		<description><![CDATA[During one of my project engagements I found that the application was leaking by taking on a lot of Strings and character arrays over time.  Using heaproots, I was able to identify the container as the class instance of org.apache.taglibs.standard.lang.jstl.ELEvaluator.  This class evaluates Expression Language (EL) expressions and caches them for performance, as [...]]]></description>
			<content:encoded><![CDATA[<p>During one of my project engagements I found that the application was leaking by taking on a lot of Strings and character arrays over time.  Using <a href="http://www.alphaworks.ibm.com/tech/heaproots">heaproots</a>, I was able to identify the container as the class instance of <code>org.apache.taglibs.standard.lang.jstl.ELEvaluator</code>.  This class evaluates Expression Language (EL) expressions and caches them for performance, as each expression is translated into an object representation of that expression that is later used for processing.  What that means, though, is that your expressions cannot be dynamic, or else you will leak out over time as the cache is very plain and does not have a limit, nor does it purge least recently used entries like an LRU cache.<br />
<span id="more-77"></span><br />
In the application I was working with, the dynamic expression appeared when working with WebSphere Portal, JavaScript, and JSF.  There was a bit of JSP scriptlet code that generated a line of JavaScript that was to be passed to a JSF tag as one of the attributes.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>    <span style="color: #003399;">StringBuffer</span> buf1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;javascript:&quot;</span><span style="color: #009900;">&#41;</span>;
        buf1.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>portletResponse.<span style="color: #006633;">encodeNamespace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;setValues&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;(${myIndex});&quot;</span><span style="color: #009900;">&#41;</span>;
        buf1.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>JSPScriptHelper.<span style="color: #006633;">generateFormSubmissionJS</span><span style="color: #009900;">&#40;</span>portletResponse, <span style="color: #0000ff;">&quot;mainForm&quot;</span>, <span style="color: #0000ff;">&quot;flow_details&quot;</span>, <span style="color: #0000ff;">&quot;myPage&quot;</span>,<span style="color: #0000ff;">&quot;N&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #339933;">%&gt;</span>
<span style="color: #339933;">&lt;</span>someTag<span style="color: #339933;">:</span>someAction id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;customBehaviour_setValues&quot;</span> refId<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit${myIndex}&quot;</span> event<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;click&quot;</span> jsFunction<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;%=buf1.toString()%&gt;&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>That JavaScript was intended to create a form submission action and inside of JSPScriptHelper was code that called <code>portletResponse.createURI()</code> and appended the resulting URI to the function.  This URI was unqiue, based on the state of the portlet (different for each render, in this case) which was then appended to the rest of the JavaScript including the expression language tag <code>${myIndex}</code>.</p>
<p>The output looked something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span>PC_7_E1HDLKG100G7902NLUVANH1045_setValues<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#123;</span>myIndex<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;javascript<span style="color: #339933;">:</span>setMandatoryCheckInfo<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'PC_7_E1HDLKG100G7902NLUVANH1045_mainForm'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'myPage'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'N'</span><span style="color: #009900;">&#41;</span>;PC_7_E1HDLKG100G7902NLUVANH1045_submitAction<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">PC_7_E1HDLKG100G7902NLUVANH1045_mainForm</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'/1/myportal/!ut/p/c1/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hXQw8XH293QwP_MH83AyM_jwDTsEBTINccKB-JW97diCTdBj5uFkB5b0MPizBHI3dLQwK6_Tzyc1P1I_WjzJHMcDe3BKryCQ1z9PMwNDAx1Y_MSU1PTK7UL8gNjSjPd1QEAEgoflQ!/dl2/d1/L0lJSklna21DU1EhIS9JRGpBQUV5QUJFUkNKRXFnL1lGTkExTkk1MC01Rjg5dyEvN19FMUhETEtHMTAwRzc5MDJOTFVWQU5IMTA0NS91eGJUNDMzL3NhLmZsb3dfZGV0YWlscw!!/#7_E1HDLKG100G7902NLUVANH1045'</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Everything after <strong>myportal</strong> is the unique URI and after writing some debug code within the ELEvaluator which printing each expression it cached, we could see that this was the cause of the leak.  There were two ways to fix this issue.  First, we could re-write our JSF component to not accept a JavaScript function in this manner and simply write the function to the page without going through the component.  However if the component is a necessary step in processing, then the second option is to re-write ELEvaluator to use an LRU cache.  This may hurt performance though depending on the frequency of the page and number of users, given that you are no longer caching the expression representation.</p>
<p>I spoke with one of the JSTL caretakers, Henri Yandell, and he told me that he&#8217;s look at Q1 for a patch release with a fix for this issue, in either version 1.1.3 and/or 2.0, yet to be determined.  In the meantime, avoid using dynamic expressions in your JSF / custim tag arguments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2009/01/20/memory-leak-with-elevaluator-and-dynamic-expressions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ganymede JSP Validation Issue</title>
		<link>http://www.gregheidorn.com/wordpress/2008/11/14/ganymede-jsp-validation-issue/</link>
		<comments>http://www.gregheidorn.com/wordpress/2008/11/14/ganymede-jsp-validation-issue/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 17:01:57 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Spring Framework]]></category>

		<category><![CDATA[Web Hosting]]></category>

		<category><![CDATA[Ganymede]]></category>

		<category><![CDATA[JSP]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=74</guid>
		<description><![CDATA[Yesterday I had a heck of a time trying to figure out my my JSPs weren&#8217;t passing validation since I upgraded Ganymede from 3.4.0 to 3.4.1.  There was a consistent issue where the JSP Validation did not like my scriptlet code, even when I dumbed it down to try even the simplest scriptlet.  [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I had a heck of a time trying to figure out my my JSPs weren&#8217;t passing validation since I upgraded Ganymede from 3.4.0 to 3.4.1.  There was a consistent issue where the JSP Validation did not like my scriptlet code, even when I dumbed it down to try even the simplest scriptlet.  The validation errors looked like:</p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">Syntax error on token &quot;}&quot;, delete this token
Syntax error on token &quot;catch&quot;, Identifier expected
Syntax error, insert &quot;Finally&quot; to complete TryStatement</pre></div></div>

<p>I actually found out what my problem was through the <a href="http://www.eclipse.org/newsportal/article.php?id=17447&#038;group=eclipse.webtools#17447">Eclipse Web Tools usergroup</a>.  The issue for me was the use of the Spring form custom tag library.  If you self-close the tag&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>errors path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;*&quot;</span> <span style="color: #339933;">/&gt;</span></pre></div></div>

<p>&#8230;then you get the goofy JSP validation error.  If you close the tag as if there was body content&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form<span style="color: #339933;">:</span>errors path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;*&quot;</span><span style="color: #339933;">&gt;&lt;/</span>form<span style="color: #339933;">:</span>errors<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Then the error goes away.  I need to follow-up with a bug for the Ganymede team.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2008/11/14/ganymede-jsp-validation-issue/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Subclipse Tip on svn:keywords</title>
		<link>http://www.gregheidorn.com/wordpress/2008/11/06/subclipse-tip-on-svnkeywords/</link>
		<comments>http://www.gregheidorn.com/wordpress/2008/11/06/subclipse-tip-on-svnkeywords/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 16:56:23 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Eclipse]]></category>

		<category><![CDATA[Subclipse]]></category>

		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=72</guid>
		<description><![CDATA[Keywords in SVN are used to insert dynamic information about a file, into the file, presumably in a comment header.  The SVN manual discusses keywords, however when I was configuring my repository and eclipse projects, I had trouble getting them to update on commit.  I found a blog entry that discussed the keywords property in [...]]]></description>
			<content:encoded><![CDATA[<p>Keywords in SVN are used to insert dynamic information about a file, into the file, presumably in a comment header.  The <a href="http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-7-sect-2.3.4">SVN manual discusses keywords</a>, however when I was configuring my repository and eclipse projects, I had trouble getting them to update on commit.  I found a <a href="http://ajmoore.blogspot.com/2007/12/enabling-cvs-id-tag-for-svn.html">blog entry</a> that discussed the keywords property in the server configuration, so I hopped on my server and set up the configuration accordingly.  I restarted the service and commited a file with the following header:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * @version svn:$Id$
 */</span></pre></div></div>

<p>After the commit, the file did not update as expected.  I did some further digging and found a <a href="http://www.symfony-project.org/forum/index.php/t/15525/">forum post</a> that discussed another option where you set the property on the file.  So I experimented with that using the <em>Team > Set Property &#8230;</em> command in eclipse on a single file.  Setting the property name to <strong>svn:keywords</strong> and value to <strong>Id</strong>.  I made a simple change to my file and committed it again.  Voila!  It worked.</p>
<p>The last step was to apply this keyword to all of my files&#8230;and preferably not manually.  The answer was to go to the root of my project and set the property there, noting to check the <em>Set property recursively</em> check box.  If I want to add more keywords later on, I can by going to the root, modifying the <strong>svn:keywords</strong> property by adding other keywords (refer to the <a href="http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-7-sect-2.3.4">manual</a> again) separated by a single space.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2008/11/06/subclipse-tip-on-svnkeywords/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Synchronization Locks in Standard Taglibs Earlier Than v1.0.6</title>
		<link>http://www.gregheidorn.com/wordpress/2008/10/01/synchronization-locks-in-standard-taglibs-earlier-than-v106/</link>
		<comments>http://www.gregheidorn.com/wordpress/2008/10/01/synchronization-locks-in-standard-taglibs-earlier-than-v106/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 14:08:20 +0000</pubDate>
		<dc:creator>Greg</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[JSTL]]></category>

		<category><![CDATA[synchronization]]></category>

		<guid isPermaLink="false">http://www.gregheidorn.com/wordpress/?p=58</guid>
		<description><![CDATA[Sometimes an oversight can lead to interesting results.  We were testing a servlet-based application and in our test scripts, we had a hitch where if the script encountered an error, the re-try cycle didn&#8217;t have think time included.  Which means anytime the script encountered an application error, it would then send re-try requests [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes an oversight can lead to interesting results.  We were testing a servlet-based application and in our test scripts, we had a hitch where if the script encountered an error, the re-try cycle didn&#8217;t have think time included.  Which means anytime the script encountered an application error, it would then send re-try requests at a sub-second (inhuman) rate.</p>
<p>This increased our load from 10 pages per second to over 100 &#8230; our first indicator that something was wrong.  We saw a corresponding spike in CPU from 8% to over 90% as the single JVM system tried to handle this new load.  The application seized and thread dumps uncovered an interesting side effect.  <span id="more-58"></span>Forty-eight of the 65 allocated web container threads were waiting to lock on the synchronized method getEvaluatorByName() in ExpressionEvaluatorManager, a class provided by the Java Standard Tag Library.  Here&#8217;s a sample from the thread dump:</p>

<div class="wp_syntax"><div class="code"><pre class="text text" style="font-family:monospace;">&quot;WebContainer : 49&quot; daemon prio=5 tid=0x04a86830 nid=0xa1 waiting for monitor entry [0x59a7d000..0x59a7fc28]
    at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.getEvaluatorByName(Unknown Source)
    - waiting to lock &lt;0xeb30d958&gt; (a java.lang.Class)
    at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(Unknown Source)</pre></div></div>

<p>Looking at the source code, you can see the Evaluator retrieval and lazy instantiation of the Evaluator cache is done within this synchronized method.  The intent was to prevent duplicate Evaluators from entering the cache, but the side effect of this approach is that every &#8220;get&#8221; is synchronized.</p>
<h5>Synchronization Blocking – standard-1.0.3.jar</h5>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">synchronized</span> ExpressionEvaluator getEvaluatorByName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JspException <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">Object</span> oEvaluator <span style="color: #339933;">=</span> nameMap.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>oEvaluator <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				ExpressionEvaluator e <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ExpressionEvaluator<span style="color: #009900;">&#41;</span>
				<span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
				nameMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>name, e<span style="color: #009900;">&#41;</span>;
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ExpressionEvaluator<span style="color: #009900;">&#41;</span> oEvaluator<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ClassCastException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">// just to display a better error message</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;invalid ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span>
			ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ClassNotFoundException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;couldn't find ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span>
			ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IllegalAccessException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;couldn't access ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span>
			ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">InstantiationException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;couldn't instantiate ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span> ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A better approach would be to move the synchronization &#8220;lower&#8221; in the chain by removing the lock at the method level and creating a static block around the lazy instantiation of the cache.  The project owners recognized this as a bottleneck in 1.0.6 and released the following revised version of the same method.</p>
<h5>Fixed – standard-1.0.6.jar</h5>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> ExpressionEvaluator getEvaluatorByName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JspException <span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">Object</span> oEvaluator <span style="color: #339933;">=</span> nameMap.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>oEvaluator <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ExpressionEvaluator<span style="color: #009900;">&#41;</span> oEvaluator<span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>nameMap<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			oEvaluator <span style="color: #339933;">=</span> nameMap.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>oEvaluator <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ExpressionEvaluator<span style="color: #009900;">&#41;</span> oEvaluator<span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
			ExpressionEvaluator e <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ExpressionEvaluator<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">Class</span>.<span style="color: #006633;">forName</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			nameMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>name, e<span style="color: #009900;">&#41;</span>;
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ClassCastException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// just to display a better error message</span>
		<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;invalid ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span> ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ClassNotFoundException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;couldn't find ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span> ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IllegalAccessException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;couldn't access ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span> ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">InstantiationException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> JspException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;couldn't instantiate ExpressionEvaluator: &quot;</span> <span style="color: #339933;">+</span> ex.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, ex<span style="color: #009900;">&#41;</span>;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code solution reduces contention to almost nothing, as there is only one Evaluator defined (hard-coded, acutally) in the out-of-the-box version of the standard tag libraries.  In conclusion, it&#8217;s always a good idea to absorb updates in the thirty party libraries you are using!  Most Java applications won&#8217;t see this issue unless they have extremely heavy traffic or are using automated load or procedures to churn through their site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gregheidorn.com/wordpress/2008/10/01/synchronization-locks-in-standard-taglibs-earlier-than-v106/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
