views:

91

answers:

2

I'm working on a layered business application written in Java that should be packaged as an EAR file and deployed to a JBoss application server. There's a web-application layer, a service layer, a domain layer but no persistence layer. At least on paper.

What is the best practice for deploying the different layers? In our team we have a little religious war going on between:

  • Packaging each layer in its own JAR file (e.g. in its own Maven module), and adding each module to the EAR file, OR
  • Bundling everything together in a single JAR file, with each layer mapped to a package naming convention.

Are there other possibilities I'm missing? What are the best practices in this area? Are there any online or offline resources I could consult about this?

+2  A: 

In my company, we bundle each layer into its own JAR. Then we include it in a WAR.

If you don't have any EJBs that need managed, there's no real advantage to using an EAR over a WAR for deployment.

Zack
+1 : personally I like the separation breaking the layers into different jars gives you. I think it helps maintain the correct dependencies between the layers, which can only help maintain the system structure.
Nick Holt
+1 for packing layers into separate jars.
javashlook
A: 

Whichever approach you choose, make sure you actually gain value out of it. In other words, don't serve the architectural principle (package/jar) let the architecture principle serve you.

You need to balance separation of concerns with efficiency. The more projects you have the more cumbersome things become, but if you have one project, that can also be cumbersome.

Look at your requirements, context and size of your application and decide which approach is going to serve you best.

Michael Wiles