How to avoid copying 40M java lib to WAR when WAR size is 41M?

At the moment, my build process consists of repackaging the war file with all the necessary java libraries in WEB-INF / lib and then copying the war file to the development / demonstration / production server, which should be redistributed by tomcat.

The size of the packed military file is about 41 M, and currently it has about 40 M external java libraries. There must be a better way. How did you solve this problem?

My development machine is a window with Eclipse as my IDE and Ant as my build tool. Servers are all Linux boxes with Tomcat 5.5.

Should I add jar files to a server-side war package?

+6
java build-process tomcat ant
source share
9 answers

I can see what you say, and had the same frustration with some of our web applications, but to ensure consistency, I suggest you keep things as they are. If you copy libraries to the tomcat / lib directory, you may run into problems with the system path of the classpath compared to the classpath.

Keeping all that is, you are sure to deploy the same things in development / demonstration when you are in the process of production. Life sucks when you manually adjust the material in production, or you have a crazy mistake, because you forgot to update XYZ.jar from version 1.6 to 1.6.1_b33 in production and now it behaves differently from what you think , is the same code on the demo.

When working with something important enough to have dev / demo / production systems, I think consistency is a much more important issue than the .war file size.

+17
source share

We use the rsync tool to do this (in our case, using cygwin under the windows) to copy the deployments to the servers (which run linux). We use exploded WAR / EAR files (i.e. a directory structure called MyApp.war, not a zip file MyApp.war), rsync will only transfer files that have been modified.

In general, rsync will transfer our 30-40 megabytes of exploded EAR in 5 seconds.

+5
source share

Tomcat has a shared / lib directory, which is a suitable place for global application dependencies. However, they will be visible to all applications that affect dependency management and can have consequences for things like static variables. I'm not sure you can configure anything better in Tomcat.

An alternative is to switch to a more complex web container. For example, WebSphere Application Server Community Edition (a bluish version of Geronimo ) supports libraries for all assets . Other free and commercial servers also support this. I know WebSphere Application Server , and I'm sure you can do it in Glassfish .

+1
source share

@McDowell, when referring to these J2EE servers, you must specify that they are J2EE servers (servlet container + others).

Like @digitaljoel, I suggest storing things like them. It looks like you haven't done a lot of web application deployment yet. The problems you will have are not worth the price (version conflicts, deployment errors, etc.).

+1
source share

Can you add immutable Jars to the server side Java library path and include only regularly changing banks in your WAR?

0
source share

you can include external java libraries in the Tomcat / lib directory. Thus, they remain on the server.

0
source share

You can simply deploy as a JAR file, locally localize the deployment environment, and simply copy the files that have been modified and the jar itself. The path is the only real problem.

Or you could study setting up an EAR.

0
source share

I work with a "blown web application" on development servers, and sometimes in production. The deployment process (based on ANT) updates the JAR in WEB-INF / lib with our packages. Only on the development server do we activate a Tomcat reboot, which takes care of restarting the application when something changes. You need to assign some additional read-only memory to these Tomcats and have a way to reboot the server, since rebooting can break Tomcat from time to time.

I know this is a strange configuration, but I don’t understand how it would be better to repack 30 MB (and increase) of our typical application. One fine day, the development descriptor resolves external references to libraries that the container can load and cache. ??

Sorry my poor English.

0
source share

You need a version control tool and a build process.

Use CSV, SVN, GIT or whatever suits you to keep your source in check. use the build tool to build your application: Maven, ant, ...

Now, when you want to deploy the application on your server, you just need to fix your updates on your computer, update the source on your server, create the application and deploy it from the server.

Thus, the server just needs to load your changes, and it should be much faster.

0
source share

All Articles