Thursday, November 12, 2009

WebLogic OutOfMemory: PermGen Error

This error can appear when starting WebLogic Server and is easy to fix although it took a while for me to work that fix out! It's all to do with which Java Virtual Machine (JVM) you are using.

By default WebLogic Server uses Oracle JRockit as its JVM - it gets installed as part of the WebLogic installation. This JVM is fast but if you get errors it gives you a generic error message of Erroneous Handlers Error (see previous blog entry on this) - in order to find the real error you have to switch your JVM to Sun.

JRockit does not use something called "generational garbage collection" so it doesn't use something called "permanent generation space" - therefore you never get PermGen errors.

(Permanent Generation Space (PermGen) is info that JVM keeps about the classes that are being run).

Sun's JVM uses PermGen so you will get the PermGen error if so many classes have been loaded that it has run out of memory to store them.

The fix is to set the amount of memory for PermGen using the -XX:MaxPermSize java option.

In setDomainEnv.sh (domain/bin dir) search for USER_MEM_ARGS.

If this is not already set then set it as follows:

USER_MEM_ARGS="-Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
export USER_MEM_ARGS

(The key properties being XX:PermSize and XX:MaxPermSize).

Save and restart WebLogic and the error should have gone.

Wednesday, November 11, 2009

Init Blocks

What are INIT BLOCKs?

They are pieces of code that you write in the Admin tool to initialize repository and session variables.

For example you might have a variable that gives you the current date or another that says how many days there are left until the end of the quarter. You write init blocks to initialize these variables with the correct values.

Initializing Repository Variables

Init blocks that initialize repository variables are only run at a scheduled time. When you create one of these you set the time and scheduler to run. If the BI Server is restarted they also get run.

Initializing Session Variables

Init blocks that initialize session variables are not run at a scheduled time. Instead, every time a user begins a new session these variables are initialized and they remain unchanged for the length of the session.