Page 1 of 11

Tag Archive for 'java'

Tomcat Context File “Mysteriously” Disappeared or Deleted

If you’ve done any Java web project deployment on Tomcat which involves NFS or SAN, you might have encountered a scenario where the Tomcat context file (\jakarta-tomcat\conf\Catalina\localhost\context.xml) mysteriously disappeared, especially after server restart.

Looks like it’s a Tomcat bug, you may refer to the Bugzilla record for further information.

This issue will only happen if the physical location of the web folder is different from Tomcat. For example, the Tomcat context could be configured with docBase residing in remote storage such as SAN or NFS.

When Tomcat detected that the web folder specified in docBase is not reachable, such as during storage server restart or network disruption, then the context file will be automatically deleted. Some may call it a feature though :p

How to Resolve in Linux?

In Linux, you can issue the following command to make the context file immutable. It’s like giving it “power overwhelming” StarCraft cheat…. will never die hahahaha

chattr +i /opt/jakarta-tomcat/conf/Catalina/localhost/ROOT.xml

Please change the location path accordingly.

chattr +i is to make the file immutable, it can’t even be deleted by root user.

If you try rm /opt/jakarta-tomcat/conf/Catalina/localhost/ROOT.xml, you will get “Operation not permitted”… wah really never die

What if one day, you decided to remove its immutable status??

Instead of chattr +i, just use chattr -i will do

Sorry but I don’t have solution for Windows yet.

Anyone with better alternatives?