Wednesday, May 9, 2012

How to Change JDK used by Weblogic Server

Hi all,

Sometime it is required to switch JDK used by weblogic server for example from Sun to JRockit (which gives better performance). Another use case could be to switch from 32 to 64 bit JDK as well as latest supported JDK. To verify supported JDK version check Oracle FMW support matrix


In this post we will switch JDK from Sun to JRockit and i assume we are on Linux environment find same configuration file name with .CMD extension if you are on windows.

Installing new JDK:


First step is to install your desired JDK. Follow these steps to install

1. Download JRockit JDK from OTN

2. FTP the file to server and unzip it by running following command

$ unzip  jrockit_282V30318-01.zip

3. The file will be extracted with .bin extension, change the permission and make it executable.

$ chmod 755 jrockit-jdk1.6.0_29-R28.2.2-4.1.0-linux-x64.bin

4. Install JRockit to your desired location (in my example i have xserver running).

Follow the wizard to complete the installation. I installed JRockit on /u01/Oracle/jrockit-r28.2.2


$ ./jrockit-jdk1.6.0_29-R28.2.2-4.1.0-linux-x64.bin

Changing Weblogic Configuration to use new JDK

1. Shutdown all managed servers in Weblogic domain

2. Backup the following files
$MW_HOME/user_projects/domains/<domain  name>/bin/setDomainEnv.sh
$WL_HOME/common/bin/commEnv.sh

e.g.
$ cd  /u01/Oracle/Middleware/user_projects/domains/base_domain/bin
$ cp setDomainEnv.sh  setDomainEnv.sh.before_jdk_change

$ cd /u01/Oracle/Middleware/wlserver_10.3/common/bin
$ cp commEnv.sh  commEnv.sh.before_jdk_change

3. Edit setDomain.env file and find ${JAVA_HOME}
     Comment the JAVA_HOME entry


#JAVA_HOME="${JAVA_HOME}"
#export  JAVA_HOME


4. Add the following after this


# Added the following lines to change to JRockit JDK
JAVA_HOME="/u01/Oracle/jrockit-r28.2.2"
export  JAVA_HOME
JAVA_VENDOR="Oracle"
export JAVA_VENDOR



5. Search the following section in the file, specifically for "-Djrockit.optfile":


Note: This parameter usually gives warning of being obsolete
you will find


EXTRA_JAVA_PROPERTIES="-Dcommon.components.home=${COMMON_COMPONENTS_HOME}   -Djrf.version=11.1.1  
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger  
-Ddomain.home=${DOMAIN_HOME}  
-Djrockit.optfile=${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt  
-Doracle.server.config.dir=${ORACLE_DOMAIN_CONFIG_DIR}/servers/${SERVER_NAME}  
-Doracle.domain.config.dir=${ORACLE_DOMAIN_CONFIG_DIR} 
......"

remove the "-Djrockit.optfile" property:
-Djrockit.optfile=${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt

6. Save the file

7. Edit commEnv.sh file, find the following section

if [ -z "${JAVA_HOME}" -o -z "${JAVA_VENDOR}" ]; then


8. Add the following line after above section
JAVA_HOME="/u01/Oracle/jrockit-r28.2.2"
export JAVA_HOME
JAVA_VENDOR="Oracle"
export JAVA_VENDOR



9. Start Admin Server and confirm your changes by running following command

$  ps -ef | grep Admin

if you see something similar then your are good to start other managed servers
oracle   13927 13771  5 15:30 ?        00:03:58 /u01/Oracle/jrockit-r282.2/bin/java -jrockit -Xms2048m -Xmx2048m -Dweblogic.Name=AdminServer

Hope it help,
Zeeshan Baig

11 comments:

  1. What I usually do is change the JAVA_HOME parameter .product_properties file located at $MW_HOME/wlserver_10.3 and $MW_HOME/coherence_10.3 into a location that I link to the JVM.

    So in your example my JAVA_HOME would be /u01/Oracle/java. That would be a symbolic link to /u01/Oracle/jrockit-r28.2.2 . So if you then upgrade java to a new version, you only have to change the symbolic link instead of having to fix all the files you mentioned.

    ReplyDelete
  2. Hi oraclemva,

    Thanks for nice tip.

    ZB

    ReplyDelete
  3. Option "-Djrockit.optfile" was replaced with another option, allowing more control over optimization process, see
    http://docs.oracle.com/cd/E15289_01/doc.40/e15066/newchanged.htm#CHDGIDAF
    and
    http://docs.oracle.com/cd/E15289_01/doc.40/e15059/crash.htm#BABJGICB

    ReplyDelete
  4. Hi Zeeshan,

    Could you please help me as I am stuck in mid after upgrading java32 bit to 64 bit and managed server is not coming up.

    Thank you
    J P Saha

    ReplyDelete
    Replies
    1. Hi,

      What exception is coming in the logs ?

      Zeeshan

      Delete
  5. in this setDomainEnv.sh having Sun_java_home and Bea_java_home , which one have to add, please let me know

    ReplyDelete
    Replies
    1. SUN_JAVA_HOME is Oracle Java JDK and BEA_JAVA_HOME is JROCKIT JDK you can set any one of it.

      Delete
  6. Any difference on installation of weblogic 9 and 10

    ReplyDelete
    Replies
    1. Not much but version 10 has been here for a while I believe over 6 years now. It is always good to follow Installation documentation.

      Delete
  7. how to define in unicast first two servers can act as agroup leader

    ReplyDelete
    Replies
    1. Hi,

      I have not done it before but you can find some detail here https://docs.oracle.com/middleware/1212/wls/CLUST/features.htm#CLUST127

      Zeeshan

      Delete