In a Nutshell: Deploying a Java webapp to Red Hat’s OpenShift

Deploying a Java webapp to OpenShift couldn’t be any simpler. In as few words as possible to show you how simple it is – here’s a quickstart:

 

… and that’s it. Your app is pushed to your remote Git repo, built with Maven, and deployed to JBoss 7.

That’s pretty simple, huh?

In a Nutshell: Deploying a Java webapp to Heroku

This post walks you through getting started with Heroku and deploying a simple Spring MVC web app.

  • Follow the Getting Started guide to get your Heroku Toolbelt setup
  • Login to Heroku from the commandline with ‘heroku login’
  • Since Heroku does not provide it’s own app server, you configure your pom.xml to pull in a dependency on a container, like Jetty (this is from the Getting Started with Spring MVC guide)
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.3</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals><goal>copy</goal></goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-runner</artifactId>
                        <version>7.4.5.v20110725</version>
                        <destFileName>jetty-runner.jar</destFileName>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

The Heroku Getting Started with Java instructions give some steps on how to run your app locally by running Java from the command line and passing a classpath pointing to your target dir, but this seems odd since Jetty is able to run from Mavan against your created war file or even the code compiled to your target dir using the ‘mvn jetty:run’ command. Add the following to the above <plugins> section to enable and use this approach instead:

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>

  • Heroku uses a file named ‘Procfile’ in the root of your project to tell Heroku how to run your code. Add this file, and inside it add this one line
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war
  • Create your new app on Heroku with ‘heroku create –stack cedar’
  • Add and commit your code if you haven’t already, then push to your heroku remote git:
git add . git commit -m "commit comment" git push heroku master

At this point Heroku should build you app remotely and start it up.

If you see this error about the jetty-runner.jar missing, then you forgot to add the plugin part to your pom.xml to copy the jetty jar to the target/dependency dir:

Unable to access jarfile target/dependency/jetty-runner.jar

Is Zuckerberg’s hoodie really ‘a mark of immaturity’?

An industry analyst who recently met with Zuckerberg about investment plans in Facebook stated that he thought Zuckerberg’s trademark hoodie is ‘a mark of immaturity’, implying that he should have been more suitably dressed for the business meeting.

Over on Google+, Robert Scoble posted about the analyst’s comment, which unleashed the most active community discussion that I’ve ever seen on G+ as a result of a single post. Opinions ranged wildly, but the activity in the discussion proves the absurdity and out of date thinking behind the expectation that professional business atire should be nothing other than suit, shirt and tie.

Times change, fashions change. The suit in today’s world is an absurd form of clothing. It has no practical benefits and is purely for show. This is my key issue – I don’t see how a suit is relevant in today’s world (in the software development world that I live in, at least) – wearing a suit does not make anyone a better software developer. It does not gift the developer with magical coding skills. It’s purely for show.

The popular saying ‘don’t judge a book by it’s cover’ hits the nail on the head with this issue. Wearing a suit is nothing more than a cover on a book. As the other expression goes, ‘first impressions count’, but the fact is, once you’ve got beyond that faux outer layer to discover the contents of the person that has wrapped themselves in fancy, overpriced fabrics, it’s hard to hide the facts without the flashy threads. In software development, you can either code or you can’t. You either gel with the team, or you don’t. You perform or you don’t. Each of these have varying levels of degree, but the key point is this: a suit is nothing more than fancy plumage. Remove the outer shell and show me what you’ve got.

There’s some awesome comments to Scoble’s post that capture my thoughts entirely, that I’d like to quote here that make the point perfectly:

"wearing a tie doesn't make you money, not unless you sell ties"
"If you need to wear a costume to play out your roles, you should 
have become an actor or actress long ago"