Chariot Training Classes

Training Courses

I run Chariot's training and mentoring services. We provide training in AngularJS, HTML5, Spring, Hibernate, Maven, Scala, and more.

Chariot Education Services


Chariot Emerging Tech

Learn about upcoming technologies and trends from my colleagues at Chariot Solutions.


Chariot Conferences


Entries in maven (4)


Spock and Roo - Maven's conventions step in to mess with me

Ok, here's a cautionary tale.

I had everything working just fine in one project using Spock - on Jenkins builds I was getting code coverage working. It was great!

Hey, listen, keep this in mind:

src/test/java is NOT src/main/groovy! Now my jQuery project is starting to use code coverage - go ahead and view the report...

Oh, and one more thing: bind them to test-compile, not test. AAAHH!


Ok, here's my maven build fragment for running the tests (I assume now that the file set is no longer needed...)


Maven Search Site Online

I was a bit surprised to find out about this, but in teaching a couple of Maven courses two weeks ago, I did my usual "and you can go to the Maven Central repository at" - but things changed on me...

For years (since the inception of Maven), when you browsed that repository URL, you'd get a file listing of the entire repository, which you could drill down into manually.  Wanna see what's in commons-lang/commons-lang/2.6?  Just click away.  However, there was no search.  In fact, there were two search URLs that I knew of (and more I'm sure) - such as and (I think, that URL is offline now).

It looks like Nexus is powering the Maven central repo now, and also they've put a message up at that central URL:

Browsing for this directory has been disabled.

View this directory's contents on instead.

Huh.  Ok, so I'll bite...  If you go to the site, you'll see a nice search engine.  I typed in commons-lang, and lo and behold, there is a 3.0 version too.  Click on the image below to see the whole screen capture, if you're curious.


Maven Central Search Engine
Uploaded with Skitch!

I'm glad they did this. The Nexus repository gives useful reports on dependencies, and provides the mounting code for a number of dependency managers, including Maven, Ivy, Buildr, and more. A nice touch. By the way, the new URL to remember is!


My Maven doesn't build Codehaus anymore, what's wrong?

Recently Codehaus moved artifacts to the nexus repository system, and added a 302 MOVED directive to every request to the OLD repository. (See HAUS-1991).

But, Maven can't deal with this (I haven't tested this assumption in Maven 3.0.0, but it certainly fails in 2.x)

So, if you have:

  • a) Maven
  • b) a Codehaus plugin or artifact

and you try to build, you MAY get this error:

[INFO] Error building POM (may not be this project's POM).

Project ID: org.codehaus.mojo:jboss-packaging-maven-plugin

Reason: Error getting POM for 'org.codehaus.mojo:jboss-packaging-maven-plugin' from the repository: Unable to read local copy of metadata: Cannot read metadata from '/Users/krimple/.m2/repository/org/codehaus/mojo/jboss-packaging-maven-plugin/maven-metadata-codehaus.xml': end tag name  must match start tag name 
from line 7 (position: TEXT seen ...\n... @9:8) org.codehaus.mojo:jboss-packaging-maven-plugin:pom:LATEST

So, how do you fix it?

Semi-easy. First, replace any reference to the codehaus repos with these, as documented in the link to HAUS-1991 above:

  • Deploy snapshot artifacts into repository
  • Deploy release artifacts into the staging repository
  • Promote staged artifacts into repository 'Releases'
  • Download snapshot and release artifacts from group
  • Download snapshot, release and staged artifacts from staging group

Then you will have to delete the files that maven complains about in the .m2 directory - they'll be ones like org/codehaus/mojo/jboss-packaging-maven-plugin/maven-metadata-codehaus.xml - that contain the errant HTML document that sends a redirect header.

Do a mvn package again and you'll be set.

HTH, Ken

Kickin' Butt with Spring Roo at the command line with Maven shade plugin

Note: I just noticed, maybe it's something just added in 1.1.0 or later builds, but they have the assembly plugin integrated with the Roo Shell perform command. So you can do perform assembly and actually get an assembled jar with all dependencies. WOOT. Anyway, this is still useful for those who want to run Maven headless projects.Let's say you want to use Spring Roo to do persistence work, but you don't need a website. Maybe it's just a utility, something that, say uses iText to generate PDF files, or does some data processing, job execution, or some other headless task.

Spring Roo is built using Maven, and the build target generally start in an initial Roo project by deploying a JAR file, until you add Spring MVC by adding a controller. In Maven, the output of a given build is generally one thing, (the jar) so running the project might involve downloading a ton of JAR files to add to a very big classpath. That's a lot of work.

Alternatives - Maven Packaging Plugins

There are a number of maven packaging plugins that can assemble a Jar that includes all of your classes and property files from various source Jars. Several, including the Maven assembly plugin, and the one-jar plugin, didn't work for me out of the gate due to some problems loading some of the SpringSource XML schemas and extender languages.

The challenge is that these special files, META-INF/spring.handlers and META-INF/spring.schemas, are included in each of the extension JARs (like Spring Security, Spring MVC, JMS, etc) so that you can issue commands like this:

<mvc:annotation-driven />

These tools generally copy files into a temp directory and then jar it up, so they overwrite these files each time.

The Shade Plugin

The Maven shade plugin has a nice feature called a transformer. There is a special AppendingTransformer class that can be configured to continue to append data into a file specified in the configuration. Based on this article from Hagel Blog, I added two entries to the plugin configuration (as commented below) to fix the two META-INF files and we were in business.

So, without further adieu, here are the steps to single-jar happiness (at least so far) with Spring Roo and the Maven Shade plugin:

Step 1: Install the Shade Plugin to your pom.xml file

Using your STS or favorite editor, go to your maven build file, pom.xml, and add the following entry to the build -> plugins section (THANK YOU, Hagel Blog, for figuring out the problem with Spring's namespace files!):

      <transformer implementation="org.apache.maven.plugins.shade.
      <transformer implementation="org.apache.maven.plugins.shade.

Step 2: Run your maven build

Now you can just issue a mvn package command, which will package up your content in the JAR file directly.

Step 3: Execute your JAR

Go ahead now and cd to target, and issue a command like:

java -classpath ./artifact-jar-file-name.jar package.path.and.mainclassname

And that's it. Pretty nifty feature, no? Let me know if you've had success or problems with this approach.