Running Oracle ADF application on High availability (HA) architecture

Oracle ADF is used to build large enterprise application. And if you want to have your application to run on high availabilty then you should understand what is High Availability (HA) .

What is High Availability –
High availability refers to the ability of users to access a system without loss of service. Deploying a high availability system minimizes the time when the system is down, or unavailable and maximizes the time when it is running, or available. This section provides an overview of high availability from a problem-solution perspective. With HA , even for new deployment you will never have down time.

Normally in large enterprise application , you don’t want your system to be down..Application deployed in cluster environment. If one of the server down then the user session should replicate to another cluster . Now , we have Oracle HTTP Server (OHS) or Apache plugin is to used to get single URL and manage internally to replicate the session and send request if one of cluster is fail.

How a web server handle request

webserver

Cluster- Group of managed server running to provide scalability and reliability. In this multiple wls instance simultaneously and working together.Cluster is part of WLS domain . A domain can have multiple cluster

Cluster


Architecture of Weblogic HA

apache web server

Now the important point for developer – Few points designing and developing Oracle ADF application for HA.
There are 6 types of memory scopes. Read more on ADF memory scopes

When the Fusion web application runs in a clustered environment, a portion of the application’s state is serialized and copied to another server or a data store at the end of each request so that the state is available to other servers in the cluster.If it not serialized then user will lose data upon fail-over.

WebLogic duplicates those sessions by serializing the objects in the session and than transfers it to the secondary machine. Only the object that are stored in the session will be replicated. From an ADF perspective this means that managed bean with pageFlowScope and above will be replicated.It is very well defined in Oracle documentation and A-team article.

Configuring Oracle ADF development for High Availability

=> Changes in Application server-

While doing development Jdeveloper integrated server will not throw any errors by default. Add this parameter in server has to be run with the following JVM parameter:

-Dorg.apache.myfaces.trinidad.CHECK_STATE_SERIALIZATION=all
 

Note that this check is disabled by default to reduce runtime overhead. Do not use this after your testing is complete.

-> Changes in ADF code

-> Please make sure that managed beans used in ADF application with a scope greater than one request should be serializable ( implement the java.io.Serializable interface). Specifically, beans stored in session scope, page flow scope, and view scope need to be serializable.

– All pageflowscope and viewscope managed beans should not contain UI bindings. In essence, component bindings should live for a http request (request scope or backingBean scope). Any state or data you need for a longer duration can be saved in a pageflowscope bean separately.

– Make sure Oracle ADF is aware of changes to managed beans stored in ADF scopes (view scope and page flow scope) and enable the tracking of changes to ADF memory scopes.

use below code to notify ADF

controllerContext ctx = ControllerContext.getInstance();
ctx.markScopeDirty(viewScope);

 


-> Configuring Application Modules

– Right-click the application module and select Configurations.Click Edit.Click the Pooling and Scalability tab.
Select the Failover Transaction State Upon Managed Release checkbox.

<AppModuleConfig ...
 <AM-Pooling jbo.dofailover="true"/>
</AppModuleConfig>
 

-> Configuring weblogic.xml

In weblogic.xml file, add entry as below persistent-store-type definition to the session-descriptor element like below

<weblogic-web-app>
    <session-descriptor>
    <persistent-store-type>
    replicated_if_clustered
    </persistent-store-type>
    </session-descriptor>
</weblogic-web-app>

 

-> Configuring adf-config.xml

In adf-config.xml file, add entry as like below

<adf-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">
 <adf-scope-ha-support>true</adf-scope-ha-support>
</adf-controller-config>

 

Happy Learning with Vinay In techartifact.

Ref- http://docs.oracle.com/cd/E12839_01/core.1111/e10106/adf.htm

Configure Node Manager in Weblogic and administer Managed server

Requirement – How to configure node manager with weblogic and administer Managed server

Solutions- I have provided below steps to accomplish this task.

-> Should have an machine accroding to Os. Either unix machine or machine
-> Start startNodeManager.sh in $MW_HOME/server/bin
-> Check if nodeManager.properties files is there
-> If file is there then make StartScriptEnabled=true
-> Then go to $MW_HOME/wlserver_10.3/common/bin
-> then go with command – ./wlst.sh
-> then go with command – connect(‘weblogic’,’welcome1′,’t3://192.168.228.134:7001′)
-> then type command – nmEnroll(‘/u01/app/oracle/Oracle/middleware/user_projects/domains/ucm_domain’,’/u01/app/oracle/Oracle/middleware/wlserver_10.3/common/nodemanager’)
-> If you successfuly enrolled then go to admin console and start managed server.
-> Then be happy and smile…..

Now you can see this video as well.

Happy Learning Weblogic with Vinay Kumar in techartifact……

Managed Beans configuration In JSF 2.0 | Techartifact

In JSF 2.0, Java bean that is accessed from JSF page is called a Managed Bean. The managed bean can be a normal Java bean, which contains the getter and setter methods, business logic or even a backing bean (a bean contains all the HTML form value).

There are two ways to configure the managed bean :

-> Configure Managed Bean with faces-config.xml

It is same as we used to do JSF 1.1 .We can defined managed bean in faces-config.xml .

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
    <managed-bean>
	  <managed-bean-name>helloBean</managed-bean-name>
	  <managed-bean-class>com.vinay.common.HelloBean</managed-bean-class>
	  <managed-bean-scope>session</managed-bean-scope>
     </managed-bean>
</faces-config>

Using Dependency Injection

-> Configure Managed Bean with Annotation

You can annotated a Managed Bean with new @ManagedBean annotation in JSF 2.0 .JSF is a basic Dependency Injection (DI) container and we can use annotations to inject objects. JSF offers setter method injection – this means the object will be passed into the setter. It is also static injection – meaning, the injection will happen only during bean creation (as opposed to Seam, where static and dynamic injection is possible).

package com.vinay.common;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import java.io.Serializable;
 
@ManagedBean
@SessionScoped

public class HelloBean implements Serializable {
 
	private static final long serialVersionUID = 1L;
 
	private String name;
 
	public String getName() {
		return name;
	}
 
	public void setName(String name) {
		this.name = name;
	}
}


@ManagedBean – marks this bean to be a managed bean with the name specified in name attribute. If the name attribute in @ManagedBean is not specified, then the managed bean name will default to class name portion of the fully qualified class name.Try to set the scope (request) into which this bean will be placed. If scope is not specified then bean will default to request scope.

@ManagedBean also has eager attribute (new in JSF 2). If eager=”true” and scope is application, then this bean must be created when the application starts and not during the first reference to the bean. In other words, the creation and storing of the bean instance must happen before any requests are serviced.

@ManagedBean(name="vinayBean", eager=true)
@ApplicationScoped
public class Vinay{
 ...
}

If eager is true but scope is not application, then regular “lazy” initialization used. If eager is not defined or missing, then “lazy” initialization is used as well.

You can also pass the value of variable using annotation.

@ManagedProperty(value="vinay")
private String name;

When the bean is created, ‘vinay’ will be passed to setName(..) method.

Happy New year guys.This is first post of this year.
Happy coding with Techartifact.