How do I have weblogic reload cached JSPs on restart

BestPractices picture BestPractices · Sep 10, 2012 · Viewed 14.4k times · Source

Our method of deploying a new version of an app for weblogic (11g) is to copy over top of the existing ear file and then stop and restart the weblogic server. We do a start/stop of weblogic rather than a redeployment, because of the known permgen issue (where eventually we will run out of perm gen and have to bounce the weblogic server).

However, this method of deploying has a drawback-- new JSP versions are not seen by weblogic. In order to fix this we have had to wipe out the contents of the tmp directory that maintain a cache of the compiled JSPs prior to restarting the server. Is there a setting that would tell weblogic to wipe the cache/reload/recompile JSPs when it starts back up?

Answer

Chucky picture Chucky · May 28, 2013

Changing the JSP refresh timer

A standard solution is to tell Weblogic to check JSP freshness more frequently by either setting the value in your web.xml or in your weblogic.xml.

In production mode, Weblogic won't check for new JSP versions (default value: -1) while it does each second in development mode (default value: 1).

The choice between modifying web.xml or weblogic.xml is up to you, regarding the application servers you target, being WebLogic only or not.

If you prefer to modify web.xml, then set a value for the context parameter weblogic.jsp.pageCheckSeconds as follows:

<context-param>
  <param-name>weblogic.jsp.pageCheckSeconds</param-name>
  <param-value>0</param-value>
</context-param>

If you prefer to modify weblogic.xml, then set a value for parameter page-check-seconds in the jsp-descriptor section. Here is the relevant excerpt from the documentation:

Sets the interval, in seconds, at which WebLogic Server checks to see if JSP files have changed and need recompiling. Dependencies are also checked and recursively reloaded if changed. The value -1 means never check the pages. This is the default value in a production environment. The value 0 means always check the pages. The value 1 means check the pages every second. This is the default value in a development environment. In a production environment where changes to a JSP are rare, consider changing the value of pageCheckSeconds to 60 or greater, according to your tuning requirements.

Source: http://docs.oracle.com/cd/E21764_01/web.1111/e13712/weblogic_xml.htm#i1038490

Forcing redeployment

Restarting Weblogic server does not force it to redeploy a Web Application (especially in production mode).

Solution Trigger explicitly the "redeploy" life-cycle operation using command line like this:

java -cp weblogic.jar weblogic.Deployer -redeploy [-remote -adminurl t3://hostname:hostport] -username login -password password -name webapp.name [-upload -source webapp.war]
  • Note that -redeploy is WAYS much safer than -update, esp. with Weblogic <= 10.x

  • Keep first block between [ ], only if the server is not local. Remove the [ ] in that case.

  • Keep second block between [ ], if you want to combine the WAR file uploading in the same step, which is way simpler. Remove the [ ] in that case.