Thursday, October 10, 2013

Websphere Application Server: Use a cleanup batch file instead of coding in debug mode

Typically, we run our application servers in debug mode when we code so it picks up our changes on java files without the need to restart the server before we run our applications. However, early on at some point the Websphere Application Server (WAS) stops picking up our changes even  in debug mode.

A better alternative to running in debug mode (and the method I much prefer) is starting the application server  through a normal start and using a batch file to clean up the WAS temporary files.

I just run the batch file below to clean up  the application server's temporary files every time I make changes to java and jspf files. You should also clear your browser's cache and reload the application on your browser. No need to restart the application server.

Here is the code for the batch file:

@echo off
set WCT_WASPROFILE=D:\IBM\WCToolkitEE60\wasprofile
REM Delete WebSphere Commerce Developer Temp Files
set DIR=%WCT_WASPROFILE%\temp\localhost\server1\WC\Stores.war
set DIR2=%WCT_WASPROFILE%\wstemp
set FILE=%WCT_WASPROFILE%\javacore.*.txt
set FILE2=%WCT_WASPROFILE%\heapdump.*.phd
set FILE3=%WCT_WASPROFILE%\logs\server1\*.*

ECHO.
ECHO Cleaning WAS Temp Directory:
ECHO    %DIR%
rmdir /Q /S %DIR%
ECHO.
ECHO Cleaning WSTEMP Directory:
ECHO    %DIR2%
rmdir /Q /S %DIR2%
ECHO.

ECHO Cleaning Javacore Files:
ECHO    %FILE%
DEL /Q /F %FILE%
ECHO.
ECHO Cleaning Heapdump Files:
ECHO    %FILE2%
DEL /Q /F %FILE2%
ECHO.
ECHO Cleaning Server1 Logs Files:
ECHO    %FILE3%
DEL /Q /F %FILE3%
ECHO.
ECHO Cleaning Complete...
ECHO.
PAUSE


Remember though that at some point the application server will stop picking up your changes and will need a restart. But it will be way much longer before that happens compared to when running in debug mode.

Happy coding!


No comments:

Post a Comment