Tuesday, November 20, 2012

How to Create Virtual Directory in Weblogic Server

Share this Post
Hi,

You can host your static files like images, javaScript, CSS content to Weblogic server as well. In ideal world these files usually are part of web server but in the absense of HTTP web server like Apache, IIS we can use Weblogic server to host these files.

The benefit of keeping file like that is that all your project's static files like logos, bullets etc etc will reside on OS and in case of any changes all you need to change at OS level instead of application server level.

In summary we will  create a simple app which will use the '/images' context of WLS and all we need to do in our apps to use /images context to retrieve the image.

1. Create a folder on your OS and put all your static images files there
e.g. c:\Jdeveloper\sharedLibs\images\





2. Create Application called 'VirtualDirectoryApp' using Fusion Template

3. Delete Model Project by right clicking it and Click New on ViewController Project and Create weblogic deployment description this will create weblogic.xml file





4. Set the properties of Directories weblogic.xml as shown in the slide



5. Set the context of the application to /virtual



6. Now deploy the WAR file by right clicking the ViewController Project and call the content of directory via following URL

http://myserver:myport/virtual/imagename.jpg





Happy Jdeveloping,
Zeeshan Baig
Follow me on Twitter @baigsorcl
 

Friday, October 5, 2012

Oracle ADF - Using Region Navigation Listener in af:region

Share this Post
Greetings,

Its been long that i have posted something related to ADF. Thanks to my visitors who ask questions to keep me alive.

One reader shared a use case with me as follows

"We have a requirement to collapse a panel in Panel splitter for specific activity in a region"

The answer for that is use Region Listener in af:region component.

The Region Listener have a RegionNavigationEvent argument which can provide the current view in a af:region based on that you can conditionally collapse or expand panel

Example: Download complete example

In my bounded task flow i got 3 views, view 1-3 respectively as shown in the slide.





I have home page with Panel splitter and af:region in facet 2



My use case is to collapse left panel when user navigates to view 2 in a region.





I have a Region Listener as follows



I have panel splitter binding in the bean 



The Region Navigation Listener code is as follows


public class RegionNavigationListener {
    private RichPanelSplitter myPanel;

    public RegionNavigationListener() {
    }

    public void onRegionNavigated(RegionNavigationEvent region) {
        String viewId = region.getNewViewId();        
        
        if (viewId.equalsIgnoreCase("/region-flow-definition/view2")) {
            doCollapsePanel(myPanel);
        }
        else {
            doExpandPanel(myPanel);
        }
    }
    
    private void doCollapsePanel(RichPanelSplitter panel){    
        panel.setCollapsed(true);
        AdfFacesContext.getCurrentInstance().addPartialTarget(panel);  
    }
    
    private void doExpandPanel(RichPanelSplitter panel){    
        panel.setCollapsed(false);
        AdfFacesContext.getCurrentInstance().addPartialTarget(panel);  
    }
    

    public void setMyPanel(RichPanelSplitter myPanel) {
        this.myPanel = myPanel;
    }

    public RichPanelSplitter getMyPanel() {
        return myPanel;
    }
}


Hope you like it 

Follow me on twitter and happy Jdeveloping,
Zeeshan Baig 








Tuesday, August 28, 2012

I am Featured in Oracle Magazine September 2012 issue

Share this Post
Hi,

Its a great honor for me that my profile featured in Peer to Peer section of Oracle Magazine in September 2012 issue. I believe that issue will be main issue for Oracle Open World 2012 as well.

Check the following link Oracle Magazine Peer to Peer September 2012



I am thankful to all who supported through out my career so i can dream of this day and also to people who visited this blog and found it helpful.

P.S. Lot of people asking about the photo...Its Grand canyon Arizona i visited there after collaborate 2012 conference in Las Vegas.

Cheers,
Zeeshan Baig
Follow me Twitter @baigsorcl

Wednesday, July 18, 2012

Sharing Common Connections Between JDeveloper Machines

Share this Post
Hi,

In order to work in a team environment JDeveloper offers many small nuggets that can make our life easier and implement development standards.

In this post we will take a look how to export and import application servers, database connections from one  Jdeveloper machine to another. You can even store these connections in your source control system to share.

Resource Palette:

You will find common place for all connections in JDeveloper under Resource Palette. Click View menu and select Resource Palette




Exporting Connection:

Right click on your desired connection and choose Export, select which connections you want to export and provide the destination, click OK the resulting window will give you the status






Save the destination file to source control or network drive (optional):


For better teamwork i would recommend to store these connections in source control system as shown in the slide i have a folder in Visual SVN repository called Connections and under that the exported file from JDeveloper.






Importing a Connection into JDeveloper


Now developers can export the connections from source control system to their file system and import connections into JDeveloper.






There you go hope you find the post useful feel free to comment. More gold nuggets to follow.

Happy JDeveloping,
Zeeshan Baig






Friday, July 6, 2012

Solution to fix Exception java.lang.NoClassDefFoundError While running weblogic commands from console

Share this Post
Hi,

A quick one here. Most of us might experienced this when try to run weblogic.Deployer or any weblogic related command from console or shell prompt you see something like this

C:\>java weblogic.Deployer
Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/Deployer
Caused by: java.lang.ClassNotFoundException: weblogic.Deployer
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: weblogic.Deployer.  Program will exit.

The problem is NOT with your installation or configuration but actually java is not able to find classes related to weblogic

Solution:

The solution is to add the JAR file into the CLASSPATH variable.

C:\> set CLASSPATH=%CLASSPATH%;D:\Oracle\Middleware1035\wlserver_10.3\server\lib\weblogic.jar

Note:  Change above command as per your environment Linux or Windows also i saw some people add the location of the folder to Classpath which will not fix the issue you should provide the name of the JAR file as mentioned above.

You can see in the slide how the error gone by adding CLASSPATH to the environment.


Monday, July 2, 2012

My Presentation from Kscope 2012 Conference

Share this Post
Hi,

Kscope 2012 conference was a great event for me i am thankful to ODTUG management by providing me this opportunity also OTN who gave me opportunity to be on Fusion middleware panel during Lunch n Learn session.

You can view my presentation from Kscope from my slideshare account. I will post separate blog on the demo details.


Monday, June 4, 2012

My Interview featured in May 2012 OTN Harvest

Share this Post
Hi,

Its been a great honor for me to be featured in OTN Harvest Spotlight. I am thankful to Oracle to recognized my contribution and to all visitors of this blog by providing positive feedback which helps be keep going

You can find the digest online on Oracle’s website using following link http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#OtnHarvest


And download the issue http://www.oracle.com/technetwork/developer-tools/adf/learnmore/may2012-otn-harvest-1652358.pdf

Happy JDeveloping,
Zeeshan Baig

Wednesday, May 9, 2012

How to Change JDK used by Weblogic Server

Share this Post
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

Share this Post
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

Share this Post
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

Share this Post
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

Share this Post
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

Share this Post
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










Friday, January 6, 2012

How to set Different JVM Heap Sizes for Admin and Managed Servers in Weblogic

Share this Post
Hi,

As per performance tuning guidelines it is good practice to start your Admin server with lower JVM heap size than your other managed servers because the Admin server doesn't required much resources.
By doing this you can utilize the free memory with others where it is needed (This makes sense when you are running Admin and Managed servers on same host)

Problem:
As i mentioned above our requirement is to use different JVM heapsize for Adminserver and only specific webcenter WLS_Spaces servers of a cluster.

One way to change the heap size is to set in weblogic admin console click here

In the example i will set JVM heap size -Xms and -Xmx values to1MB for AdminServer and 2MB each for WLS_Spaces managed servers of a cluster.

Solution:

1. Shutdown Admin and Managed servers

2. Add the following line of code in setDomain.env file. you can find the file under bin directory of weblogic domain home

Make sure you add these lines at-least after "export XMX_JROCKIT_32BIT" so it will override any other default settings.

e.g. /u01/Oracle/Middleware/user_projects/domains/myDomain/bin

# Set 1024MB for AdminServer

if [ "${SERVER_NAME}" == "AdminServer" ] ; then
      USER_MEM_ARGS="-Xms1024m -Xmx1024m"
    export USER_MEM_ARGS
fi

#Set 2MB if server name contains WLS_Spaces ( it will cover WLS_Spaces1,2,3,4..)

if [[ "${SERVER_NAME}" == *WLS_Spaces* ]] ; then
    USER_MEM_ARGS="-Xms2048m -Xmx2048m"
    export USER_MEM_ARGS
fi

3. Start Adminserver to verify if your change is working (if ok then start all others)

4. Verify by check the JVM heapsize using Jrockit mission control or Linux process
e.g. $ ps -ef|grep AdminServer




Have a nice day,
Zeeshan Baig