17

A very simple question. I have a .war(~40MB) file to be run on JBoss. What is the best practice for deployment: Should the war file be deployed in exploded format? Or not?

I ask because if its exploded then I've a choice of updating my properties file anytime I choose to (and need not make a new war every time I change the properties file).

But I'm not sure if deploying a war in exploded format is the best practice.

Please help me realize. :)

JJJ
  • 32,902
  • 20
  • 89
  • 102
pavanlimo
  • 4,122
  • 3
  • 32
  • 47
  • Also, who decided to call it 'exploded' instead of just 'extracted'? Sure it's more fun but we of all people should call a thing what it is :). – bbarker May 05 '16 at 13:07

4 Answers4

15

Should the war file be deployed in exploded format? Or not?

This would depends on several factors:

  • Will you require that application-server administrators modify the contents of the WAR file after deployment? If the answer is yes, especially in the cases where property or configuration files are concerned, then you ought to be using an exploded format. This would make it easier to make changes in the files, without requiring a redeployment of the complete WAR file.
  • How do you propagate changes to production? If you are not pre-compiling your JSP files, and if you are intending to deploy newer versions of JSPs by copying them over to the area containing the exploded WAR file, then it is quite obvious that re-deploying a huge WAR file is not an optimal solution. However, do note that this would depend on your deployment practices. Often, it is easier to audit that the WAR file in production is a replica of a generated build from version control, with a single hash of the WAR file. If you deploy incremental changes, you will find that hashes will be required for every file deployed.
  • How soon do you want your application to be deployed and made available? This point is trivial, but there are enough instances of applications that take several minutes to start because the application server is busy exploding the WAR file and recreating the necessary artifacts. This could lead to significant downtime, if the behavior of the server is to explode the WAR file on every restart of the application server. Since I am unaware of the behavior of JBoss or the specific version in question, I would suggest that you verify this on your own, to ensure that you can limit downtime to an acceptable level.
Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
9

Modifying the exploded contents is certainly faster and more efficient, but one consideration is auditing and traceability. One advantage of only deploying WAR files and treating them as "sealed" is that any changes you make will have to be captured in your source code management system. You certainly don't want people to have the ability to change whatever they wish in your application's configuration without some kind of audit trail.

The Java EE separation of concerns usually means that the developer of the WAR is not the same person as the admin for the app server. If the developer does not have direct access, that means that folks who don't know the application thoroughly are making changes.

I'm not defending the extreme mentality that forbids developers from modifying an exploded WAR, just pointing out an alternative view for your consideration.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • Thanks @duffymo. I'll consider it. However, based on my requirements, so far the balance is tilting towards explode. – pavanlimo Jul 15 '11 at 10:24
  • A few years later I think this is more appropriate answer for the question. The answer being- do not explode unless you really really need to. – pavanlimo Jul 24 '17 at 23:10
2

If you need to change configuration within your .war without redeploying, I would prefer to deploy exploded. Otherwise I would prefer to deploy the file (then the jboss will extract the file into tmp/deploy/.. )

powerMicha
  • 2,753
  • 1
  • 24
  • 31
  • 1
    But is it "ok" to deploy in exploded format for production environment? – pavanlimo Jul 15 '11 at 07:41
  • 2
    yes, of course. Many other publishers do this as well (e.g. TeamCity, Hyperic HQ, ...) – powerMicha Jul 15 '11 at 07:42
  • Thanks @powerMicha for that bit of information. By any chance, are you aware of any docs/articles which talk about best practices for java web-app deployment? – pavanlimo Jul 15 '11 at 07:46
0

It gets exploded anyway so can you alter properties even if deployed as war ... it makes no difference. In development environment at least.

However, if you are deploying in exploded format to production so you can alter properties files isn't the bigger problem that you need to change properties (of production) after deployment ? And not whether you have used a war or not.

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311
  • I couldn't clearly understand you, but if you restart the server, changed property file is replaced by the original property file since the unwarring happens in a temp location. – pavanlimo Jul 15 '11 at 08:41
  • @pavanlimo I know, we changed the file in the temp location whilst developing. I am unsure if you are doing this in dev or production. My point is you should look at why you are changing properties in a production environment(if you are). If you are talking about dev, its not important, imho, but I prefer wars. – NimChimpsky Jul 15 '11 at 08:53