Question

I was wondering if there is a way to put all the needed .jars in a separate .war/ear so that when I made a minor change in my code I don't have to deploy all the library .jars to the server?

Because uploading 50mb (to an offside Tomcat server) every time I want to test a change/during development is not a great way to spend your time.

Most topic I read on SO stated that you do want a self containing .war file. In this case it is only shared with 1 .war file. Not sure if this is possible with some kind of library reference in the deployment descriptor.

Was it helpful?

Solution

According to the Java EE Spec, your .jars are supposed to be deployed to WEB-INF/lib within your WAR file. I have seen some folks hack the Tomcat classloader to pull from an external directly (especially after Tomcat 5+ removed support for CATALINA_HOME/shared/lib), but that has its obvious downsides.

I'd suggest looking at changing your deployment process instead of changing the code. You can actually do an "exploded WAR" deployment to appBase (see Tomcat docs), and only transfer the files that have changed.

I work for Inedo, and I've seen a lot of users do this with BuildMaster. The workflow looks something like this:

  1. Get Latest from $/MyApp
  2. Run Ant (build.xml)
  3. Unzip MyApp.war
  4. Create Build Artifact
  5. Stop Tomcat Service
  6. Deploy Build Artifact to SERVER (/path/appBase)
  7. Start Tomcat Service

The last step (Deploy Build Artifact) will only deploy the files that changed, which will greatly reduce the time it takes to deploy your 50MB artifact.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top