Programmatically Force JSP Reload
Hello, I am developing an app framework that has a very costly startup cycle. Consequently, I try to avoid restarting apps because it takes a long time for the core to get spooled up. In this vein I have a custom classloader that reloads the WEB-INF/classes directory without doing a full restart of the app. I've run into a problem, however, in JSPs. It's possible for JSPs to contain a reference to a .class file that becomes stale when I reload behind the scenes, which results in a ClassCastException. The bottom line here is that I am searching for a way to programmatically force tomcat to drop all loaded JSPs from memory. I do not need to recompile them, just reload the classes. However, if compilation and reloading are inextricably linked, that's a cost I'm willing to accept. I've tried looking around the documentation and searching the mailing list, but I've been unsuccessful so far. Any insight is greatly appreciated. Thanks! -Eric -- View this message in context: http://www.nabble.com/Programmatically-Force-JSP-Reload-tp21715300p21715300.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Programmatically Force JSP Reload
Not sure if this helps you or not. You could use the following. www.yourdomain.com/jspfile.jsp?jsp_precompile=true You may be able to use this to your advantage somehow. Landon Fabbricino IT Applications Phone: 403.225.7515 Fax: 403.225.7604 lfabb...@agrium.com From: Eric Grunzke eric.grun...@gmail.com To: users@tomcat.apache.org Date: 1/28/2009 2:20 PM Subject:Programmatically Force JSP Reload Hello, I am developing an app framework that has a very costly startup cycle. Consequently, I try to avoid restarting apps because it takes a long time for the core to get spooled up. In this vein I have a custom classloader that reloads the WEB-INF/classes directory without doing a full restart of the app. I've run into a problem, however, in JSPs. It's possible for JSPs to contain a reference to a .class file that becomes stale when I reload behind the scenes, which results in a ClassCastException. The bottom line here is that I am searching for a way to programmatically force tomcat to drop all loaded JSPs from memory. I do not need to recompile them, just reload the classes. However, if compilation and reloading are inextricably linked, that's a cost I'm willing to accept. I've tried looking around the documentation and searching the mailing list, but I've been unsuccessful so far. Any insight is greatly appreciated. Thanks! -Eric -- View this message in context: http://www.nabble.com/Programmatically-Force-JSP-Reload-tp21715300p21715300.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org IMPORTANT NOTICE ! This E-Mail transmission and any accompanying attachments may contain confidential information intended only for the use of the individual or entity named above. Any dissemination, distribution, copying or action taken in reliance on the contents of this E-Mail by anyone other than the intended recipient is strictly prohibited and is not intended to, in anyway, waive privilege or confidentiality. If you have received this E-Mail in error please immediately delete it and notify sender at the above E-Mail address. Agrium uses state of the art anti-virus technology on all incoming and outgoing E-Mail. We encourage and promote the use of safe E-Mail management practices and recommend you check this, and all other E-Mail and attachments you receive for the presence of viruses. The sender and Agrium accept no liability for any damage caused by a virus or otherwise by the transmittal of this E-Mail. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Programmatically Force JSP Reload
Thanks for the response, but that doesn't appear to solve my problem. I'm not really concerned with when jsps are compiled, or even when they are loaded, but rather when they are reloaded. Allow me to provide a sample jsp: %...@page import=load.test.Car% html body % out.write(Car.get(Mustang).getTopSpeed() + br/); % /body /html This code will execute with no difficulties, until the domain model changes for the type Car. Once changed, my framework will reload the definition of Car, but tomcat will not reload the jsp, because it is unchanged. The next visit to the jsp will throw a ClassCastException, as Car.get() in the jsp will return the new class definition of Car, but attempt to cast it to the old definition of Car that the jsp still has in memory. I can manually fake it by overwriting the jsp with an identical copy of itself, which tomcat detects and then reloads. This (along with additional sandboxing I've done) proves that the jsp classes hold on to stale definitions. Thus I need to reload (but not necessarily recompile) jsp classes when I reload domain classes, and I need to be able to do it programmatically. -Eric Landon Fabbricino wrote: Not sure if this helps you or not. You could use the following. www.yourdomain.com/jspfile.jsp?jsp_precompile=true You may be able to use this to your advantage somehow. Landon Fabbricino IT Applications Phone: 403.225.7515 Fax: 403.225.7604 lfabb...@agrium.com -- View this message in context: http://www.nabble.com/Programmatically-Force-JSP-Reload-tp21715300p21718708.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Programmatically Force JSP Reload
Hi Eric, If you call touch on the JSP does it update? This used to work on versions of JRun back in the 90's. Just a shot in the dark... Kirk Eric Grunzke wrote: Hello, I am developing an app framework that has a very costly startup cycle. Consequently, I try to avoid restarting apps because it takes a long time for the core to get spooled up. In this vein I have a custom classloader that reloads the WEB-INF/classes directory without doing a full restart of the app. I've run into a problem, however, in JSPs. It's possible for JSPs to contain a reference to a .class file that becomes stale when I reload behind the scenes, which results in a ClassCastException. The bottom line here is that I am searching for a way to programmatically force tomcat to drop all loaded JSPs from memory. I do not need to recompile them, just reload the classes. However, if compilation and reloading are inextricably linked, that's a cost I'm willing to accept. I've tried looking around the documentation and searching the mailing list, but I've been unsuccessful so far. Any insight is greatly appreciated. Thanks! -Eric - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Programmatically Force JSP Reload
Thanks for the reply, Kirk. Calling touch probably would force Tomcat to reload the jsp, but it's not a complete solution. In production environments, Tomcat polls the filesystem for changes, so until the next polling cycle hits, the app would still get a ClassCastException. Additionally, there are performance implications for for continually recompiling in a production environment (the default checkInterval is zero, which results in no runtime checks for modification). I considered calling touch or making a trivial change to the jsp (like extra whitespace at the end), but I can never completely eliminate the failure window that way, and it's a bit of a kludge anyways. When Context.reload() is called, something in there reloads the jsps. I just need to find that something. -Eric Kirk True wrote: Hi Eric, If you call touch on the JSP does it update? This used to work on versions of JRun back in the 90's. Just a shot in the dark... Kirk -- View this message in context: http://www.nabble.com/Programmatically-Force-JSP-Reload-tp21715300p21721735.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org