GeeCON Prague 2014*
The moose likes Java in General and the fly likes How do I incrementally patch a war file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I incrementally patch a war file?" Watch "How do I incrementally patch a war file?" New topic
Author

How do I incrementally patch a war file?

Christopher Lee
Greenhorn

Joined: Aug 24, 2011
Posts: 4
My war file is currently around 20mb. Sometimes I have small changes that need to be made and I would like to be able to send to the customer only the parts of the application that need to be updated, instead of sending the entire war file for every update.

The solution needs to be generic and work with any type of web application server and environment.

Thanks,
Chris
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14196
    
  20

Using the jar tool (included with the JDK) you can extract, update etc. individual files inside a WAR file.

If you can update a WAR that is deployed on an application server incrementally depends on whether your particular app server supports that.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Christopher Lee
Greenhorn

Joined: Aug 24, 2011
Posts: 4
I can't rely on my customers having the jdk installed so that they can update the war file. Most will only have the jre.

Is there another way?
Lanny Gilbert
Ranch Hand

Joined: Jun 11, 2002
Posts: 103
As Jesper said, you can use the JAR tool to add incrementally newer versions of certain files to your WAR. That's the only way that I'm aware of to do it.
So, I don't think it's a technical issue you're trying to solve, but a process issue.

As an old timer, I would highly recommend against giving the customer the "deltas" and then letting them update the WAR. That is fraught with peril.

20MB over FTP takes a couple minutes. I think you're *much* better off building the WAR yourself (making sure you have a copy that *exactly* matches
what your customer has for adding the new stuff).

My $0.02...
Christopher Lee
Greenhorn

Joined: Aug 24, 2011
Posts: 4
What about OSGi? I've been reading a little about it and it sounds like it might allow for what I'm trying to do.

The OSGi technology provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components. These components can be composed into an application and deployed.

The OSGi Service Platform provides the functions to change the composition dynamically on the device of a variety of networks, without requiring restarts.


Or am I reading too much into this? It also sounds a bit like the dependency injection feature of Spring (which I am currently using).


Also, I know that my war file is smallish at the moment (20 mb), but I'm planning on adding lots of new features over the next year or two. Assuming my war file gets to 100+ mb, do I really have to send the whole war file every time? How to the major companies handle this problem with their large applications?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14196
    
  20

Do you really want to let your customers update the WAR file themselves? I don't know if that is a good idea... (assuming they are not Java developers). What if they do something wrong so that your software doesn't work anymore?

If there are resources that they have to be able to change themselves, then you could store them somewhere else, not inside the WAR file. Then they'd just have to put the right files in a directory somewhere and your webapp will pick them up from there.

What exactly are the replaceable parts of your application? Just data files (HTML pages, images, ...) or runnable code?
Christopher Lee
Greenhorn

Joined: Aug 24, 2011
Posts: 4
Jesper de Jong wrote:Do you really want to let your customers update the WAR file themselves? I don't know if that is a good idea... (assuming they are not Java developers). What if they do something wrong so that your software doesn't work anymore?

I agree with you on this point. I don't like the idea of forcing the customer to manually repackage the war file. I am wondering what common strategies are used by others when dealing with this problem (multiple war/jar files, optional packages, etc). So far I haven't found a solution that works other than repackaging/redistributing the entire war.

Jesper de Jong wrote:What exactly are the replaceable parts of your application? Just data files (HTML pages, images, ...) or runnable code?

I would need to replace both static files(xml,xsl,js,etc) as well as updates to class files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I incrementally patch a war file?