How To Reuse Java EE 6 WAR Code With Maven (3)

In Java EE 6 WAR is the new EAR. A WAR, however, is entirely "installed" to the maven 3 repo. It's contents (like JAXB-DTOs), cannot be reused from other applications.
Configuration of maven-jar-plugin and maven-install-plugin solves the issue. The first plugin creates a JAR and the latter installs it into the local repo:


After configuration of both plugins, WAR contents are redundantly stored as JAR in the local maven repository and are accessible to other projects by specifying a "usual" dependency to it.

You could also use the attachClasses tag to deploy the jar in addition to the WAR with the "classes" classifier (as suggested by struberg):


But then you will also have to specify the classifier in the dependency:


NetBeans 7 + git - A Smoke Test

NetBeans 7 supports git. The git plugin has to be installed first (Tools->Plugins and search for git). The installation is fast (the plugin is < 1MB).
Some observations:

  1. git plugin supports: Show Changes, Add, Commit, Diff, Branches, Checking out a revision, Merging, Fetch and Disconnect
  2. Repository browser: (Team -> Git -> Repository Browser)
  3. Bug tracking integration (in the commit panel)
  4. My favorite: NetBeans "downlights" files included in .gitignore
I tested it with x-ray and it works great. The git-plugin should be shipped with the next NetBeans 7.X release. 2.0 ...Rocks! is the old, but nice URL, with the great infrastructure behind. I created the x-ray project, which is a vanilla Java EE 6 "analytics" software installed on this blog and sample application for the "Real World Java EE Night Hacks--Dissecting the Business Tier" book as well. What I appreciate:

  1. Freedom of choice: you can choose between SVN, HG, GIT or external repositories. Even register multiple repos for a single project
  2. Support for wikis, message forum, mailing lists, or chat. You can even setup the whole website from scratch
  3. Support for webhooks - you can register webhooks to drive your CI server
  4. Real Time Feedback - all changes are visible instantenously
  5. Clean and modern design
  6. Convenient and fast management - I was able to setup x-ray in 10 minutes during a lunch break...

Why I used for about 2 years and it worked perfectly. can be considered as "kenai on steroids" - it comes with additional features like e.g. git support.

Real World Java EE Night Hacks--Dissecting the Business Tier - Available On Kindle

The book Real World Java EE Night Hacks--Dissecting the Business Tier is available on Kindle (worldwide). If you dont't have a kindle - there are free readers available for iPad, iPhone, Mac, Windows, Android, BlackBerry... as well.

Enjoy reading - feedback is highly appreciated!

Real World Java EE Night Hacks--Dissecting the Business Tier Book and Project

The book Real World Java EE Night Hacks--Dissecting the Business Tier is available as softcover (print), Kindle (worldwide) hardware, kindle software reader (Win, Mac, Android, BlackBerry iPhone and iPad) and Adobe Digital Editions eBook (epub)
Real World Java EE Night Hacks dissects a plain vanilla Java EE 6 application "x-ray". It measures the traffic and statistics of this blog and comes with Roller 4 integration - just look at the right area to see it in action. With this post x-ray will the first time measure the popularity of itself :-). Real World Java EE Night Hacks includes coverage of:

  • A brief introduction into the core principles of Java EE 6 (EJB 3.1, CDI, JPA, JTA,Dependency Injection, Convention over Configuration, interceptors, transactions, REST) using real world code
  • Unit and integration testing of Java EE 6 applications using JUnit and ScalaTest
  • Using interceptors for performance measuring and monitoring
  • Creating mocks with Mockito for EJB 3.1, CDI, JPA, and JAX-RS
  • Developing embedded integration tests with Arquillian
  • Productive use of JAX-RS, Contexts and Dependency Injection, EJB 3.1, and JPA
  • RESTful services and REST clients with Java EE 6
  • Convention over Configuration with Java EE 6
  • Effective component configuration with CDI and Convention over Configuration
  • Plug-in implementation with CDI
  • Transactional pub/sub without JMS based on CDI and EJB 3.1
  • Continuous integration with Maven 3, Mercurial/Git, and Hudson/Jenkins
  • Implementing configurable timers and asynchronous batch processing
  • Eventual consistency and high-performance deferred writes with Java EE 6
  • Real-time client and server monitoring with JMX and REST
  • Functional testing with FitNesse
  • Performing stress and load tests
  • Simplest possible, but maintainable, Java EE 6 design and architecture
Special thanks to James Gosling, ( for the foreword:

"Most books for software developers are horizontal slices through some piece of the technological landscape. "X for Dummies" or "Everything you need to know about X." Breadth and lots of toy examples. This book takes a largely orthogonal approach, taking a vertical slice through a stack of technologies to get something very real done. Adam takes as his organizing principle one real Java EE application that is not a toy, and goes through it, almost line-by-line explaining what it does, and why. In many ways, it feels like John Lions', Lions' classic Commentary on UNIX 6th Edition.

One of the problems that people often have when they start looking at Java is that they get overwhelmed by the vast expanse of facilities available. Most of the APIs have the interesting property that the solution to any task tends to be pretty simple. The complexity is in finding that simple path. Adam's book shows a path to a solution for the problem he was trying to solve. You can treat it as an inspiration to find your own simple path to whatever problem you have at hand, and guidance on how various pieces fit together "
Real World Java EE Night Hacks - Dissecting the Business Tier will benefit experienced developers and architects interested in code, not PowerPoint slides :-).

I will cover the topics in subsequent posts - so the content of the book will become more technical again :-). The source code was pushed into the GIT-repository:

All samples were tested with Glassfish v3 - v3.1, developed with Netbeans 7 and IntelliJ, built with Maven 3 / Hudson, managed by Mercurial / GIT, unit tested with JUnit / Scala Test, mocked with Mockito, functional tested with fitnesse, and quality-measured with SonarSource.

Online Workshops
...the last 150 posts
...the last 10 comments