Tuesday 30 January 2018

Weblogic forced Garbage collection for servers

========================================================================
Applies to:
Weblogic: 10.3.6 and later
OS: CentOS7
========================================================================
Procedure:
There are two ways to perform garbage collection.

Weblogic admin console:
1. Login to weblogic admin console using admin(usually weblogic) user.
2. From left pane of the Console, go to Environment => Servers.
3. On summary of servers page, select server for which you would like to perform Garbage collection.
4. Go to Monitoring => Performance
5. Click on Garbage Collect button.

Using WLST:
1. Invoke wlst.sh from $oracle_home/oracle_common/common/bin
e.g. /u02/oracle12213/middleware/oracle_home/oracle_common/common/bin
[oracle@purupoc bin]$ ./wlst.sh

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline>
2. Connect to admin server using below command,
connect('<<weblogic-username>>','<<weblogic-password>>','t3://<<adminserver-host>>:<<adminserver-port>>')

e.g. connect('weblogic','weblogic123','t3://localhost:7001')
wls:/offline> connect('weblogic','weblogic123','t3://localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server "AdminServer" that belongs to domain "wl_server".

Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

wls:/wl_server/serverConfig/>

3. Enter into domainRuntime mode using domainRuntime()
wls:/wl_server/serverConfig/> domainRuntime()
Location changed to domainRuntime tree. This is a read-only tree
with DomainMBean as the root MBean.
For more help, use help('domainRuntime')

wls:/wl_server/domainRuntime/>

4. Go to server directory.
cd('/ServerRuntimes/<<Servername>>/JVMRuntime/<<Servername>>')
Use ls() command to check existing stats.

wls:/wl_server/domainRuntime/> cd('/ServerRuntimes/AdminServer/JVMRuntime/AdminServer')
wls:/wl_server/domainRuntime/ServerRuntimes/AdminServer/JVMRuntime/AdminServer> ls()

-r--   HeapFreeCurrent                              273970360
-r--   HeapFreePercent                              61
-r--   HeapSizeCurrent                              471633920
-r--   HeapSizeMax                                  518979584
-r--   JavaVMVendor                                 Oracle Corporation
-r--   JavaVendor                                   Oracle Corporation
-r--   JavaVersion                                  1.8.0_161
-r--   Name                                         AdminServer
-r--   OSName                                       Linux
-r--   OSVersion                                    3.10.0-693.el7.x86_64
-r--   Type                                         JVMRuntime
-r--   Uptime                                       1480421


wls:/wl_server/domainRuntime/ServerRuntimes/AdminServer/JVMRuntime/AdminServer>

5. Use cmo.runGC() to force garbage collection.
wls:/wl_server/domainRuntime/ServerRuntimes/AdminServer/JVMRuntime/AdminServer> cmo.runGC()
wls:/wl_server/domainRuntime/ServerRuntimes/AdminServer/JVMRuntime/AdminServer> ls()

-r--   HeapFreeCurrent                              311455952
-r--   HeapFreePercent                              69
-r--   HeapSizeCurrent                              471633920
-r--   HeapSizeMax                                  518979584
-r--   JavaVMVendor                                 Oracle Corporation
-r--   JavaVendor                                   Oracle Corporation
-r--   JavaVersion                                  1.8.0_161
-r--   Name                                         AdminServer
-r--   OSName                                       Linux
-r--   OSVersion                                    3.10.0-693.el7.x86_64
-r--   Type                                         JVMRuntime
-r--   Uptime                                       1691110


wls:/wl_server/domainRuntime/ServerRuntimes/AdminServer/JVMRuntime/AdminServer>

6. Disconnect from AdminServer using disconnect() command
wls:/wl_server/domainRuntime/ServerRuntimes/AdminServer/JVMRuntime/AdminServer> disconnect()
Disconnected from weblogic server: AdminServer
wls:/offline> 

Friday 5 January 2018

java.lang.OutOfMemoryError: Java heap space error while Applying Oracle Weblogic Server Patch using BSU

========================================================================
Environment Details:
Weblogic Server : 10.3.6
Linux Version: CentOS7

========================================================================
Problem Summary:
We are unable to apply oracle wblogic 10.3.6 patch becuase of java.lang.OutOfMemoryError: Java heap space

Error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.AbstractCollection.toArray(AbstractCollection.java:136)
at java.util.ArrayList.addAll(ArrayList.java:559)
at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getProperties(SchemaTypeImpl.java:705)
at com.bea.cie.common.dao.xbean.XBeanDataHandler.loadPropertyMap(XBeanDataHandler.java:775)
at com.bea.cie.common.dao.xbean.XBeanDataHandler.<init>(XBeanDataHandler.java:99)
at com.bea.cie.common.dao.xbean.XBeanDataHandler.createDataHandler(XBeanDataHandler.java:559)
at com.bea.cie.common.dao.xbean.XBeanDataHandler.getComplexValue(XBeanDataHandler.java:455)
at com.bea.plateng.patch.dao.cat.PatchCatalogHelper.getPatchDependencies(PatchCatalogHelper.java:442)
at com.bea.plateng.patch.dao.cat.PatchCatalogHelper.getPatchDependencies(PatchCatalogHelper.java:464)
at com.bea.plateng.patch.dao.cat.PatchCatalog.getPatchDependencies(PatchCatalog.java:56)
at com.bea.plateng.patch.dao.cat.PatchCatalogHelper.getInvalidatedPatchMap(PatchCatalogHelper.java:1621)
at com.bea.plateng.patch.PatchSystem.updatePatchCatalog(PatchSystem.java:436)
at com.bea.plateng.patch.PatchSystem.refresh(PatchSystem.java:130)
at com.bea.plateng.patch.PatchSystem.<init>(PatchSystem.java:114)
at com.bea.plateng.patch.PatchSystem.<clinit>(PatchSystem.java:41)
at com.bea.plateng.patch.Patch.main(Patch.java:279)
Exception in thread "Thread-0" java.lang.NoClassDefFoundError: Could not initialize class com.bea.plateng.patch.PatchSystem
at com.bea.plateng.patch.PatchClientHelper.getAllPatchDetails(PatchClientHelper.java:74)
at com.bea.plateng.patch.PatchInstallationHelper.cleanupPatchSets(PatchInstallationHelper.java:130)
at com.bea.plateng.patch.PatchTarget.<init>(PatchTarget.java:272)
at com.bea.plateng.patch.PatchTargetFactory.create(PatchTargetFactory.java:30)
at com.bea.plateng.patch.ProductAliasTarget.constructPatchTargetList(ProductAliasTarget.java:88)
at com.bea.plateng.patch.ProductAliasTarget.<init>(ProductAliasTarget.java:46)
at com.bea.plateng.patch.ProductAliasTargetHelper.getProdAliasTargetList(ProductAliasTargetHelper.java:55)
at com.bea.plateng.patch.ProductAliasTargetHelper.getAllHomeToProdAliasesTargetMap(ProductAliasTargetHelper.java:32)
at com.bea.plateng.patch.ProductAliasTargetHelper.checkProfilesInProductAliases(ProductAliasTargetHelper.java:133)
at com.bea.plateng.patch.Patch$1.run(Patch.java:376)
at java.lang.Thread.run(Thread.java:745)


========================================================================
Root Cause:
Heap size configured for BSU is not sufficient

========================================================================
Resolution:
1. Go to $MIDDLEWARE_HOME/utils/bsu
2. Edit bsu.sh
3. Change the memory arguments from
MEM_ARGS="-Xms256m -Xmx512m"
To
MEM_ARGS="-Xms2048m -Xmx2048m"
4. Save the changes.
5. Try to apply patch again.