>Number: 4309 >Category: mod_jserv >Synopsis: Problem serialiazing to/from file from within servlet >Confidential: no >Severity: serious >Priority: medium >Responsible: jserv >State: open >Class: sw-bug >Submitter-Id: apache >Arrival-Date: Mon Apr 26 07:40:00 PDT 1999 >Last-Modified: >Originator: [EMAIL PROTECTED] >Organization: apache >Release: 1.3.4 + 1.0b3 >Environment: Solaris 2.6, JDK 1.2_01 Production release >Description: I am having a problem with a servlet, as described below:
My servlet collects up to two hours of data in a List. When I do something that causes my servlet zone to reload all of the servlets, I would prefer that the servlet didn't have to start collecting its data from scratch. To avoid this, in the destroy method I write out (serialize) the data List to a file. In the init method I read the data List back in if the file exists. The basic code in the destroy method: os = new ObjectOutputStream( new GZIPOutputStream( new FileOutputStream(saveFile))); os.writeObject(installations); os.flush(); The basic code in the init method: is = new ObjectInputStream( new GZIPInputStream( new FileInputStream(saveFile))); installations = (List) is.readObject(); In order to give enough time to do the disk read/write, I have made the following changes in the zone properties file: init.timeout=120000 destroy.timeout=120000 After Apache is restarted, the init method successfully reads in an existing file. If I do something that causes my servlet zone to reload all of the servlets, the destroy method successfully writes out the file. However, on the next initialization, the init method seems to freeze on the readObject() line (CPU usage drops to 0, and nothing more appears in the logs, suggesting that the next line never gets executed). I have to restart Apache - on the subsequent init the file is read successfully, so I know it was written properly in the destroy method. Because this works once, I suspect that the problem is with Apache JServ, and not with my code. >How-To-Repeat: >Fix: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, ] [you need to include <[EMAIL PROTECTED]> in the Cc line ] [and leave the subject line UNCHANGED. This is not done] [automatically because of the potential for mail loops. ] [If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request ] [from a developer. ] [Reply only with text; DO NOT SEND ATTACHMENTS! ]