Monday, 20 November 2017

Oracle Forms and Reports Services 12c Configuration Notes

This article is a collection of useful notes on a variety of topics related to configuration of Oracle Forms and Reports Services 12c.

◉ Installation


This site contains a number of articles describing the installation of WebLogic Server 11g and Oracle Forms and Reports Services 12c on Linux and Windows.

◉ Configuration Utility


If you choose a software-only installation, you can initiate the configuration steps using the following command.

$FR_HOME/oracle_common/common/bin/config.sh

This is also useful if your configuration phase fails and you want to rerun it after making the necessary changes to fix the issues.

◉ Environment Variable Settings


The basic WebLogic environment variable settings are described in the installation guides, but the following list accounts for most of the scenarios you are likely to come across on the server, including forms compilation from the command line. Remember to adjust the paths to suit your installation. The paths below assume you've installed using the same paths I used in my installation guides. Also, remember to adjust the FORMS_PATH and TWO_TASK variables as required.

# Middleware
export ORACLE_BASE=/u01/app/oracle
export MW_HOME=$ORACLE_BASE/product/12.2.1
export ORACLE_HOME=$MW_HOME
export WLS_HOME=$MW_HOME/wlserver
export WL_HOME=$WLS_HOME

export FR_HOME=$ORACLE_HOME
export ORACLE_INSTANCE=$DOMAIN_HOME/config/fmwconfig/components/FORMS/instances/forms1
export FR_INST=$ORACLE_INSTANCE

export DOMAIN_HOME=$ORACLE_BASE/config/domains/frsdomain
export JAVA_HOME=$ORACLE_BASE/jdk1.8.0_144

export OHS_INST=$DOMAIN_HOME/config/fmwconfig/components/OHS/instances/ohs1

# Forms compilation
export PATH=.:$FR_HOME/bin:$FR_HOME/forms/mesg:$PATH
export LD_LIBRARY_PATH=$FR_HOME/oracle_common/jdk/jre/lib/amd64:$FR_HOME/lib:$FR_HOME/oracle_common/lib:$FR_HOME/oracle_common/jdk/jre/lib/amd64/server
export FORMS_BUILDER_CLASSPATH=$FR_HOME/jlib/
export FORMS_PATH=[*** add the path to your forms ***]
export REPORTS_PATH=[*** add the path to your reports here ***]
#export TWO_TASK=ORCL
export TNS_ADMIN=$DOMAIN_HOME/config/fmwconfig/
export TERM=vt220
export ORACLE_TERM=$TERM

# Reports server: Adjust as required to allow forms to get the reports server name
# using "tool_env.getvar('REPORTS_SERVER_NAME', v_rep_server);"
export REPORTS_SERVER_NAME=rep_wls_reports_ol6-forms_asinst_1

I tend to use FR_HOME and FR_INST in place of ORACLE_HOME and ORACLE_INSTANCE as I think they are more descriptive. It's worth setting both as many documents don't follow my preference.

A number of the sections below assume these environment variables have been set.

◉ Configuration Files


Many of the 12c Forms and Reports Services configuration files are the same as those in 11gR2, but their locations differ. It is often easier to find things by searching below the $MW_HOME and $DOMAIN_HOME, as shown below.

$ find $DOMAIN_HOME -name formsweb.cfg

The files I tend to visit the most are listed below.

formsweb.cfg: Definitions of individual configurations.
$DOMAIN_HOME/config/fmwconfig/servers/WLS_FORMS/applications/formsapp_12.2.1/config/formsweb.cfg

default.env: Runtime environment parameter definitions.
$DOMAIN_HOME/config/fmwconfig/servers/WLS_FORMS/applications/formsapp_12.2.1/config/default.env

tnsnames.ora:
$DOMAIN_HOME/config/fmwconfig/tnsnames.ora

dads.conf: Does not exist in the 12c version of OHS! Install ORDS instead!

fmrweb.res: Key definition file for webforms.
$FR_INST/admin/resource/US/fmrweb.res

cgicmd.dat: Reports mapping file.
$DOMAIN_HOME/config/fmwconfig/servers/WLS_REPORTS/applications/reports_12.2.1/configuration/cgicmd.dat

A couple of the important files are described below.

◉ formsweb.cfg


The "formsweb.cfg" file is one of the most important configuration files as it allows you to define multiple configurations, or environments, within a single software installation.

Typically, each separate environment will have it's own section in the "formsweb.cfg" file, where environment-specific settings are placed. You only need to specify a value in a Named Configuration if it differs from that in the default configuration. For example, a named configuration might be simple, like the following.

[myapp]
form=MyDefaultForm.fmx
pageTitle=My Application Title
width=1024
height=768
separateFrame=true
imageBase=codebase
archive=frmall.jar,my_icons.jar
envFile=/path/to/myapp.env

A very useful entry is the "envFile" parameter, that can associate an environment file with a named configuration. This allows each named configuration run with a unique set of environment variables, including the FORMS_PATH variable amongst others. Any custom environment files should be derived from the "default.env" file, described below.

Changes to this file to not require a restart of any components. The changes can be done directly to the file, or through Enterprise Manager.

◉ default.env


The "default.env" file defines the forms runtime parameters for a specific environment. All custom environment files should be derived from this file.

Environment variables specified in an ".env" file override existing environment settings. If an environment variable is not defined in the ".env" files, the value from the session that started the server process will be used.

Changes to these ".env" files do not require a restart of any components. The changes can be done directly to the file, or through Enterprise Manager.

 It's is worth explicitly setting the NLS_LANG environment variable in the ".env" file to match the NLS details of the database the forms connect to, thereby removing any implicit character conversions.

NLS_LANG=AMERICAN_AMERICA.AL32UTF8

◉ Compiling Forms


Forms, menus and libraries are compiled using the frmcmp.sh or frmcmp_batch.sh scripts. You can find these in the "$FR_INST/bin/" directory. Running the command without any parameters displays the usage information. Some examples of the basic syntax are shown below.

$ export DISPLAY=mypc:0.0
$ $FR_INST/bin/frmcmp.sh module=myform.fmb module_type=form userid=scott/tiger

$ $FR_INST/bin/frmcmp_batch.sh myform.fmb scott/tiger module_type=form batch=yes output_file=myform.fmx compile_all=special

Remember, frmcmp.sh requires and X Server, so you will need to SSH tunnel (ssh -X oracle@server) or set your DISPLAY environment variable (export DISPLAY=mypc:0.0).

You can easily script the compilation of all your forms-related objects, as shown by the following script.

#!/bin/bash

export FORMS_PATH=/path/to/my/forms

export DB_USER=scott
export DB_PASSWD=tiger
export DB_SERVICE=ORCL

# Libraries
for FILE in `ls $FORMS_PATH/*.pll`; do
  OUTPUT=${FILE/pll/plx}
  echo "$FILE -> $OUTPUT"
  $FR_INST/bin/frmcmp_batch.sh $FILE $DB_USER/$DB_PASSWD@$DB_SERVICE \
    module_type=library batch=yes output_file=$OUTPUT compile_all=special
done

# Menus
for FILE in `ls $FORMS_PATH/*.mmb`; do
  OUTPUT=${FILE/mmb/mmx}
  echo "$FILE -> $OUTPUT"
  $FR_INST/bin/frmcmp_batch.sh $FILE $DB_USER/$DB_PASSWD@$DB_SERVICE \
    module_type=menu batch=yes output_file=$OUTPUT compile_all=special
done

# Forms
for FILE in `ls $FORMS_PATH/*.fmb`; do
  OUTPUT=${FILE/fmb/fmx}
  echo "$FILE -> $OUTPUT"
  $FR_INST/bin/frmcmp_batch.sh $FILE $DB_USER/$DB_PASSWD@$DB_SERVICE \
    module_type=form batch=yes output_file=$OUTPUT compile_all=special
done

◉ Compiling Forms From a Non-Oracle User


In Forms 11g and 12c using SUDO is the recommended way to compile forms as a non-Oracle user.

As the root user, edit the "/etc/sudoers" file with the following entry (as a single line).

myuser ALL=(oracle) NOPASSWD: /u01/app/oracle/middleware/asinst_1/bin/frmcmp.sh,
   NOPASSWD: /u01/app/oracle/middleware/asinst_1/bin/frmcmp_batch.sh

You can now run the compile commands from the user "myuser" by using the "sudo -u oracle" prefix. All environment variables discussed above must be set for this to work. An example is shown below.

$ sudo -u oracle $FR_INST/bin/frmcmp_batch.sh myform.fmb scott/tiger@orcl \
    module_type=form batch=yes output_file=myform.fmx compile_all=special

The TWO_TASK environment variable does not work correctly using this method, so you should use the "username/password@service" method for database authentication.

◉ Forms Builder


If you are running on RHEL7/OL7, you will need to create the following symbolic link as the root user. This is not necessary on RHEL6/OL6.

# ln -s /usr/lib64/libXm.so.4.0.4 /usr/lib64/libXm.so.3

If you have set the environment variables described above, using the X Server based Forms builder should be as simple as issuing the frmbld command.

$ export DISPLAY=mypc:0.0
$ frmbld &

OR

$ $FR_INST/bin/frmbld.sh &

◉ Compiling Reports


Reports are compiled using the rwconverter.sh script. You can find this in the "$FR_INST/config/reports/bin/" directory. Running the command without any parameters displays the GUI screen. An example of the command line syntax is shown below.

$ $FR_INST/config/reports/bin/rwconverter.sh userid=scott/tiger batch=yes \
    source=myreport.rdf stype=rdffile dtype=repfile overwrite=yes compile_all=yes

◉ Reports Builder


If you have set the environment variables described above, using the X Server based Reports builder should be as simple as running the rwbuilder command.

$ export DISPLAY=mypc:0.0

$ $FR_HOME/bin/rwbuilder &

◉ Webutil Configuration


The basic configuration is described below.

1. Download the zipped "jacob.jar" (v1.18-M2) file from https://sourceforge.net/projects/jacob-project/files/jacob-project/1.18-M2/.
2. Unzip the contents of the file.
3. Copy the "jacob.jar" to the "$FR_HOME/forms/java" directory.
4. Copy the "jacob-1.18-M2-x86.dll" to the "$FR_HOME/forms/webutil/win32" directory.
5. Copy the "jacob-1.18-M2-x64.dll" to the "$FR_HOME/forms/webutil/win64" directory.
6. Edit the "$FR_HOME/forms/java/extensions.jnlp" file, making the following change.

From this: <!-- <jar href="jacob.jar"/> -->
To this  : <jar href="jacob.jar"/>

7. Sign the "jacob.jar" file.

8. Add "$FR_HOME/forms/java/frmall.jar" to the CLASSPATH entry in the "default.env" file. This should be done with Enterprise Manager, but it works fine if you manually edit the file. If you use custom environment files, you should add it to those also.
Add "frmwebutil.jar" and "jacob.jar" to the "WebUtilArchive" entry in the "formsweb.cfg" file for any configurations that require it, for example.

WebUtilArchive=frmwebutil.jar,jacob.jar
WebUtilLogging=off
WebUtilLoggingDetail=normal
WebUtilErrorMode=Alert
WebUtilDispatchMonitorInterval=5
WebUtilTrustInternal=true
WebUtilMaxTransferSize=16384
baseHTML=webutilbase.htm
baseHTMLjpi=webutiljpi.htm

9. After making changes, restart the WLS_FORMS managed server and the OHS.

# Stop
$DOMAIN_HOME/bin/stopComponent.sh ohs1
$DOMAIN_HOME/bin/stopManagedWebLogic.sh WLS_FORMS

# Start
nohup $DOMAIN_HOME/bin/startManagedWebLogic.sh WLS_FORMS > /dev/null 2>&1 &
$DOMAIN_HOME/bin/startComponent.sh ohs1

Additional configuration is possible by editing the "$FR_INST/config/FormsComponent/forms/server/webutil.cfg" file.

◉ Jar File Security Warning Hangs


Unsigned or self-signed jar files cause a browser security warning dialog to appear.

Oracle Database Tutorials and Certifications, SAS Guides, SAS Learning

On some clients the behavior of this dialog is rather erratic, sometimes hanging and preventing you from taking the appropriate action. This seems to relate to two MOS notes.

◆ Form Hangs When Acknowledging Security Warning - The application's digital signature cannot be verified [ID 1328039.1]
◆ Windows Java Client Hangs On Accepting Not Verified Signature Of jar Files When SeparateFrame=True [ID 1173365.1]

The solution is to alter the order of the Jar files set by the "archive" and/or "WebUtilArchive" entries in the "formsweb.cfg" file. In the case of the "jacob.far" file, if you have it listed in the "archive" parameter, you will probably need to make the following change.

#Before
archive=frmall.jar,jacob.jar

#After
archive=jacob.jar,frmall.jar

If you have instead listed it in the "WebUtilArchive" parameter, you will probably need to make the following change.

#Before
WebUtilArchive=frmwebutil.jar,jacob.jar

#after
WebUtilArchive=jacob.jar,frmwebutil.jar
You should not need to restart any services for this to take effect.

◉ Sign JAR Files


Edit the "$FR_INST/bin/sign_webutil.sh" file, setting the appropriate values. If you want to generate a new certificate and keystore you must enter the following information, adjusted as desired.

DN_CN="myserver.example.com"
DN_OU="My Department"
DN_O="My Company"
DN_L="My City"
DN_ST="My State"
DN_C=GB
KEYSTORE_PASSWORD=password1
JAR_KEY_PASSWORD=password1
VALIDDAYS=3600

If you created a keystore for securing your managed servers, you can reuse that by editing the following settings to match the details of your existing keystore.

KEYSTORE=/home/oracle/keystore/identity.jks
KEYSTORE_PASSWORD=password1
JAR_KEY=selfsigned
JAR_KEY_PASSWORD=password1

Make sure line 84 has the correct path to the "keytool" utility. I had to make the following change to the line.

From this: error_text=`/u01/app/oracle/product/12.2.1/wlserver/../jdk/bin/keytool -genkey -dname "CN=$DN_CN, OU=$DN_OU, O=$DN_O, C=$DN_C" \
To this  : error_text=`/u01/app/oracle/product/12.2.1/oracle_common/jdk/bin/keytool -genkey -dname "CN=$DN_CN, OU=$DN_OU, O=$DN_O, C=$DN_C" \

Make sure line 108 has the correct path to the "jarsigner" utility. I had to make the following change to the line.

From this: error_text=`/u01/app/oracle/product/12.2.1/wlserver/../jdk/bin/jarsigner -keystore $KEYSTORE -storepass $KEYSTORE_PASSWORD -keypass $JAR_KEY_PASSWORD \
To this  : error_text=`/u01/app/oracle/product/12.2.1/oracle_common/jdk/bin/jarsigner -keystore $KEYSTORE -storepass $KEYSTORE_PASSWORD -keypass $JAR_KEY_PASSWORD \

Issue to the following command to sign the specified JAR file. In this case it is the jacob.jar file. If you are using a self-signed certificate this will result in a warning, and since return text is not blank the script will say the signing failed, but it didn't.

$ $FR_INST/bin/sign_webutil.sh $FR_HOME/forms/java/jacob.jar

If you attempt to re-sign a JAR file that is already signed, it will contain multiple signatures in the "META-INF" directory, which will probably result in the following error.

sun.security.validator.ValidatorException: PKIX path validation failed:
  java.security.cert.CertPathValidatorException: signature check failed

To fix this, unpack the JAR, remove the signatures from the "META-INF" directory and re-pack the JAR. The following example shows how this can be done for the "jacob.jar" file.

mkdir $FR_HOME/forms/java/temp
cd $FR_HOME/forms/java/temp

export MYJAR=jacob.jar
unzip ../$MYJAR
rm -f META-INF/*.SF META-INF/*.DSA  META-INF/*.MF
# You may need to remove more, so visually check.
$JAVA_HOME/bin/jar -cvf $MYJAR *
mv $MYJAR ..
rm -Rf *

cd ..
rmdir $FR_HOME/forms/java/temp

Once you've stripped the signatures from the JAR file you will need to resign it.

I've combined this method, along with the signing of the JAR file into following script, which I save as "resign_jars.sh".

mkdir $FR_HOME/forms/java/temp
cd $FR_HOME/forms/java/temp

function sign_jar {
  export MYJAR=$1
  unzip ../$MYJAR
  rm -f META-INF/*.SF META-INF/*.DSA META-INF/*.MF

  echo "Manifest-Version: 1.0" >> META-INF/MANIFEST.MF
  echo "Created-By: 1.6.0_37 (Oracle Corporation)" >> META-INF/MANIFEST.MF
  echo "Permissions: all-permissions" >> META-INF/MANIFEST.MF
  echo "Application-Library-Allowable-Codebase: *" >> META-INF/MANIFEST.MF
  echo "Caller-Allowable-Codebase: *" >> META-INF/MANIFEST.MF
  echo "Application-Name: Oracle Forms MyCompany" >> META-INF/MANIFEST.MF
  echo "Created-By: MyCompany" >> META-INF/MANIFEST.MF

  # You may need to remove more, so visually check.
  $JAVA_HOME/bin/jar -cvf $MYJAR *
  mv $MYJAR ..
  rm -Rf *
  $FR_INST/bin/sign_webutil.sh $FR_HOME/forms/java/$MYJAR
}

sign_jar frmall.jar
sign_jar frmgeneric_laf.jar
sign_jar frmmain.jar
sign_jar frmoracle_laf.jar
sign_jar frmresources.jar
sign_jar frmwebutil.jar
sign_jar jacob.jar
cd ..
rmdir $FR_HOME/forms/java/temp
This will strip and resign any JAR file passed as a parameter to the "sign_jar" function.

◉ REP-52262: Diagnostic output is disabled.


Reports 11.1.2.1 turns off the diagnostics output by default. If you need to turn it on, do the following.

Edit the "$DOMAIN_HOME/config/fmwconfig/servers/WLS_REPORTS/applications/reports_11.1.2/configuration/rwservlet.properties" file as follows.

# From
<inprocess>yes</inprocess>

# To
<inprocess>yes</inprocess>

<webcommandaccess>L2</webcommandaccess>
Restart WLS_REPORTS server.

Once you have finished testing, you will probably want to remove the new entry and restart the WLS_REPORTS server.

◉ In-Process Reports Server not Starting Properly


After a clean start of the Forms and Reports Services, the in-process reports server should start automatically on the first attempt to run a report. In practice, this does not seem to happen. There are a number of ways to kick the in-process reports server into touch.

The "startserver" URL can be used to start the in-process reports server. Adding the following commands to the end of your startup script will start make sure it starts as expected.

sleep 600
curl http://localhost:8888/reports/rwservlet/startserver > /dev/null 2>&1 &

If you have enabled the diagnostics pages (discussed earlier), any call to a diagnostics page will start the in-process reports server. Adding the following commands to the end of your startup script will start make sure it starts as expected.

sleep 600
curl http://localhost:8888/reports/rwservlet/getserverinfo > /dev/null 2>&1 &

You can also start the process using the Reports application page in Oracle Enterprise Manager. Either use the "Monitoring > Start Reports Application" option or the "Administration > Start In-process Reports Server" option.

◉ Key Mappings


The shortcut keys used by Forms can be altered by editing the key mapping resource file for your specific language. The default US/English language uses one of the following resource files, depending on the character set being used.

$FR_INST/admin/resource/US/fmrweb.res
$FR_INST/admin/resource/US/fmrweb_utf8.res

◉ Reports Fonts


The fonts available for the Reports server are defined in the following files.

$FR_INST/guicommon/tk/admin/uifont.ali
$FR_INST/guicommon/tk/admin/uiprint.txt
$MW_HOME/frcommon/templates/tk/config/screenprinter.ppd

The fonts referenced in these configuration files must be present in the following directory.

$FR_HOME/guicommon/tk/admin/AFM

After making any changes, restart the Forms and Reports Services.

◉ SSL Configuration


SSL configuration of Forms and Reports Services can seem a little tricky as there are a number of different elements to consider, including:

◆ The AdminServer, WLS_FORMS and WLS_REPORTS managed servers. Explained here.
◆ The JAR files used by the Forms and Reports Services. Explained here.
◆ The Oracle HTTP Server (OHS). See below.

To configure the Oracle HTTP Server (OHS), do the following steps, which assume you have already configured the managed servers for SSL using a keystore as described here.

Create a new wallet.

cd ~/keystore
$MW_HOME/oracle_common/bin/orapki wallet create -wallet ./ -pwd password1 -auto_login

Load the contents of the previously created keystore into the new wallet.

$MW_HOME/oracle_common/bin/orapki wallet jks_to_pkcs12 -wallet ./ -pwd password1 \
  -keystore identity.jks -jkspwd password1

Edit the "$DOMAIN_HOME/config/fmwconfig/components/OHS/instances/ohs1/ssl.conf" file, altering the path to the wallet as shown below.

#Path to the wallet
#SSLWallet "${ORACLE_INSTANCE}/config/fmwconfig/components/${COMPONENT_TYPE}/instances/${COMPONENT_NAME}/keystores/default"
SSLWallet  "/home/oracle/keystore"

Restart the Oracle HTTP Server.

$DOMAIN_HOME/bin/stopComponent.sh ohs1
$DOMAIN_HOME/bin/startComponent.sh ohs1

The Oracle HTTP Server is now using the certificate in the wallet to support HTTPS traffic.