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

Monday, April 30, 2012

Download Working with Portlets in ADF and Webcenter Presentation

Hello all,

I am back to home after a great trip to Collaborate 2012 in Las vegas. I am thankful to all people who attended my session. You can now download my presentation and paper from collaborate site as well here.


Download White paper

I will put the demo videos on my YouTube channel soon and i am hopeful to see you again soon at Kscope 2012 in San Antonio, TX.

Best Regards,
Zeeshan Baig
LinkedIn: http://www.linkedin.com/in/baigzeeshan
Twitterhttp://twitter.com/baigsorcl
YouTubehttp://www.youtube.com/user/baigsorcl

Thursday, April 5, 2012

Join my Session at Collaborate 2012 in Las Vegas

Greetings,

If you are not aware by chance that i will presenting 1 session at Collaborate 2012 this year in Las Vegas.

Following are the details of the session


#288 - Working with Portlets in ADF and Webcenter

Date:
Monday, April 23
2:30 pm - 3:30 pm
Location:
Surf E
Product Line:
Oracle WebCenter, Framework (ADF)
Track:
Development
Description:
A portlet is a reusable Web component that can draw content from many different sources. Oracle ADF and Webcenter provides a powerful framework to build and integrate portlets into your enterprise portal.

In this session we will demonstrate how to build and deploy portlets using ADF and later integrate into Oracle Webcenter portal. The session will also discuss the general best practices and standards.

So come to say hello to me.
See you soon,
Zeeshan Baig

Friday, March 9, 2012

Defining Unique Key Constraints for Non-Primary Key Attributes in ADF-BC

Greetings,

ADF BC (Business Components) allows you to write code declaratively instead of writing spaghetti code in Java.

One of the feature is Alternate key constraint which is different from Primary and Unique key constraints available in database. Usually Primary key values are coming from database sequence so you don't have to worry about their uniqueness but if you like to validate uniqueness on other columns e.g. email address,Region or Country Name that's where Alternate key comes into action.

Following are some properties of alternate keys:

  • You can check Uniqueness at record level e.g. Department Name must be unique 
  • You can have many alternate keys as compare to Primary keys
  • You can look for a row in entity object using findByKey() method
  • If the key is found in entity objects ADF will throw TooManyObjectsException


Lets look into example (Download the complete example)

Use case:
Database schema: HR @ Oracle XE

Column Country name must be unique in Countries table. We have primary key CountryId in the table as shown in the slide




Solution:

  1. Create an Alternate key constraint on Entity object.
  2. Add Unique Key validation on Entity Object using alternate Key

Creating Alternate Key:

Right click the Entity Object and Choose "New Entity Constraint"



Enter the name of the constraint, Enter the Attribute where you want to add constraint in our case select Country Name





You can verify the Alternate key constraint Under general tab of entity object properties




Creating Unique Validation:

Go to Business Rules tab in Entity Object properties and Click Create New Validation by selecting "Entity Validators" as shown in the slide



Select "Unique Key" from Rule Type list. Select the Alternate key constraint from Keys


Go to Failure tab and Enter custom error message



Run the Application Module, Create new Record and Enter Unique country name like Brazil, You would see the similar error message.


Also on JSF page you would see error message on Commit



Happy JDeveloping,
Zeeshan Baig







Friday, March 2, 2012

Using Programmatic Validation in ADFBC

Greetings,

This month of March i will be focusing on ADF business components. So first entry in this series is how to write programmatic validations for entities in ADF business components.

I have covered a similar concept using ADF Domain types  which gives us global validation control instead of writing code for specific entities.

As you might be familiar that ADF BC provides facility to write validations in declarative manner but sometimes  the use case is complex for that you can write programmatic validations as follows

1. Add a method that will do validation in EntityImpl.java class
2. Call that method as part of validation cycle in validateEntity() method which is called at commit time when any attribute has been updated.

Let's get into detail

In this example use case (Download the example)

Our business rule says that all email address should be first letter of First name and full Last name of the employee

e.g. If the name is Zeeshan Baig then email address should be ZBAIG

1. Generate EntityImpl java class by double clicking on entity, go to Java tab and click on the pencil button choose generate employeeImpl class and click OK as shown in the slide



2. Write your custom method that will perform validation. In our use case is as follows

    public boolean checkValidEmail() {
        //Email must be first letter of First name and Full last name of employee
        //e.g Zeeshan Baig should be entered as zbaig
        String validEmailRule = this.getFirstName().substring(0,1) + this.getLastName();      

        if (getEmail().compareToIgnoreCase(validEmailRule) == 0 && getEmail() != null) {
            return true;
        } else {
            return false;
        }
    }

3. Override validateEntity() method but clicking override button enter text validate, select method and click OK



4. Override the code of validateEntity() method as follows

    protected void validateEntity() {
        if (!checkValidEmail()) {
            throw new JboException("Email Address should start with First letter of First Name and Complete Last Name.");
        }
        super.validateEntity();
    }

5. Compile the class and Run Application module to test in ADF business component browser




6. Enter wrong email address and click Validate Button to test you should receive Error alert



7. Enter valid email as per the rule and click Validate No alerts should come click Commit you should be able to see the successful commit message in the log




Happy JDeveloping,
Zeeshan Baig

Wednesday, February 22, 2012

How to Change Database Schema Password For Oracle Content Server

Hi,

Sometimes it is required to recover forgotten password of Oracle Content Server repository.

The purpose of this post is to identify where you are required to do changes if you are going to reset content repository database account password.

Usually the database schema owner of Oracle content server is <Your-Prefix>_OCS if your prefix during installation was DEV then username in database will be DEV_OCS.

Your DBA changed the password using following command

alter user DEV_OCS identified by newPassword;

Change In Weblogic Console:

1. Open Weblogic Admin console by following URL

http://mysername:myport/console
e.g http://myserver:7001/console

2. Go to Services > JDBC > Data Sources > CSDS > Configuration > Connection Pool




3. Enter new password and Press Save as shown




4. Weblogic will ask you to restart the data source, follow as shown in the slide






Change Password in Content Server Configuration:

To change password in Linux environment you need X-Windows / VNC or Login to Box using Tools like Reflections

1. Go to your content-server domain directory as follows


/u01/Oracle/Middleware/user_projects/domains/myDomain/ucm/cs/bin/


2. Run SystemProperties file

$ ./SystemProperties

3. A properties window will appear. Go to Database tab and change the password and hit OK



The changes will propogate out to the config.cfg file restart content server if required.

Hope this will help,
Zeeshan Baig