wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "File is deleting when calling shutdown.bat" Watch "File is deleting when calling shutdown.bat" New topic
Author

File is deleting when calling shutdown.bat

sal sathya
Greenhorn

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() {
System.out
.println("---------------------Running Shutdown Hook-----------------------------");
writeObjects();
}
});
}
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: 15964
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: File is deleting when calling shutdown.bat
 
Similar Threads
Problems with security policies for Axis2 in Tomcat
What in the world happened to JWS ??????
Tomcat 5.0.28 won't play with my servlet =(
JSP can't find bean classes
How to see my html file in my own directory