Thursday, December 5, 2013

JRockit R28 StartUp Issues - WLS 10.3.6

Recently, I configured a WebCenter Portal PS5 Environment having following configuration:

Linux 2.6.32-300.41.1.el5uek x86_64
Weblogic 10.3.6
WebCenter Portal 11.1.1.6.0 BP5
Oracle JRockit(R) (build R28.2.7-7-155314-1.6.0_45-20130329-0641-linux-x86_64)

And when I tried to start Weblogic Server, I found following error/warning messages in the Server log.

[WARN ] Use of -Djrockit.optfile is deprecated and discouraged.
[ERROR][osal   ] Unable to discover information about /mnt/hugepages
[WARN ][memory ] Could not acquire large pages for Java heap.
[WARN ][memory ] Falling back to normal page size.

First, I tried to resolve -Djrockit.optfile warning. To resolve this, I followed below steps.

[WARN ] Use of -Djrockit.optfile is deprecated and discouraged.

1. Open <DOMAIN_HOME>/bin/setDomainEnv.sh
2. Search for property -Djrockit.optfile. You will find it in EXTRA_JAVA_PROPERTIES
3. Replace  existing
-Djrockit.optfile=${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt
with
-XX:+UnlockDiagnosticVMOptions -XX:OptFile=${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt and Save the file.
4. Open ${COMMON_COMPONENTS_HOME}/modules/oracle.jrf_11.1.1/jrocket_optfile.txt file and change the content as follows and save the file.

Exisitng:
- oracle/xquery/parser/XPathTokenManager.*
- oracle/adf/view/rich/render/RichRenderer.createSubId*
- oracle/adf/view/rich/render/RichRenderer.createClientSubId*

Convert to:
{
match: ["oracle.xquery.parser.XPathTokenManager.*",
"oracle.adf.view.rich.render.RichRenderer.createSubId*",
"oracle.adf.view.rich.render.RichRenderer.createClientSubId*"],
enable: jit
}

Note: content of jrocket_optfile.txt varies depends on environment.

Now let us take a look into error/warning about hugepages.

[ERROR][osal   ] Unable to discover information about /mnt/hugepages
[WARN ][memory ] Could not acquire large pages for Java heap.
[WARN ][memory ] Falling back to normal page size.

This error will occur due to -XX:+UseLargePagesForHeap added to Weblogic Startup command. We can handle this error in two ways.

Approach 1: Comment/remove -XX:+UseLargePagesForHeap from setDomainEnv.sh script.
if [ "${JAVA_VENDOR}" = "Oracle" ] ; then
        EXTRA_JAVA_PROPERTIES="-XX:+UseLargePagesForHeap ${EXTRA_JAVA_PROPERTIES}"
        export EXTRA_JAVA_PROPERTIES
fi

Approach 2: Configure HugePages on Linux  and increase the number of HugePages on the OS using "sysctl -w vm.nr_hugepages" command

Refer following documentation to configure HugePages on Linux.

Kernel Documentation
Note 361468.1: HugePages on Oracle Linux 64-bit
Note 361323.1: HugePages on Linux: What It Is... and What It Is Not...

Wednesday, December 4, 2013

Refresh af:OutputText value using JavaScript

Applicable to FMW 11.1.1.6.0

Y'day, I was trying to write a Java Script to change the Page header(af:outputText) based on link(af:goLink) clicked by user. I tried following approaches to achieve it.

Approach 1:
JSPX page source: 
<af:iterator>
  ...........................
   <af:goLink text="#{side_menu_item.title}" id="gk1"
              destination="#{side_menu_item.goLinkPrettyUrl}"
              targetFrame="#{side_menu_item.attributes['Target']}">
         <af:clientListener type="click" method="changeHeader"/>
         <af:clientAttribute name="Title" value="#{side_menu_item.title}"/>
         <af:serverListener type="setHeader" method="#{pageFlowScope.PortalBean.setNavHeader}"/>
   </af:goLink>
   ...........................
</af:iterator>

Note: No need to set clientComponent=true , if you are adding af:clientListener

   <af:outputText value="#{pageFlowScope.PortalBean.navHeader}" id="pt_ot2"
                  clientComponent="true"
                  binding="#{pageFlowScope.PortalBean.navHeaderText}"
                  noWrap="true">
   </af:outputText>

Java Script:
    function changeHeader(evt) {
       var goLink = evt.getSource();
       var title = goLink.getProperty("Title");
       AdfCustomEvent.queue(goLink,"setHeader",{param1:title},true);
    }

Managed Bean Method: (This server side method will be called using af:serverListener)
public void setNavHeader(ClientEvent ce) {
        String param = (String)ce.getParameters().get("param1");
        setNavHeader(param);
        AdfFacesContext.getCurrentInstance().addPartialTarget(getNavHeaderText());      
    }

    public void setNavHeader(String navHeader) {
        this.navHeader = navHeader;
    }

    public String getNavHeader() {
        return navHeader;
    }

Approach 2:
Later, I thought to set the <af:outputText> using only JavaScript instead of calling Server side bean.
function changeHeader(evt) {
       var goLink = evt.getSource();
       var title = goLink.getProperty("Title");
       var headerText = goLink.findComponent("pt_ot2");
       headerText.setValue(title);
    }

Note: In this case, the component can be find using its id.

Approach 3:
Again, I tried another approach to set the <af:outputText>.
function changeHeader(evt) {
       var goLink = evt.getSource();
       var title = goLink.getProperty("Title");
       document.getElementById('pt1:pt_ot2').value=title;
    }

Note: In this case, the component can be find using id generated on client side(browser). You can get the client side id by accessing page source.

When I run the page, it worked fine in IE 9, but not in Mozilla(17.0.11) & Chrome(31.0.1650.57 m) browsers. Then I made small change to javascript, which worked across all browsers.

function changeHeader(evt) {
       var goLink = evt.getSource();
       var title = goLink.getProperty("Title");
       document.getElementById('pt1:pt_ot2').innerHTML=title;
    }

Note: If you are using af:GoLink, it will refresh the complete global container. Hence the <af:outputText> value will be set to NULL. In this case, you can try to use browser sessionStorage to store values even after browser refresh.

    function storeValue(key, value) {
        if (window.sessionStorage) {
            sessionStorage.setItem(key, value);
        }
    }

    function getStoredValue(key) {
        if (window.sessionStorage) {
            return sessionStorage.getItem(key);
        }
    }

storeValue('header', title);
getStoredValue('header');

WebCenter: Issue with /tmp directory permission

Applicable to WebCenter 11.1.1.6.0

Recently, I was not able to access Weblogic server console and when I checked the Server logs, found  below mentioned error domain logs.

Error 1: found in WebCenter Collaboration Server log & WLS Domain log
<Dec 3, 2013 12:53:11 PM CST> <Error> <com.jivesoftware.Jive-ERR> <BEA-000000> <Permission denied java.io.IOException: Permission denied
        at java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:883)
        at org.apache.lucene.store.FSDirectory$1.obtain(FSDirectory.java:363)
        at org.apache.lucene.store.Lock.obtain(Lock.java:51)
        at org.apache.lucene.store.Lock$With.run(Lock.java:98)
        at org.apache.lucene.index.IndexReader.open(IndexReader.java:141)
        at org.apache.lucene.index.IndexReader.open(IndexReader.java:136)
        at com.jivesoftware.forum.database.DbSearchManager.getReader(DbSearchManager.java:1169)
        at com.jivesoftware.forum.database.DbSearchManager$UpdateTask.run(DbSearchManager.java:1662)

The error stack did not provide any details about folder/file path and was not able to identify the root cause for this error. When I executed grep command, all the Admin & Managed server processes are showing status as Running, but not responding.

And when I tried to shutdown the Managed/Admin servers using stopManagedWebLogic.sh/stopWebLogic.sh, I got following error in the CLI console.

Error 2:
Initializing WebLogic Scripting Tool (WLST) ...
Jython scans all the jar files it can find at first startup. Depending on the system, this process may take a few minutes to complete, and WLST may not return a prompt right away.
*sys-package-mgr*: can't create package cache dir, '/tmpWLSTTemp<user>/packages'

Cause: Some how the /tmp folder permissions changed to 755.

Fix: executed chmod 1777 /tmp to reset permissions. (1 refers to Sticky bit)

After changing /tmp folder permissions, both Error 1 & 2 resolved.

Monday, December 2, 2013

Enable APEX application to load in Frames

Applicable to APEX Version 4.2 and FMW 11.1.1.6.0

Recently, I tried to load APEX application in ADF/WebCenter application page region using ADF faces component af:InlineFrame. The result is empty page, the af:InlineFrame component was not able to render the APEX application page.

After lot of trails, Luckily I walk through APEX user guide and understood the security constraints on APEX page to avoid "ClickJacking" attacks.

After changing Browser Security settings to allow Embed In Frames(as mentioned in user guide), the af:InlineFrame component was able to render the APEX application page.

Steps to change Browser Security settings in APEX:
1. Login to APEX main page
2. Click on Application Builder --> Application

3. Go to Shared Components and Click on Security Attributes

4. In Security Attributes page, go to Browser Security section. Select Allow for Embed in Frames option.