views:

315

answers:

5

Sometimes, when we're doing small changes to our web apps, e.g. bug fixes, we don't build a whole new WAR-file each time, but merely replace just the affected class files in the exploded web app directory under WEB-INF/classes and restart the app.

Is that okay?

+11  A: 

I'd say that probably isn't a best practice, because of versioning: how do you know which version of the application you've got deployed? If you deploy a .war file your build process can take care of updating a build number (from source control, or separately, whatever - as long as each build has a different number it's OK).

If you're using continuous integration (and it's definitely a good idea to be) then your build process should be kicking out an 'artifact' (war file) each time you make changes in source code. also perhaps tagging the code in version control with the build number.

So, when you deploy your web app, you know exactly which version is running and which source code makes up that version.

Making small incremental changes by updating individual .class files I'd say is probably not a good idea for anything other than local developer testing.

Phill Sacre
A: 

Agree with PHill; it seems the time savings are negligible and the potential risks are many

davetron5000
+2  A: 

You can solve your deployment tasks using maven.

Every time you change anything, just type

svn update
mvn clean compile war:exploded tomcat:inplace -P deployment

you have 'deployment' profile in your pom.xml file, containing all the configuraiton needed for deployment environment.

this way you can event automate the deployment process and never fail when manually copying wrong/old/etc files.

miceuz
A: 

Technically speaking, as long as class/method signatures are the same, it should work. But as Phill points out, it is not the best idea in the world.

I am assuming that you are neither using Apache Ant nor Apache Maven to create your .war file. I highly recommend that you pick a tool that can automate the creation of the .war file, precisely to avoid the kind of manual hacks like you are talking about. I personally use Maven and it takes care of compiling, running unit tests and packaging my application. Good stuff :)

Guðmundur Bjarni
A: 

Injecting an updated class file into the application should only be done on a limited basis and should not be a standard activity for a build. That being said, I've seen it done on large applications where an entire rebuild/repackage would take hours, and the bug fix was needed ASAP. Hope it helps.

Neal Swearer