Friday, July 12, 2013

Simple war deploy to Tomcat with Gradle

After observing and trying many different Tomcat deployment strategies, I decided to share my current pick.

The Goal: build the war and upload it into Tomcat's "webapps" directory. Should be simple. Thankfuly it is, using int128's Gradle SSH Plugin, a wrapper around JSch.

The main takeaway is that the Gradle SSH Plugin is a nice piece of work, but there are a few other things to note:

  • After the gradle war task has executed the path the new war is war.archivePath.absolutePath (usually in "build/libs").
  • If your deploying to Amazon EC2, (and who isn't?) you'll need to disable StrictHostKeyChecking.
  • Don't upload the war with a .war extension. Tomcat will attempt to start it before it's done copying, fail, and you will have to restart tomcat or screw around in the admin console.
  • Once it's finished uploading, and the old war is removed, then you can rename to .war.
This example doesn't take advantage of Tomcat 7's Parallel Deployment feature, but it could easily be extended to do so by naming the war things like appName##versionNumber.war.

Feel free to post your favorite Tomcat deploy edge cases in the comments!

Example tested with Tomcat 7 and Gradle 1.5.

Tuesday, February 5, 2013

If you want to believe what you read ... then actually read it

Snapped from Facebook before the thread was deleted. Names other than mine cropped out. 

This is the ritual.

1. Viral graphic on Pintrest shared by one of your friends.

Any truth found in this infographic is purely coincidental.

2. Semi-legit looking article apparently from MSNBC, titled "Want a Better Job? Top Jobs In America Revealed." It praises working online for companies like "Home Cash Success" as the #1 type of job in America, citing an annual review by Career Cast. Links to the Home Cash Success website which looks exceedingly shady.

3. Googling the phrase Home Cash Success, second result: Home Cash Success Scam. Snopes article is from 2009 but seems to be describing the same thing.

4. The actual 2012 review done by Career Cast, The 10 Best Jobs of 2012. Seems like a nice review and well researched. Says something completely different than the MSNBC article that cites it.

5. Upon attempting to write a letter to the editor informing NBCNews that one of their columnists screwed up and requesting a retraction, realize that the article is nowhere to be found from within

6. Re-inspect the first article link's domain, "" ... WAIT A MINUTE.

Should've caught that a lot sooner, honestly. I'm sure Mike Finney would've.

The specific facts here aren't important. It's the ritual. Skepticism is about more than the Shroud of Turin and Big Foot. It's even about more than being a smartass on social media. 

Critical thinking is a lifestyle. We live in a world filled with information, good and bad, whizzing past us as fast as we care to absorb it. If you're going to put some of it in your head, vet it.

(See also my 2008 post: The arrogance of demanding evidence)

Monday, May 14, 2012

The Work - A Manifesto For The Underground Musician

Adapted from my song "The Work," winning entry in the No Coast 2009 Beat Competition.

Our communities in the underground and popular music scenes must make continual progress. In the global village there is no East Coast, West Coast or Mid-West style; the playing field is level.

When I turn on the radio, I'm unimpressed by the content. Most of today's popular singles will not stand the test of time. It's depressing that many music fans need to be drunk or high to enjoy them. Today's top-ten is a joke.

We as musicians should do the following to improve music:

Strive to compete on a higher level than our own geographic region, and seek influences from the world at large. This is how we will grow. Our style can draw from the distant past but should bring that style to the level of present and future. Draw inspiration from other regions, other genres and other eras.

Write what deserves to be heard and repeated. None of us were formally invited to be music makers - we showed up unannounced to a party full of egos and posturing.

To open the doors to creative success, practice relentlessly. Compare yourself to and compete with your favorite artists. A following of listeners is not a right, you must earn it. Focus your creative power to have an impact. If you believe you are better than everyone else, you will not improve - but be overtaken by those whose humility motivates their improvement.

Continue creating - if not publishing - new music. The alternative is stagnation. Make new music. Share it. Perform it live. Make a name for yourself, but never rest on your laurels.

Music is usually an outlet or way of life - not a source of income. Only the most business savvy are able to make a living from it. Even if you press and distribute your own CDs, you are not relevant as a musician until you perform for live audiences. This will mean doing many gigs for little to no money. Put on your best possible performance for the biggest and smallest crowds alike.

By definition most artists are average. Many plan to get better but don't follow through. Being good means more than thinking highly of yourself. If we don't speak intelligently from our hearts and minds, we will fade into deserved obscurity.

Too much music is self-similar and repetitive. Stop. Let art imitate the richness of life: past, present and future. Good music, precisely because it is not repetitive, is worth listening to again.

"Possibly I’m thought to be a prodigy to wanna make a mockery of monuments to modern mediocrity."

You can listen to this essay in song form on my Soundcloud:

Sunday, May 22, 2011

Old School Hip-Hop Revivalists

The New York Times has a pretty neat article called "White Rappers Paying Homage to the Past". It's definitely worth a read for Rap fans, but here's the main point: The current trend for white rappers seeking respect is a fight to revive Hip-Hop's past. You can't go wrong traveling beaten paths. Insightful but I felt part of the story was missing, so I'm throwing in my take as an 11-year Hip-Hop DJ.

First, kudos. Someone at the Times must be a pretty big hip-hop head to recognize the 5 second homage to "Smoothe da Hustler ft. Trigger tha Gambler - Broken Language" in the Action Bronson track. I specialize in hip-hop circa 1995 and I'd never heard of it (though the instrumental definitely makes the rounds). Unsurprising that it's obscure though, it's a 4 minute song with no chorus, just one giant verse with the same formula throughout -- listing a bunch of things that they are. Gotta admire sticking to themes.

The thesis of the article is an interesting one: many white rappers these days see themselves as preservationalists and throwback artists. Their next example was Beastie Boys, which is a bit off because that's not a sign of the times. The Beastie Boys have rapped like it's '86
since it was '86.

Really what I think you've got here is that Hip-Hop has always been a bitterly nostalgic genre. Case in point, that very 1995 track paid homage to Big Daddy Kane, who hasn't really been relevant since 88.

It's not necessarily a white thing, more of an underground hip-hop thing. There are plenty of examples of black rappers, underground and mainstream alike referencing tracks like
Slick Rick's La Di Da Di from 1985 ("La Di Da Di, we like to party..."). Amazingly, in that song Slick Rick was ALREADY complaining
about rappers biting his rhymes, and they're still doing it 25 years later.

If there has been a resurgence of the old school revivalist theme (such as Wu-Tang's recent "Take It Back", Black Eyed Peas "Bringin It Back" several albums ago when they were good, and virtually the entire Jurassic 5 catalog), I would ascribe it to the appeal of Hip-Hop as an
underdog genre. It's reached mainstream popularity dominating the charts, so we look back fondly to the days where it was relatively esoteric. As with grunge and many others, the hardcore fanbase feels let down now that our pride and joy has been warped toward popularity.

Identifying a trend with "White Rappers" is bound to get more readers, though.

Sunday, December 5, 2010

Grails Domain Objects Across Schemas

The Grails documentation is very clear on how to specify specific table and column names for your domain classes (in Section 5.5.2 Custom ORM Mapping). But what if you need to specify the schema as well? Fortunately it is just as easy, if less well-documented.

Of course, when all of your domain tables are in the same schema, you should simply specify a default schema in DataSource.groovy. The property is hibernate.default_schema.

Thursday, August 5, 2010

Testing rich webapps from JUnit with Rhino and Envjs

Envjs is an implementation of the DOM in Javascript. Together with Rhino, it can function as a headless web browser in Java. Picture HtmlUnit, but with flawless Javascript support. For instance, the latest version of JQuery works flawlessly in Envjs on Rhino but won't even load in HtmlUnit.

Here's a simple way to tie them together in JUnit. Wonderful testing frameworks to follow (looking at you, Mike ;)

Not too many Groovy-isms here, can easily be converted to plain Java.

Friday, July 23, 2010

Watch Directory For Changes in Groovy

One must-have feature in any modern web stack is the ability to automatically restart/refresh the development server when you edit the source code. It is critical for developer workflow that the feedback loop be as tight as possible. Here source code refers to actual class definitions, templates (JSPs, GSPs, haml files, etc...), static content (javascript, css, images), AND configuration (I'm looking at you, struts.xml).

All web frameworks which do not support automatic updating of all content during development shall hereafter be referred to as "Legacy Web Frameworks". Is your shop using them?

Justin Voss and I have been hard at work on a web micro-framework called Ratpack (inspired by Ruby's Sinatra). Lest it become a Legacy Web Framework right out of the gate, we've implemented basic auto-reloading right away. Feel free to grab this for other uses, as it works independently.

groovy runapp.groovy app/myapp.groovy app

The script app/myapp.groovy will be killed and re-run when any content in the app directory changes.

Since Ratpack uses Jetty, there are probably better solutions. Feedback is welcome.

The NIO.2 Filesystem in JDK7 will make this sort of thing much easier.