jQuery in Action, 3rd edition
The moose likes Tomcat and the fly likes File is deleting when calling shutdown.bat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "File is deleting when calling shutdown.bat" Watch "File is deleting when calling shutdown.bat" New topic

File is deleting when calling shutdown.bat

sal sathya

Joined: Jul 28, 2010
Posts: 11
HI All,
In special situation i want a set of data that has to be store in a .ser file,means some values that has to store if tomcat is shutdown,and when tomcat restarted those values has to read from the file,so i use serialization of java and store the data at "tomcat_home\webapps\axis2\WEB-INF\classes"=='SaveValue.ser'.
In my program i used
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
.println("---------------------Running Shutdown Hook-----------------------------");
the writeObjects() will do the serialization as described here http://www.javabeginner.com/uncategorized/java-serialization .
if i click close button or press cntl-C while tomcat is running the SaveValue.ser will created and store in the location tomcat_home\webapps\axis2\WEB-INF\classes ,but when i click shutdown.bat the file is not creating .
what is the problem how can do serilization with tomcat restart in axis2 webservice.please help me
Thanks in advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

You should NEVER write files to anywhere inside a WAR. It's neither safe nor reliable. Always write them somewhere outside the WAR. The WAR should be treated as read-only, because in many cases it actually is read-only.

You're also not doing yourself any favours by using Windows-style pathnames. If you forget to escape the backslashes, you can get in all sorts of trouble. It's safer to use forward slashes when working in Java.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: File is deleting when calling shutdown.bat
It's not a secret anymore!