How to Configure WebUtil in Oracle Forms 11g – A Step-by-Step Guide

 

Introduction

Oracle Forms 11g lacks native support for client-side operations, such as file selection dialogs, clipboard access, or interactions with Microsoft Office. WebUtil bridges this gap by enabling Oracle Forms applications to perform these client-side operations.

This guide provides a detailed step-by-step procedure to configure WebUtil in Oracle Forms 11g, complete with actual commands.

1.      Prepare the Database Schema for WebUtil

Before using WebUtil, you must create the necessary database objects by executing the create_webutil_db.sql script.

 

Connect to the database as SYSDBA:

$  sqlplus / as sysdba

 


Create a dedicated WebUtil user :

SQL>CREATE USER webutil IDENTIFIED BY webutil DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;

 

SQL> GRANT CONNECT, RESOURCE, CREATE SYNONYM, CREATE PUBLIC SYNONYM TO webutil;


Run the WebUtil database script from application server:

$ sqlplus webutil/webutil@DB_SID $ORACLE_HOME/forms/create_webutil_db.sql


1.      Download and Place the JACOB Library Files

WebUtil depends on the JACOB library to interact with Windows-based applications.

Download the Required JACOB Version

·         For Forms 11g Release 1 (11.1.1.X) → JACOB 1.10.1

·         For Forms 11g Release 2 (11.1.2.X) → JACOB 1.14.3

 

The JACOB version can be downloaded from following github site

https://github.com/freemansoft/jacob-project/releases


1.      Copy JACOB Files to Oracle Forms

After downloading the JACOB files, extract to the  ZIP file:

Copy the files in following path of application server

copy jacob.jar $ORACLE_HOME/forms/java/

 

1.        Place the JACOB DLL Files

Place the JACOB DLL files in the correct directories:

For Forms 11g Release 1 (11.1.1.X):


copy jacob.dll $ORACLE_HOME/forms/webutil/



Forms 11g Release 2 (11.1.2.X):

cd jacob-1.14.3

cp jacob-1.14.3-x86.dll $ORACLE_HOME/forms/webutil/win32/

cp jacob-1.14.3-x64.dll $ORACLE_HOME/forms/webutil/win64/


1.      Sign the JACOB JAR File

To avoid security issues when running Forms, sign the jacob.jar file using Oracle's provided script.

Before sign, change the following in $ORACLE_INSTANCE/bin/sign_webutil.sh  file

SET JAR_KEY_PASSWORD=Password123#

SET KEYSTORE_PASSWORD=Password123#

SET VALIDDAYS=3600

 


cd $ORACLE_INSTANCE/bin

$ sh sign_webutil.sh $ORACLE_HOME/forms/java/jacob.jar


1.      Update CLASSPATH in default.env

Modify default.env to include the necessary JAR files.

cd $DOMAIN_HOME/config/fmwconfig/servers/WLS_FORMS/applications/formsapp_11.1.2/config

 

Add following parameter

 

CLASSPATH=$ORACLE_HOME/forms/java/frmall.jar

 



1.      Modify the formsweb.cfg Configuration File

cd $DOMAIN_HOME/config/fmwconfig/servers/WLS_FORMS/applications/formsapp_11.1.2/config

 

Add following [webutil] configuration

 

[webutil]

WebUtilArchive=frmwebutil.jar,jacob.jar

baseHTMLjinitiator=webutiljini.htm

baseHTMLjpi=webutiljpi.htm

archive_jini=frmall_jinit.jar archive=frmall.jar

Form=webutil_demo.fmx

Userid=username/password@DB_SID

##Provide db username and password and DBsid to connect the DB

 

Save and exit.


1.      Compile and Deploy webutil_demo.fmb

First download webutil_demo.fmb from following url and place it in application server

https://www.dropbox.com/s/mdkhjh7997r8arh/webutil_demo.fmb?dl=0

 

Open form builder and compile the form webutil_demo.fmb and place it under

$ORACLE_HOME/forms location. 

Or compile it using command

$ Cd $ORACLE_HOME/bin

$ frmcmp module=webutil_demo.fmb module_type=form userid=webutil/webutil_password@yourdb compile_all=yes

 

 


1.      Compile webutil.pll to create webutil.plx

$ cd $ORACLE_HOME/bin
$ frmcmp module=webutil.pll module_type=library userid=webutil/webutil_password@yourdb compile_all=yes

 


Restart Oracle Forms and weblogic services

$ cd $ORACLE_INSTANCE/bin

$ ./opmnctl stopall

 

 

#Stop reports services

cd $DOMAIN_HOME/bin

 

./stopManagedWebLogic.sh WLS_REPORTS

 

#stop forms services

 

./stopManagedWebLogic.sh WLS_FORMS

 

 

#stop weblogic admin server

 

./stopWebLogic.sh

 

#start weblogic admin server

 

cd $DOMAIN_HOME/bin

 

nohup ./startWebLogic.sh > /dev/null 2>&1 &

 

#Wait for sometime to start the admin server

 

#start forms services

 

nohup ./startManagedWebLogic.sh WLS_FORMS > /dev/null 2>&1 &

 

 

#Start reports services

 

nohup ./startManagedWebLogic.sh WLS_REPORTS > /dev/null 2>&1 &

 

#start opmn

 

$ cd $ORACLE_INSTANCE/bin

./opmnctl startall

./opmnctl status


1.      Test WebUtil Configuration

http://your_server_hostname:port/forms/frmservlet?config=webutil


This should open a window like below




Automating Oracle Forms 11g Compilation with a Shell Script

 

Automating Oracle Forms 11g Compilation with a Shell Script

In the world of Oracle applications, managing and compiling forms can be a time-consuming task, especially when dealing with a large number of forms. Fortunately, with the power of shell scripting in Linux, we can automate this process to save time and reduce errors. In this blog post, we will guide you through creating a shell script that compiles multiple Oracle Forms 11g or 12c in one go.

Why Automate Form Compilation?

Compiling Oracle Forms is essential for ensuring that your applications run smoothly. When changes are made to forms, they need to be recompiled to reflect those changes in the application. Manually compiling each form can be tedious and prone to human error, particularly when you have dozens or even hundreds of forms to process. By automating this task, you can:

  • Save Time: Compile multiple forms simultaneously without manual intervention.
  • Reduce Errors: Minimize the risk of missing a form or making mistakes during the compilation process.
  • Increase Efficiency: Focus on more critical tasks while the script handles the repetitive work.


Below is a shell script designed to compile all .fmb files in a specified directory for Oracle Forms 11g.


#!/bin/bash

. .bash_profile

 export FR_INST=/u01/app/oracle/product/fmw11g/asinst_1

 # Database credentials

USERNAME="scott"

PASSWORD="tiger"

DATABASE="prod"

 # Directory containing the forms

FORMS_DIR="/home/oracle/forms"

 

# Change to the forms directory

cd $FORMS_DIR || { echo "Directory not found: $FORMS_DIR"; exit 1; }

 

# Compile all forms

echo "Starting compilation of Oracle Forms..."

 

for form in *.fmb; do

    if [ -f "$form" ]; then

        echo "Compiling $form..."

        $FR_INST/bin/frmcmp_batch.sh Module_type=form Module="$form" userid="$USERNAME/$PASSWORD@$DATABASE"  batch=yes  compile_all=yes

       

        if [ $? -ne 0 ]; then

            echo "Error compiling $form"

        else

            echo "$form compiled successfully."

        fi

    fi

done

 

echo "Compilation process completed."

 

 

Instructions for Using the Script

  1. Modify Variables:
    • Update ORACLE_HOME, USERNAME, PASSWORD, DATABASE, and FORMS_DIR with your actual Oracle installation path and database credentials.
  2. Save the Script:
    • Save this script to a file, for example, compile_forms.sh.
  3. Make it Executable:

              chmod 777 compile_forms.sh

  1. Run the Script:
    • Execute the script in your terminal:

./compile_forms.sh

Key Components of the Script

  • Environment Variables: The script sets up necessary environment variables such as ORACLE_HOME and updates the PATH to include Oracle binaries.
  • Looping Through Forms: It uses a for loop to iterate through all .fmb files in the specified directory.
  • Error Handling: After each compilation attempt, it checks for errors and provides feedback on whether each form was compiled successfully or if there was an error.


Automating Deadlock Resolution with DBMS_SCHEDULER

 

We often encounter customers reporting application is hung/ not responding. Upon checking most of the time we observe blocking sessions. Deadlocks occur when two or more sessions block each other while waiting for resources, causing a standstill in database operations. This solution automates the detection and resolution of such conflicts, significantly reducing downtime and ensuring seamless database performance.


Database deadlocks and prolonged locks can cause performance degradation, especially when critical tables are involved. To address this, I’ve implemented a DBMS_SCHEDULER job that automatically identifies and terminates sessions causing contention on specific tables. Here's how I achieved this:

 

1. Creating the Procedure

The first step is to define a PL/SQL procedure that identifies and kills sessions based on specific criteria, such as duration of the lock, session status, and the affected tables. This procedure will check for locked session for more than 2 mins.

CREATE OR REPLACE PROCEDURE kill_blocked_sessions AS

BEGIN

    FOR rec IN (

        SELECT s.sid,

               s.serial#,

               ROUND((SYSDATE - s.logon_time) * 24 * 60) AS logon_time_minutes,

               o.object_name

        FROM   v$session s

        JOIN   v$session_wait w

               ON s.sid = w.sid

        JOIN   v$locked_object l

               ON s.sid = l.session_id

        JOIN   dba_objects o

               ON l.object_id = o.object_id

        WHERE  w.event IN ('enq: TX - row lock contention', 'enq: TM - contention')

        AND    s.status = 'ACTIVE'

        AND    (SYSDATE - s.logon_time) * 24 * 60 >= 2 -- Lock duration exceeds 2 minutes

      --  AND    o.object_name IN ('SESSION_LOG_INFO', 'USER_LOG_INFO')

       -- AND    o.owner = 'TESTUSER'

    ) LOOP

        -- Kill the session

        EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION ''' || rec.sid || ',' || rec.serial# || ''' IMMEDIATE';

        DBMS_OUTPUT.PUT_LINE('Killed session: SID=' || rec.sid || ', Serial#=' || rec.serial# || ', Table=' || rec.object_name);

    END LOOP;

END;

/

 

 

This procedure:

  • Targets sessions holding locks on specific tables (SESSION_LOG_INFO, USER_LOG_INFO etc.).
  • Filters for sessions with a lock duration exceeding 2 minutes and an active status.
  • Terminates these sessions using the ALTER SYSTEM KILL SESSION command.

2. Scheduling the Job

To ensure this procedure runs periodically, I created a DBMS_SCHEDULER job that executes it every minute. The job definition is as follows:

BEGIN

    DBMS_SCHEDULER.CREATE_JOB(

        job_name        => 'AUTO_KILL_BLOCKED_SESSIONS',

        job_type        => 'PLSQL_BLOCK',

        job_action      => 'BEGIN kill_blocked_sessions; END;',

        start_date      => SYSTIMESTAMP,

        repeat_interval => 'FREQ=MINUTELY; INTERVAL=1', -- Runs every 1 minute

        enabled         => TRUE,

        comments        => 'Automatically kills blocked sessions on specific tables.'

    );

END;

/

 

This setup ensures that deadlocks or blocked sessions are identified and resolved promptly, maintaining smooth database operations.

 

3. Verifying the Job

Once the job is created, it’s crucial to monitor its status and execution details to ensure it’s running as expected. The following queries can help:

Check Job Status:

SELECT job_name, state, last_start_date, last_run_duration

FROM   dba_scheduler_jobs

WHERE  job_name = 'AUTO_KILL_BLOCKED_SESSIONS';

 

Check Job Logs:

SELECT LOG_ID, LOG_DATE, OWNER, JOB_NAME, STATUS, REQ_START_DATE, ACTUAL_START_DATE, OUTPUT

FROM   dba_scheduler_job_run_details

WHERE  job_name = 'AUTO_KILL_BLOCKED_SESSIONS';

These queries provide insights into the job's execution history and whether it successfully resolves blocked sessions.

 

Conclusion

By leveraging the power of Oracle's DBMS_SCHEDULER, I automated the resolution of deadlocks and blocked sessions on critical tables. This approach not only reduces manual intervention but also ensures high availability and responsiveness of the database. If you're facing similar challenges, this solution can be adapted to your environment with minimal changes.

Let me know your thoughts or share your experiences with handling deadlocks in Oracle databases!