• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File is deleting when calling shutdown.bat

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic