<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Zarar Siddiqi&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/" />
<modified>2007-04-20T19:58:51Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/zarar/292</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2007, zarar</copyright>
<entry>
<title>Are JSPs dead?</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2007/04/are_jsps_dead.html" />
<modified>2007-04-20T19:58:51Z</modified>
<issued>2007-04-18T17:10:18Z</issued>
<id>tag:weblogs.java.net,2007:/blog/zarar/292.7080</id>
<created>2007-04-18T17:10:18Z</created>
<summary type="text/plain">Seriously, anybody still use them?</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>That’s supposed to be a rhetorical question, of course they’re dead. They died a long time ago when it dawned on us that they were nothing but untestable, overweight slobs that only ever existed because of ASP. Anybody who ever used JSPs has at some point, sworn by them, marveled at how great they are and felt really, really excited to write actual Java code inside pages. But it was only a matter of time until some of the lesser known facts about JSPs became more and more prevalent to the point of that templating languages were forced into creation to combat the shortcomings of Java Server Pages.</p>

<p>JSPs are the ultimate contradiction to Java reusability, there is simply no mechanism in J2EE which allows even an honest man to reuse a JSP. If you’re thinking of &lt;jsp:include&gt;, you’re missing the larger point of reuse - reuse as in other components of the application or even different applications. Of course being confined to a Servlet container kills off any chance of reuse in the SE world along with making testing so hard that you’re forced to mock an application server just to see what’s rendered. The direct binding to a Servlet is also something that never amused me nor did I find the behind the scenes conversion from JSP to Java to Class file ever a needed exercise. Why bother with an extra compilation stage when you’re already serving your page from a compiled Servlet?</p>

<p>Be advised that if you’re still considering using JSPs as the V part in MVC for even a mid-sized application, you’re making a mistake. This is especially true if you’re using JSPs as purely a view mechanism (no actual code in the pages but just taglibs) since you’re not even taking “advantage” of the ability to write Java code in them. If you are one of those folks who thinks the <c:sql> library wasn’t the ultimate example of bad ideas, you might actually still be using scriptlets in your pages and passing them off as acceptable software. You, you just keep doing what you’re doing, there’s no help for you.</p>

<p>Not too long ago a colleague of mine stumbled upon a major bank website (TD Canada Trust) who had managed to seriously screw up their application server configuration and ended up serving the raw JSP page instead of actually executing the code in it. Needless to say the code looked like crap with request.getParameter() being used more often than white space to compute user states in a banking application. It was one of those “this page can do a lot of stuff so I’ll just write a lot of ifs to figure stuff out” type things. What I’m trying to say is that JSPs promote shoving control logic in your pages no matter who you are simply because it’s so easy to fall into the pitfall that are scriptlets. It’s best to eliminate the temptation and use a dumb templating tool to render your views because let’s face it, they’re views!</p>

<p>What to use if not JSPs? Plenty of choices including Velocity, Jamon, Freemarker, StringTemplate, JByte etc. All good options with Freemarker being my favorite because of it’s lightweight nature, templating prowess and out-of-the-box support for Taglibs. Whether you’re templating a simple email to be sent out or a full-fledged page, the concept remains the same. Add in very easy Struts 2 integration for both Velocity and Freemarker and there’s little reason to rely on JSPs to do anything.</p>

<p>I used Selenium as a functional testing tool and realized that I was falling into the pitfall of checking the content displayed on the page to test whether the correct business logic was being performed rather than whether the correct view was being returned (think about it, there’s a difference). If you use a templating engine other than JSP, you can quite easily test the former without having to resorting to a functional testing tool.</p>

<p>As AJAX is becoming more and more popular, JSPs are getting further phased out. Lot of developers prefer to return chunks of HTML from the server rather than an actual dispatched forward. A lightweight and powerful template language is much more suitable here as your AJAX interface view will be an aggregation of snippets of HTML returned from the server. Doing this using JSPs would add a level of complexity that is both undesired and unneeded.</p>

<p>Having said all that, you can produce the same product with both JSPs and other lightweight template engines, but the latter stay much truer to the MVC philosophy and result in a much cleaner code base.<br />
</p>]]>

</content>
</entry>
<entry>
<title>A look back at The ServerSide Java Symposium 2007</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2007/03/sure_there_was.html" />
<modified>2007-03-27T19:57:39Z</modified>
<issued>2007-03-27T17:42:27Z</issued>
<id>tag:weblogs.java.net,2007:/blog/zarar/292.6929</id>
<created>2007-03-27T17:42:27Z</created>
<summary type="text/plain">An unadulterated look at The ServerSide Java Symposium 2007 held in Las Vegas, NV.</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>Sure there was fluff, fluff is everywhere and TSS Java Symposium was no different.  But in the end there were more code examples than SOA hand-waving and even when the so-called SOA gurus went about trying to sell you stuff, they usually backed it up (or at least tried to) with some kind of a demo which would translate through to the lowest common developer.  Advertised as the most pragmatic of conferences, TSSJS kept its word for the most part with only a couple talks bordering on inanity.  </p>

<p>Most of the speeches were tin-canned and delivered a thousand times before but if you've never heard it, its new to you, right?  That's the optimist in me talking.  There were some talks which could cure insomnia (Nati Shalom) while others entertained and informed (Brian Goetz - Java Performance Myths), but most fell into the category of "Here's a product X, it does A and B and it's good for people who are doing C".  Maybe I'm being naive and not critical enough but at least that's what I got out of the talks.</p>

<p>Does all this AJAX stuff really belong at a conference dedicated to the "server side".  Prototype and GWT? No matter how you swing it, it's still simple old JavaScript.  I can see this being a topic at JavaOne where there's plenty of sessions to fill out but at a specialized conference like this one, it seemed out of place.  I know a lot of developers are making the crawl over to the client side but to me these were sessions where the knowledge gained could've been done so using Google searches.</p>

<p>This was a smaller conference without any security guards armed with guns at the doors so technically anybody staying at The Venetian could get in (and some did thanks to Tech Target - lazy SOBs).  All the sessions I went to had plenty of room to sit or move up and almost all the sessions went without an AV hitch (Ross Mason's Mule2 and Chet Haase's Rich Client one being the exceptions).  Most of the talks were focused and concise and although the aforementioned fluff reared its ugly head often, it was in most cases, quickly put down in favor of practical speech.</p>

<p>The keynote speaker simply sucked, maybe I was expecting too much of Eric Gamma but the guy kept droning on about Jazz and how great the Eclipse team is.  Didn't really feel the vibe man.  After that on Wednesday morning, my expectations were pretty low but things got progressively better over the day thanks to some Spring2, OSGi, ESB and AOP talks.  I think I also felt a lot better after Mark Richards told me that I'm not an idiot for not really knowing what an ESB really is or whether I need it.  This was probably the best ESB talk that I went to.  It's good to see a speaker who wants to make a singular point and dedicate his entire talk to it by guiding you through what went in his mind as he reached his conclusions.</p>

<p>I stepped up to the Google desk in the vendor area and asked some Googly guy what he was doing for his side project, for those in the dark Google has a policy of allowing employees to work on side projects for 20% of their paid time.  It turns out he was wasting it by thinking about it for the past four months. I get a sick feeling every time I meet a Google employee.  Can't really explain it. I think it might even be jealousy.  My colleague still isn't over the fact that the Google supplied computers in the "Cyber Cafe" were missing J2REs.</p>

<p>The GigaSpaces logo was about as abundant as Gordie Brown posters, even penetrating a few talks through their new Interface21 partnership.  Spring2's endorsement of SBA includes declarative XML and annotation support for the architecture, making the product-pitch much easier for GigaSpaces.</p>

<p>One of the regrets I have is forgetting to attend the cocktail party on Wednesday night, if anybody did go to it, do let me know how it went.  Since I've already attended the one conference that I get allotted a year, I can't go to JavaOne which is a shame.  If anybody's feeling charitable enough to fly me out, be so kind to do so.  Great to meet a fellow Arsenal fan at the conference. Go Gunners.</p>

<p>If anybody cares, my reviews of the sessions are posted here:<br />
<ul><br />
<li><a href="http://arsenalist.com/2007/03/23/tss-java-symposium-review-part-1-eclipse-eric-gamma-rod-johnson-spring/">Part 1 - Eric Gamma, how could you?</a></li><br />
<li><a href="http://arsenalist.com/2007/03/26/tss-java-symposium-review-part-2-spring2-anything-cool-esbs-exposed-osgi-love/">Part 2 - Spring2 + <anything> = cool; ESBs exposed; OSGi love</a></li><br />
<li><a href="http://arsenalist.com/2007/03/26/tss-java-symposium-review-part-3-filthy-rich-gwt-clients-using-sba/">Part 3 - Rich GWT Clients using SBA</a></li><br />
<li><a href="http://arsenalist.com/2007/03/26/tss-java-symposium-best-talk-brian-goetz-tackles-java-performance-myths/">Best Session - Java Performance Myths by Brian Goetz</a></li><br />
</ul><br />
</p>]]>

</content>
</entry>
<entry>
<title>JavaOne vs. TSS Java Symposium</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2007/03/javaone_vs_tss.html" />
<modified>2007-03-07T00:06:37Z</modified>
<issued>2007-03-06T23:53:16Z</issued>
<id>tag:weblogs.java.net,2007:/blog/zarar/292.6753</id>
<created>2007-03-06T23:53:16Z</created>
<summary type="text/plain">After going to JavaOne last year, I decided against attending it this year in favor of TSS Java Symposium.  Maybe it&apos;s a horrible decision and I&apos;ll regret it later, but I do have my reasons for spending my money elsewhere.</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>JavaOne</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>The people I work for have rewarded my countless hours of hard labor by approving my application to go to TheServerSide.com's Java Symposium.  This comes a year after I attended JavaOne in San Francisco.  So why did I choose TSS Java Symposium over Java One?  I'm sure you give a rats ass about my opinion but here it comes anyways.  </p>

<p><b>JavaOne is too big:</b> It's f***ing huge! There's like 10,000 people there and although you might argue that the size of people attending is proportional to the quality of the presentations, you're wrong.  I did attend a couple nice sessions last year but there were more than a few crappy ones (Spring Web Flow, Composite Applications etc.) which tells me (keeping proportions in mind) that there are many crappy ones.  The rooms are huge which takes away from the learning environment that it should be; it feels like a first year chemistry class rather than a conference where you're supposed to quickly pick up stuff while having some fun at the same time.</p>

<p><b>The Commercialism:</b> Everyone's trying to sell you something and as soon as you tell them you don't have any purchasing power in your company, they throw sharp pointed objects at you.  I talked to the guy from Terracotta last year for about 15 minutes asking him all kinds of questions and at the end he asked me what I did at my company and when I said I was a measly developer, he gave me one of those I-can't-believe-I-wasted-20-f***ing-minutes-on-this-guy look.</p>

<p><b>Bad Food:</b> Just horrible and awful.  I was scared to touch it, let alone eat it.  But when I finally mustered up the courage to eat it, I regretted it after two bites.  I threw the sandwich away and gave my warm soda to what appeared to be a homeless developer.</p>

<p><b>Repetition:</b> There were around four different sessions on Java Persistence API which covered the same subject matter.  I made the mistake of attending two of them only to realize they're talking about the exact same thing, they just labeled the sessions differently just so everybody on the expert group had their crack at impressing the bored audience how they copied Hibernate.</p>

<p><b>Bad Party:</b> Any party where the ratio of men to women is 6:1 is never going to be good but you can make up for it by actually providing accessible food and drink.  When you shove 10,000 people in one big room and setup 4 stations where you can get drinks and food from, your appetite will force you to exit the premises and the lack of women will only motivate you to do so quickly.  I scampered off to the Marriot nearby and admired San Francisco from towering heights.  Also, chugging T-Shirts out of a cannon is not entertainment.</p>

<p><b>Long lines at sessions:</b> Again, the size issue.  The Gestapo regime that is the event staff forces you to lineup before every session and swipe your conference card.  The lineups are long and painful and if you're in the line, you'll often here more than a few people muttering "I don't believe this shit".  Don't believe me? Ask anyone who attended last year.</p>

<p><b>Spam after you come back:</b> Here's a tip to anyone attending this year, give a fake phone and email address in your JavaOne registration form.  You'll thank me as you're laughing at your friends for having to deal with daily spam and intruding phone calls imploring you to buy some product from Quest Software and pay for training courses from Sun.  These people have a knack of bothering you during lunch hour which is a double whammy.  Every moment you're in the pavilion, somebody's begging to swipe your conference card like they were get paid by the swipe.  They probably are.</p>

<p><b>No Networking Opportunities:</b> Aside from the BOF's which you may or may not be interested in, there are really no parties or events that will allow you to network with other people.  Given how most IT folks are socially inward and scared of light, the task of networking at JavaOne is a little tough.  The best time I had last year was at the Geronimo party, although I've never even used Geronimo, I sure enjoyed the free food and drinks provided by IBM etc.  Side note: Again, aside from the waitresses, no women at this party either.  I actually exchanged a few business cards with some fine folk; more of these events would only help JavaOne.</p>

<p>Now I've never been to TSS Java Symposium before but from what I can gather from the session descriptions, they seem to cater more to my line of work: enterprise development.  I read some horror stories about TSS last year but it's time I take a look and judge for myself.</p>

<p>Since I write about other stuff besides just Java, I primarily use a wordpress blog: <a href="http://arsenalist.com/tag/tech">arsenalist.com</a>.  I'll be talking and reviewing the sessions at <a href="http://arsenalist.com/tag/tss-java-symposium">TSS Java Symposium </a> over there.  If anybody cares.<br />
</p>]]>

</content>
</entry>
<entry>
<title>The pain of migrating from Ant to Maven</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2006/12/the_pain_of_mig_1.html" />
<modified>2007-01-10T19:40:38Z</modified>
<issued>2006-12-13T16:18:58Z</issued>
<id>tag:weblogs.java.net,2006:/blog/zarar/292.6162</id>
<created>2006-12-13T16:18:58Z</created>
<summary type="text/plain">Plan on migrating from Ant to Maven?  You don&apos;t know what you&apos;re in for.</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>
So you want to migrate to Maven because somebody told you <a href="http://www.ddj.com/dept/architect/186100398">it's the greatest build system around</a>?  They're probably right but what they don't tell you is that the road to Maven success is through hundreds of land mines, open JIRA's, mailing list lies and enough internal bleeding to make you wish you had stayed with good ol' Ant even though the build file had reached 4000 lines.
</p>
<p>
Don't take my word for it, just ask anybody and everybody who's ever converted a project larger than 30 source files from Ant to Maven.  God forbid if you're dealing with XDoclet and generated files, if that is the case, then you'll need enough Valium to last you a mvn deploy and no you can't use -Dmaven.test.skip=true.  Let's keep the attempts at humor on the side and talk about what really plagues Maven.  You, you right there who’s reading this and thinking, <em>Has this guy lost his mind? Maven is the greatest thing since the wheel and I've never run into any problems with it so it must be great.</em>  You my friend have obviously never worked with a multi-module project or mastered the maven-release-plugin which was originally designed to keep ADD patients occupied for months on end.
</p>
<p>
<strong>
Let's look at the good first:</strong>
</p>
<p>

Maven does all the dirty work for you.  Given a set of Java source code, it will take you no longer than two minutes to set up a Maven directory structure (using the archetype plugin), compile your sources and jar them up.  Given a set of Java sources, web.xml, and other web resources, it will take you no longer than two minutes to create a fully functional war ready to be deployed.  If you have any test classes, it will even run them for you without you even having to write a single line of XML.
</p>
<p>

As you can see the convention over configuration thingy does make sense.  To accomplish the above tasks, you would be required to write a verbose Ant script but with Maven you have to write almost nothing.   Note to Maven virgins: Maven by default assumes your source classes are in src/main/java, test classes in src/test/java, and web resources in src/main/webapp.  It also assumes you have the ability to find a grain of salt on the beach when it comes to the mailing list but more on that later.
</p>
<p>

Continuing with the good, Maven's greatest feature (and it is a HUGE feature) is dependency management which it does a fine job of.  No more downloading xfire-1.2.zip, unzipping it and adding it to your classpath.  Almost everything is on ibiblio and you can download it from there using a reference in your pom.  If something is not on ibiblio or if you’re dependent on a home grown artifact, Maven allows you to install the artifact in your local or remote repository with minimal bruises.  Your application can literally be built from scratch by using a single call to mvn package.
</p>
<p>

<strong>Let's now look at the good and bad:</strong>
</p>
<p>

The first thing to do when working with Maven is to get the bleeding edge version (2.0.x) which has as many fixes as possible and then read <a href="http://www.mergere.com/m2book_download.jsp">Mergere Inc.'s book</a>.  Same goes for any plugins that you'd use.  One of the better things about Maven is that it's <a href="http://maven.apache.org/guides/plugin/guide-java-plugin-development.html">very easy to develop plugins</a> to fit your need; this of course might also explain why all the <a href="http://jira.codehaus.org/secure/IssueNavigator.jspa?reset=true&amp;mode=hide&amp;sorter/order=DESC&amp;sorter/field=priority&amp;resolution=-1&amp;pid=11150&amp;component=-1">plugins have bugs in them</a>.
</p>
<p>

<strong>maven-antrun-plugin</strong>
</p>
<p>

What this plugin is saying is this:  <em>We know Maven has problems and it can't do everything but we want to say that it can do everything so here's a blanket piece of code which covers all cases, granted with piss poor quality.</em>
</p>
<p>

The maven-antrun-plugin for those of you who've never had to use it allows one to write Ant scripts inside a pom.xml, allbeit with strait-jacket type restrictions.  If you plan on doing a medium sized Maven migration, be sure to familiarize with the evils of this plugin:
<ol>
	<li>It does not pass Maven properties to the Ant script unless you specifically redefine each property inside the Ant script, thus defeating the whole purpose.</li>
	<li>There is no way of passing Ant properties to Maven.</li>
	<li>It <a href="http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%3C43DDE0D7.8000106@imc.nl%3E">magically runs twice</a> if a parent pom also has a maven-antrun-plugin defined, an entirely possible scenario.</li>
	<li>It does not allow for macrodefs to be called.</li>
	<li> It has class loading issues if you plan to use Ant optional tasks.</li>
	<li>It ideally should be used as a last ditch effort to perform tasks but has become a primary means of building with Maven.</li>
</ol>
</p>
<p>
So although the antrun plugin is powerful, it is a direct contradiction to Maven's philosophy of convention over writing-big-ass-scripts-to-do-build-tasks.
</p>
<p>

<strong>Plugins in General:</strong>
</p>
<p>

The power of Maven lies in its plugins.  If there is a task that needs to be performed, say compilation, it's handled by the maven-compile-plugin; if you need to run tests, the maven-surefire-plugin; if you need to filter files, the maven-resources-plugin; you need to precompile JSP's, the jspc-maven-plugin.  You get the idea.
</p>
<p>

The problem is that so many of the plugins hosted at Codehaus or Apache have bugs and "features" that will keep you up for nights wondering if you'll ever get to resume your FIFA game.  Allow me to point out a couple brisk examples for the unbelieving audience:
<ol>
	<li>Plugins getting executed in no particular order:  Not really a specific plugin issue but more of a general one.  If you have multiple executions for a plugin bound to the same stage, they execute in, get this, RANDOM ORDER.  Instead of caring for our sleep and executing them in the order they were defined, which would make too much sense, the Maven developers have decided to throw a curveball our way.  This will make you wish there was another phase between process-classes and test-compile, guaranteed.</li>
	<li>maven-resources-plugin: Treats even built-in property values as verbatim.  ${project.build.directory} will not be evaluated to "target" which it should be but to ${project.build.directory}.  This can drive you insane if you're filtering for different environments.</li>
	<li>maven-surefire-plugin: Despite <a href="http://jira.codehaus.org/browse/MSUREFIRE-58">pleas by the general public</a> to add a configuration parameter for having an additionalClasspathElements, the surefire plugin is committed to pissing people of by forcing them to have a custom version which they will need to patch and deploy to their local repository.</li>
	<li>maven-release-plugin: If anybody has got this working with a hierarchical project, please let me know.</li>
</ol>
</p>
<p>
The maven-idea-plugin, or sorry, the idea-maven-plugin was a pleasant surprise.  Yes, the name matters.  If you start your plugin name using "maven-", you better be part of the Apache group or they nuke your PC.   Back to the plugin: Type in mvn idea:idea and you have a bunch of IntelliJ files which get you fairly close to compilation as long as you're doing nothing fancy.  Unfortunately, if you're doing anything remotely complicated like generating source files or resources, you'll have to fiddle with the settings (classpath, source tree, XML files etc) to get it to do anything.  All in all, it was a decent find.
</p>
<p>

When <a href="http://mojo.codehaus.org/jspc-maven-plugin/usage.html">well written like the jspc-maven-plugin</a>, life is good.  If written like the <a href="http://cargo.codehaus.org/Maven2+plugin">Cargo Maven plugin</a>, it lulls you into a false sense of security, shoots you and then gnaws your head off while you’re sleeping on your keyboard.  Chances are that if you're going to decide to use a plugin beyond the most basic case, you will end up looking in its source code to figure out what the hell its doing.  That's probably why every plugin has a convenient link to the source repository.  What better documentation!
</p>
<p>

<strong>Generated Files:</strong>
</p>
<p>

If you're using XDoclet, you fall into two categories of people:  Those that have fixed a bug in XDoclet and are using a custom version and those who haven't <a href="http://opensource.atlassian.com/projects/xdoclet/browse/XDT-1616">contracted rabies from a careless XDoclet developer error</a>.  If you fall into the latter group, you can go ahead and use the maven-xdoclet-plugin and see how far it gets you.  However, if you fall into the former category, what lies ahead is the unenviable task of copying all the stuff you did in your build file over to your Maven POM and in to the antrun plugin.  The other thing you can do is to force the xdoclet-plugin to use your custom version of XDoclet rather than getting it via its defined dependencies.  Good luck going down that road.
</p>
<p>

Maven completely missed the boat on generated sources.  Since all the source code is supposed to be in src/main/java, one is forced to do one of two things, both not very glamorous:
<ol>
	<li>You could dump them in src/main/java in the generate-sources phase and delete them in some subsequent phase after compile.  Stinks of bad programming and will probably get you fired.</li>
	<li>Create a gen directory in target or as Maven likes to call it ${project.build.directory} and then use the build-helper-maven-plugin's add-source goal which will add another 25 lines to your pom.xml, making you nostalgic about Ant.  Side note: is it just me or is ${project.build.directory} excessively long an alias for the word "target". Same for target/classes which the Maven folks happily defined as ${project.build.outputDirectory}.  How nice and compact.</li>
</ol>
</p>
<p>
I hope you're a religious man if you're generating a web.xml or a struts-config.xml because the only way you'll ever get them in the WEB-INF folder is through prayer.  Although the following misuse of the maven-resources-plugin would work too:
</p>
<p>
<pre>
&lt;resources&gt;
   &lt;resource&gt;
      &lt;directory&gt;src/main/resources&lt;/directory&gt;
   &lt;/resource&gt;
   &lt;resource&gt;
      &lt;directory&gt;target/gen/web-resources/WEB-INF/&lt;/directory&gt;
      &lt;filtering&gt;true&lt;/filtering&gt;
      &lt;targetPath&gt;../<a href="http://jira.codehaus.org/browse/MRESOURCES-38">wardir-cant-use-property-here-due-to-bug</a>/WEB-INF&lt;/targetPath&gt;
   &lt;/resource&gt;
&lt;resources&gt;
</pre>
</p>
<p>

See, if you want to copy over a resource other than the default one, you have to redefine the default resource (the first resource element).  The second resource element's targetPath assumes the default location of target/classes which makes the value of targetPath rather confusing to the untrained eye.
</p>
<p>

Maven should seriously consider having a target/gen/src/main/java etc structure to combat generated files since this is a situation faced by most medium to large projects.
</p>
<p>

Again, there is a solution but it’s not pretty.
</p>
<p>

<strong>Profiles:</strong>
</p>
<p>

Remember the good old day of AntContrib's if/else statement?  How simple? If or else.  Two options, pick one of them.  Well in the ultimate example of killing a bird with a cannon, in order for one to execute an if/else statement in Maven, you must write a profile which stores the plugins that execute on the true condition.  If you want something else to happen in the false condition, write another profile.  Sounds overkill? It is.  Well, you could always use the maven-antrun-plugin but that won't get you far since you can't call Maven code from Ant code and you'll be forced to do everything with Ant once you go down that road.
</p>
<p>

Having said that, profiles do allow executions to run in different conditions.  For example, if you only want your JSP's only to be precompiled when you're deploying to production, you would define the jspc-maven-plugin in a profile with an id of "precompile-jsps" and it'll only get executed if you activate it, for .e.g.: mvn -P precompile-jsps deploy.  But say if you want to copy a file into either dir1 or dir2 based on ${prop1}, whip out the antrun plugin.
</p>
<p>

<strong>Class Loading</strong>
</p>
<p>

Justifiably Maven's class loading mechanism is complex, especially when it comes to multi-module hierarchical projects.  They do have the decency to <a href="http://maven.apache.org/plugins/maven-antrun-plugin/classpaths.html">provide you with different classpath's</a> which are built from the dependencies specified in the POM.  Although this is very convenient, you just never know <a href="http://www.nabble.com/-M1--compiling-jasper-reports-tf2351306s177.html#a6561073">when you need to specify a weird property out of the blue.</a>
</p>
<p>

<strong>Mailing List</strong>
</p>
<p>

Exhibit A, <a href="http://www.nabble.com/Maven---Users-f178.html">The Maven Users Forum</a>.  Where the users providing help are as confused as the poor bastards asking for it.  For every query typed into the search box, six <em>different </em>"solutions" pop back <a href="http://www.nabble.com/forum/Search.jtp?query=ant+nodeps&amp;local=y&amp;forum=178&amp;daterange=0&amp;startdate=&amp;enddate=">all claiming to work</a> but rarely ever doing so because you have something sliiiighhtly different somewhere.  These posts usually have a link to a JIRA of some sort which may or may not be related to the actual problem.  What I'm trying to ramble through is that the mailing list has tons of useful information in there but you have to be careful for what you accept as a solution as it's <a href="http://www.nabble.com/M2-%3A-Having-problems-with-a-javac-on-a-very-simple-build-of-my-first-M2-project.-tf660202s177.html#a1762829">pretty easy to get lost</a>.
</p>
<p>
<strong>Let's take a look at the bad:</strong>
</p>
<p>

<strong>Properties:</strong>
</p>
<p>

This bothered me to no end and I ended up writing  <a href="http://jira.codehaus.org/browse/MOJO-535">properties-maven-plugin</a> which still hasn’t been accepted despite many users supporting the feature.  The feature in question is loading various project properties from property files. It only make sense but this essential piece of the puzzle in any application is mysteriously missing from Maven.  For example, I want to load a different property file for production versus for development.  Is that too much to ask?   What Maven wants you to do is to define two profiles with their own set of properties and activate one of those profiles during the build (and hope that the profile properties override the project properties which they don’t).   This makes the POM unnecessarily huge since defining properties in XML is a bitch:
</p>
<p>

What would be this:
</p>
<p>

<pre>myprop1=myvar1
myprop2=myvar2
</pre>
</p>
<p>
becomes this:
</p>
<p>

<pre>&lt;properties&gt;
&lt;myprop1&gt;myvar1&lt;/myprop1&gt;
&lt;myprop2&gt;myvar2&lt;/myprop2&gt;
&lt;/properties&gt;</pre>
</p>
<p>

Note you have to do this each time for every environment in your POM.  Those of us coming from Ant can’t get a handle on this.  There needs to be a replacement for &lt;property file="build.properties"/&gt; in Maven.  Don’t even think of using the maven-antrun-plugin to do that.
</p>
<p>

Oh, by the way, the ${line.separator}  property is broken in Maven and if you try printing it out, <a href="http://jira.codehaus.org/browse/MANTRUN-62">you'll only be disappointed</a>.
</p>
<p>

<strong>Multi-Module compilation:</strong>
</p>
<p>

Be very careful in a multi module project.  If you’re doing a mvn compile, it will look at your sources in all POM’s that have a version number ending with the word SNAPSHOT, however, if you’re doing a mvn package, Maven decides to ignore your checked out sources but instead looks in the local repository for a snapshot jar.  To avoid any possibility of compiling against older source, it’s best to do a mvn install for the module that’s serving as a dependency before doing a mvn package for the main module.   Remember this and you’ll never find yourself doing an mvn package for hours without figuring out why your changes aren’t showing up.
</p>
<p>

Maven’s whole deal of treating –SNAPSHOT versions differently is bound to cost anybody a few hours of headache but once you’re past the initial growing pains of somebody shoving a philosophy down your throat, you’re bound to like it.
</p>
<p>

So in closing: Maven has been a complete pain to work with but it has pleasantly surprised me at how integrated my build has become and how source code from multiple modules is combined together to produce multiple artifacts.   Something Ant just couldn’t do.
</p>
]]>

</content>
</entry>
<entry>
<title>The shock of seeing your password in clear text</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2006/08/the_shock_of_se.html" />
<modified>2006-08-25T16:43:59Z</modified>
<issued>2006-08-22T13:50:22Z</issued>
<id>tag:weblogs.java.net,2006:/blog/zarar/292.5396</id>
<created>2006-08-22T13:50:22Z</created>
<summary type="text/plain">A sick feeling encompasses my soul, a wretched sickness comes over me as I sit there staring at this violation of even the simplest of courtesies.  I examine it closely and sure enough, it is there, in clear text mocking me, laughing at me, just as I had typed it - letter for letter, digit for digit.</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>Security</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>
A sick feeling encompasses my soul, a wretched sickness comes over me as I sit there staring at this violation of even the simplest of courtesies.  I examine it closely and sure enough, it is there, in clear text mocking me, laughing at me, just as I had typed it - letter for letter, digit for digit.  No sense of regard showed on the part of the offender, in this case XDoclet's JIRA.  
</p>
<p>
<img alt="password-o-meter.jpg" style="padding-left: 4px; padding-bottom: 4px; float: right;" src="http://weblogs.java.net/blog/zarar/archive/password-o-meter.jpg" width="183" height="27" />So hard have I worked to come up with a word at least eight characters long, containing a digit, an uppercase letter, a symbol and one that I won't forget and you have to ruin it all by sending it to me in clear text over email?  Especially even when the password-o-meter told me I had chosen a great password.  Why, I ask, Why?  
</p>
<p>
The first thing that comes to mind is that this sacred phrase is most likely stored in a cheap MySQL database without being md5'd.  This alone is enough to warrant public execution but I'll let this pass as we live in times where acts of such vileness are tolerated.  Who has access to my sacred word? Well, in this case it's the JIRA admin.  I know he's (she's?) sitting there on those lonely nights just going through the list of the poor souls he has seduced into supplying him with the key to their lives.  I've also been naive (stupid?) enough to supply the same password I use as for my email, youtube, home computer and most importantly bank.  Yes, it is my fault, I have shown too much faith in common technology courtesy and will be punished for it by the JIRA admin finding out all about my porn stash.
</p>
<p>
My best judgment on why these sites don't encrypt passwords is because a) they're lazy, b) they don't know how, c) they want the user to have a copy of the password in case they supplied a really made-up one and will forget it instantly.  Let’s give them the benefit of the doubt and say its c).  Even in this case you HAVE to encrypt the damn password for database storage or at least ask the user on the sign up form whether they'd like their password mailed to them in clear text or not.
</p>
<p>
Listen, I don't have much going on in life and by no means will the person who knows my bank password be at a great advantage but it's still absolutely wrong to a) store such info in clear text for anyone with database access to see and b) to send it in an email which can be easily compromised.  I've never been a JIRA admin so I'm not too sure if there's an option to use encryption or not but I'd be shocked if there weren't considering one has to open their wallet to use it.
</p>
<p>
So for next time let us all agree to be careful with passwords for the sake of internet privacy:
</p>
<p style="padding-left: 30px;">
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/VbyJbrhzDk4"></param><embed src="http://www.youtube.com/v/VbyJbrhzDk4" type="application/x-shockwave-flash" width="425" height="350"></embed></object></p>]]>

</content>
</entry>
<entry>
<title>Passing arbitrary data between JSP pages and SiteMesh decorators</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2006/01/passing_arbitra.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-01-19T18:49:02Z</issued>
<id>tag:weblogs.java.net,2006:/blog/zarar/292.3974</id>
<created>2006-01-19T18:49:02Z</created>
<summary type="text/plain"><![CDATA[When passing data between your JSP pages and SiteMesh decorators, you are not restricted to just the head, body and title elements.  You can pass in any amount of data as long as you know how to use the &lt;content&gt; tag.]]></summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>J2EE</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>
I try not to complain about lack of documentation.  So in this blog entry, I'll show how simple it is to pass in arbitrary data from JSP pages to <a href="http://www.opensymphony.com/sitemesh/">SiteMesh</a> decorators.
</p>
<p>
For every piece of information that you want to pass from the JSP page to the SiteMesh decorator, create a <code>&ltcontent&gt</code> tag.  In the following example, I want to pass in two pieces of data, a "page name" and a "site section".  So I must declare two content tags in the JSP page:
</p>
<pre><code>
&lt;content tag="pageName"&gt;
    Login Page
&lt;/content&gt;
&lt;content tag="siteSection"&gt;
    Administration
&lt;/content&gt;
</code></pre>
<p>
Now, all thats left is telling the SiteMesh decorator to access this information, and that is very easily done using the following syntax in the decorator:
</p>
<pre><code>
&lt;decorator:getProperty property="page.pageName"/&gt;
&lt;decorator:getProperty property="page.siteSection"/&gt;
</code></pre>
<p>
That's it.  Now you can pass in anything you want and aren't restricted to using <code>&lt;decorator:head/&gt;</code>, <code>&lt;decorator:body/&gt;</code> and <code>&lt;decorator:title/&gt;</code>.  My problem with these three tags is that I don't want to declare a head, title and body tag for every JSP page since the JSP page is usually the "main" content of the page and shouldn't have to declare such basic HTML elements.   IMHO using &lt;content&gt; tags is a cleaner and more powerful solution as you can pass in an unlimited amount of data without using specific tags.  However, combining the three tags mentioned with the <code>&lt;content&gt;</code> tag is also a fine strategy.</p>
]]>

</content>
</entry>
<entry>
<title>Sneaky, sneaky Log4J</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2005/11/sneaky_sneaky_l.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-11-14T21:23:56Z</issued>
<id>tag:weblogs.java.net,2005:/blog/zarar/292.3630</id>
<created>2005-11-14T21:23:56Z</created>
<summary type="text/plain">There is no API in Java that tells you the current line of code being executed.  So how does Log4J do it?</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>Performance</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>
So I found myself wanting to know if I could print the enclosing method of the current line of code being executed.  A quick look at the reflection API didn't yield much.  A little reflective thinking later, I came to the conclusion that it's impossible for the reflection API to tell me this since it explores binary files at the class level.
</p>

<p>
Thats when it struck me that <a href="http://logging.apache.org/log4j">Log4J</a> does exactly what I want to do.  It can print out the method and line number of the code for each <code>log.debug(..)</code> call.  So of I went digging into Log4J code looking for an answer.  I found it.
</p>

<p>
What Log4J ends up doing is that for each <code>debug(..)</code> call, it creates an instance of <code>Throwable</code> which takes a snapshot of the runtime stack.  It then proceeds to parse the stack to yield the current line of code being executed along with class and method information.
</p>

<p>
Keep in mind that constructing stack traces is a fairly expensive operation. When an <code>Exception</code> is created, the JVM needs to literally pause the processing and so it can get a good glimpse of the entire runtime stack - this includes classes, methods, line numbers etc - starting from <code>Thread.run()</code> all the way till the creation of <code>Throwable</code>.  From the runtime's point of view, this is acceptable since it's not designed for great <code>Exception</code> handling but to run as fast as possible.  
</p>
<p>
However, in the logging scenario, the culprit is the call to the <code>Throwable.fillInStackTrace()</code> method in the <code>Throwable</code> constructor which gets invoked on each <code>debug(..)</code>, <code>info(..)</code> and other logging calls.
This is the only way to retrieve the logging information requested via the <code>PatternLayout</code> class.  Give Log4J credit since they only create the <code>Throwable</code> instance when the specific <code>PatternLayout</code> is specified; plus they have the <a href="http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html">decency to warn you</a> about using the <i>l</i>, <i>L</i> and other expensive options.  
</p>

<p>
Although descriptive logging can provide good <a href="http://www.plop.dk/vikingplop/2003/Patterns/saridakis.pdf">roll-back mechanisms</a> in production code, the cost incurred by specifying method and line numbers when logging is simply too high.  It seems like the pain of typing out the method name when logging is unavoidable.
</p>

<p>
To some, this might come as old news but to many it'll make them change their <i>log4j.properties</i>.
</p>]]>

</content>
</entry>
<entry>
<title>Developer thinks he&apos;ll make a better PM</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/zarar/archive/2005/11/developer_think.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-11-08T20:03:13Z</issued>
<id>tag:weblogs.java.net,2005:/blog/zarar/292.3584</id>
<created>2005-11-08T20:03:13Z</created>
<summary type="text/plain">Although I&apos;ve been a core developer for a significant part of my career, I do often come in contact with the business-types who drone on about requirements while the eager-to-please IT shop keeps saying yes to even the most unfathomable requests.</summary>
<author>
<name>zarar</name>

<email>zarar.siddiqi@utoronto.ca</email>
</author>
<dc:subject>Community: Global Education and Learning Community</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/zarar/">
<![CDATA[<p>Although I've been a core developer for a significant part of my career, I do often come in contact with the business-types who drone on about requirements while the eager-to-please IT shop keeps saying yes to even the most unfathomable requests.  After all the yes's have been nodded and all the necessary hands shaken, the Project Manager brings a steep pile of 8.5 x 11's to the developers along with a pat on the back and a confidence inspiring wink.  Boo Yeah! The project has started.</p>

<p>A meeting is held by all parties involved only to be cut short by 12:00 PM and the ensuing two hour lunch break.  The developers are left figuring what this stack of paper is trying to say.  The front page is pretty clear, "Inventory Management System" it says.  On the second page there's something about Java being a requirement.  There's also a due date.  They start working.</p>

<p>Fast forward to five months later.  The stack of paper has a lot of writing on it. Lines have been scribbled and crossed out.  Along with bits and pieces of scribble, you'll also find pepperoni stains and some fluids which can best be ascribed to coke spills.  Lots of code has been written, some of it has even been tested.  The programmers are feeling fairly confident, the PM has his ass covered, anything goes wrong, and he’s ready to play the blame game.</p>

<p>Guess what? Something does go wrong. Seriously wrong. Turns out something works the way it's not supposed to work.  "No Problem" says the PM and says he can have it fixed by end-of-day.  The developer is told of the "problem" and the expected fix date.  The look on his face is priceless:  "That's not a problem, I've made it that way just like you said", he pleads pointing at the greasy stack of paper.  They both consult the stack, sure enough, he's right.  He's done what he was asked to do.</p>

<p>The PM frowns, goes away, comes back half an hour later and says, "You've misunderstood the document, this is what it really means".  The developer listens, frowns, frowns some more, consults the other developers who all frown.  An hour later, they reach the agreement  that the wording can mean more than one thing depending on the time of day and the salary you're making.</p>

<p>The PM has found somebody to blame.</p>

<p>********************</p>

<p>It's incidents like these that motivated me to go back to class and take a couple Project Management courses via <a href="http://www.pmi.org">pmi.org</a>.  I'm almost through with the courses and have so far learnt that Project Management is simply common sense wrapped around acronyms, document formats and jargon.  It really does sound very simple and sometimes quite bloated.  Hey, did you know if you have 10 people on your project you have 45 communication channels?  How did I arrive at that number? Why I simply applied the formula n(n-1)/2.  That’s 45 different conversations between two people and thus a lot of room for miscommunication.</p>

<p>See what I mean?  Someone wise once said, "common sense is not common". I agree.</p>

<p>More on the conclusion of this course.</p>]]>

</content>
</entry>

</feed>