Tuesday, December 22, 2009

WebLogic Server : Flush the Application Cache

" On our system, what I normally do is to stop the server with the cache that needs to be flushed, then delete the tmp and cache directories of the server "

- Java Ranch Forum Post

Weblogic server maintains certain "caches" in tmp and cache folders. The caches can sometimes prove to be nuisance - especially, the tmp folder.

You can usually find the tmp folder for your application under :-

$DOMAIN_HOME/tmp/_WL_user/myApplication/
I recently ran into this issue and it gave me a couple of sleepless nights.

I had deployed my Application and started it. I then hit the URL in my browser and promptly received an error, which indicated that my cocktail of JAR files were sour and some libraries did not like the other ones.

During the next iteration of development, decided to use newer versions of a particular library. I deleted all the old libraries, provided a "gold" set of libraries ( that were certified on the vendor's website ) and then re-deployed my application.

However, I still noticed that same error. I was baffled as I was *certain* that I had removed all the old libraries.

First, I decided to investigate which JAR file was contributing the class. I retorted to good ol' Java Reflection for this - I just put this neat little piece of code in my Servlet :-

.class.getProtectionDomain().getCodeSource().getLocation();


I printed this using a simple statement and ensured that the output gets imprinted in the Server's Domain Log.

Alright, I now redeployed my application and when I invoked the Servlet, I saw this in my log file :-

$DOMAIN_HOME/servers/tmp/_WL_user/myApplication/ub48zr/war/WEB-INF/lib/myOldJARFile .jar

Bingo ! I promptly cleared the "cache" and redeployed the application. I re-invoked my Servlet and it works fine !!

I have modified my build.xml to include this minor operation - to clear the contents of the _WL_user folder and then undeploy / redeploy.



No comments: