Re: [Winstone-devel] I/O not working in shutdown()
Status: Beta
Brought to you by:
rickknowles
From: Rick K. <ri...@kn...> - 2006-05-03 04:51:05
|
All, Please forgive me for reposting this, but my ISP's SMTP server has been blacklisted by Spamcop, so I keep getting bounce messages from sourceforge rejecting me as a spammer. I'm never sure which ones are getting through. Don't worry ... the ISP's ass is grass. I'm organizing a new one later this week hopefully. Apologies if it results in some of you getting multiple copies of the same message. Rick Rick Knowles wrote: > Artur, > > Thanks, this is much better info. It was difficult to tell earlier > whether the shutdown you referred to was a complete container shutdown > (ie process killed) or a webapp shutdown (like the kind triggered by > the reloading class loader). The stacktrace has cleared that up, and > it looks more like a straight container shutdown problem. > > This does look like something more container related. Could you send > me a demo warfile please ? I'm quite keen to work this out ... seems > to be something quite subtle by the look of it. > > Thanks again, > > Rick > > randomJavaTroll wrote: >> Hello! >> >> I don't quite understand your answer. I did not want to keep >> persistent IO across web app instances, I wanted to open the IO in >> contextInitialized and close it in contextDestroyed. The IO stream >> was indeed a static variable. Could it make any problem if the IO is >> presumably closed/reopened on app restart? >> >> I changed the code so that Notifier is now an object constructed in >> contextInitialized, and accessed within the app using ServletContext. >> The code of the listener is now as follows: >> >> public void contextInitialized(ServletContextEvent event) { >> try { >> Notifier notifier = new Notifier("bin/event_handler"); >> >> event.getServletContext().setAttribute(Notifier.CONTEXT_ATTRIBUTE, >> notifier); >> } catch(IOException e) { >> System.out.println("Could not initialize notifier: " + >> e.toString()); >> System.exit(1); >> } >> } >> public void contextDestroyed(ServletContextEvent event) { >> Notifier notifier = (Notifier)event.getServletContext(). >> getAttribute(Notifier.CONTEXT_ATTRIBUTE); >> notifier.shutdown(); >> >> event.getServletContext().removeAttribute(Notifier.CONTEXT_ATTRIBUTE); >> } >> >> I am not sure about using servletContext.getAttribute() from within >> contextDestroyed(), but it seemed to work. >> >> Yet, the problem is the same -- writing to the output stream is fine >> but in the notifier.shutdown() method. I got IOException: Broken pipe >> again. >> >> Here is the backtrace you asked for: >> >> Stack trace: java.io.IOException: Broken pipe >> at java.io.FileOutputStream.writeBytes(Native Method) >> at java.io.FileOutputStream.write(FileOutputStream.java:260) >> at >> java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) >> at >> java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) >> at events.Notifier.notify(Notifier.java:450) >> at events.Notifier.shutdown(Notifier.java:369) >> at >> events.NotifierHandler.contextDestroyed(NotifierHandler.java:37) >> at >> winstone.WebAppConfiguration.destroy(WebAppConfiguration.java:1136) >> at >> winstone.HostConfiguration.destroyWebApp(HostConfiguration.java:141) >> at winstone.HostConfiguration.destroy(HostConfiguration.java:149) >> at winstone.HostGroup.destroy(HostGroup.java:75) >> at winstone.Launcher.shutdown(Launcher.java:345) >> at winstone.ShutdownHook.run(ShutdownHook.java:24) >> >> If this is not enough and you were so kind to test the war file, I >> might send it to you. >> >> Thanks, >> Artur >> > -- Servlet v2.4 container in a single 160KB jar file ? Try Winstone (http://winstone.sourceforge.net/) |