Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 5.5: .jar not releasing on .war rebuild

Synopsis

I am attempting to export a WAR to my webapps folder but everytiime I update the war it deletes all of the content of the webapp minus /WEB-INF/lib/struts.jar

System info

  • Windows 2K3
  • Tomcat 5.5
  • JRE 1.6.23

Ok here is what is happening:

  1. Export project as .WAR via Eclipse (Helios) to /webapps directory
  2. Tomcat sees the change in the war and attempts to rebuild webapp
  3. Tomcat deletes contents of webapp folder (/webapps/public)
  4. (/webapps/public/WEB-INF/lib/struts.jar) is locked preventing it from being deleted.
  5. Tomcat gives up rebuild leaving me with nothing in the folder besides the struts.jar causing the application to break.

Question(s)

  • Is there a way to keep the jar from being locked?
  • (OR) a better deployment process I should be using (and can pick up quickly)?

Using antiResourceLocking="true" and antiJARLocking="true" on the <Context> element did not solve the problem. Appreciate any help.

like image 827
PseudoNinja Avatar asked May 05 '11 14:05

PseudoNinja


3 Answers

Does adding unloadDelay to your Context help?

Which is the:

Amount of ms that the container will wait for servlets to unload. If not specified, the default value of the flag is 2000 ms.

Source: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Apparently sometimes the web app is in the middle of a large GC / the ClassLoader hasn’t been garbage collected and cannot release in time. Try experimenting with the timeout to see if that helps.

There is also some anecdotal evidence of strange file locking on Windows platforms.

Also, assuming you're referring to a development (not production) build environment, look at one of my questions, showing my approach to Tomcat / Eclipse hot deploy environments:

Tomcat and Eclipse Zero Turnaround Deployment


Update

This helpful thread comes up on a Google search of the same issue and is referred to by a number of others:

http://blog.exis.com/colin/?s=I+Put+A+Spell+On+You

like image 70
Michael Avatar answered Nov 05 '22 10:11

Michael


I guess your requirement is to deploy and rebuild quickly given eclipse is ur IDE. As you have figured out exporting war file to webapps folder is not the best option. Few other options are

a) Use sysdeo tomcat plugin -- sysdeo deploys the project folder

b) Update build script to deploy in exploded format. -- deploy the \build folder as exploded application

First option is easiest. Second option is cleaner.

[OFF TOPIC] consider switching to tomcat 7

like image 33
kiran.kumar M Avatar answered Nov 05 '22 09:11

kiran.kumar M


Could this thread be of relevance? Cites the DTD in the tiles-config.xml causing issues.

like image 1
MJB Avatar answered Nov 05 '22 10:11

MJB