Year: 2014

Oracle ADF: Required grants when implementing the UIShell

When implementing the Oracle ADF UIShell, it is crucial to set the necessary grants for the UIShell template and the UIShell task flows imported from the ADF libraries. If these grants are not correctly assigned, the dynamic areas of the UIShell remain empty. If unsure, you can check if the dynamic areas are generally working at all by temporarily disabling ADF security. If they do, but then are again empty after re-enabling security, the grants are not properly set up. To assign the necessary grants, open jazn-data.xml through JDeveloper’s “Application/Secure/Resource Grants” menu and select “Resource Type: Web Page”. Make sure to check “Show web pages imported from ADF libraries” – otherwise, only the pages from the project are shown, but not those which reside within ADF libraries. Assign the anonymous-role to oracle_apps_fnd_applcore_templates_UIShell:

Then, select “Resource Type: Task Flow”, and again make sure that “Show task flows imported from ADF libraries” is checked. Assign the anonymous-role to the MainArea, RegionalArea and TasksList task flows as follows:

Oracle JDeveloper: how to define the default run target

In JDeveloper, an application can be deployed to the internal weblogic server by selecting an entry in the project navigator and choosing “Run” from the context menu. JDeveloper then also prints the target URL through which the application can be accessed to its console. Which file is actually used as the application’s starting point and how the target URL is constructed can be defined in the “Run configuration” of the project (usually the ViewController project). Select the ViewController project, and then from the context menu choose “Project Properties”. In the “Project Properties” dialog, select the “Run/Debug/Profile” section from the tree on the left, and then edit the run configuration. The “Edit Run Configuration” dialog is shown (click to enlarge):

In the “Edit Run Configuration” dialog, there are two sections which define the default run target:
  • “Launch Settings” defines the file to use as the run target. This can for example be an ADF task flow file such as adfc-config.xml for the unbounded task flow or a particular .jspx file. Below is the option “Attempt to Run Active File before Default”: this influences whether JDeveloper shall always use the file provided above, or, when a particular file is currently selected in the project navigator, JDeveloper shall first try to use that file as the run target.
  • In case the default run target is an ADF task flow, there is a second section in the “Edit Run Configurations” dialog which needs to be considered: “Launch Settings => ADF Task flow”. There, the actual task flow to execute by default is defined.

Resolving build dependencies through manifest file

The MANIFEST.MF file in a jar file can be used to define runtime dependencies through the Class-Path attribute. In the manifest specification, it says:

Class-Path: The value of this attribute specifies the relative URLs
of the extensions or libraries that this application or extension needs. 
URLs are separated by one or more spaces. 
The application or extension class loader uses the value of this attribute
to construct its internal search path.

Since it explicitly states “application or extension class loader”, it is not completely clear from the specification that the Class-Path attribute is also considered by the javac compiler to resolve build dependencies. However, it is – this is the bug which introduced that feature in Java 5: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4212732 Consider the following sample code which imports classes from some third party jar files:

package com.example;

import org.apache.log4j.PropertyConfigurator;
import com.google.gson.Gson;

public class Sample {

   public static void main(String[] args) {
      PropertyConfigurator.configure("log4j.properties");
      Gson gson = new Gson();

      // ...
   }
}

We can create a jar file like libs.jar with a Class-Path reference to the corresponding libraries:

$ cat manifest.txt
Class-Path: lib/gson-2.2.2.jar lib/log4j-1.2.17.jar

$ jar cvfm libs.jar manifest.txt
added manifest

By simply adding the libs.jar to the classpath when invoking javac, the additional jar files get pulled in:

$ javac -d bin -classpath libs.jar -sourcepath src src/com/example/Sample.java

$ ls -la bin/com/example/Sample.class
-rw-r--r-- 1 andreas users 432 Apr  7 12:20 bin/com/example/Sample.class

A real-world sample where this is used is the Oracle Platform Security Services. There is only one jar file which needs to be added to the build path, jps-manifest.jar, which references all other required jar files through its Class-Path attribute.

Passing string parameters to a SQL*Plus script

With SQL*Plus, it is possible to use parameters in the form &1, &2, … inside a script to be executed through the sqlplus command and pass the parameter values from the command line. Consider this script, contained in a file called sample.sql:

SELECT '&1' FROM DUAL;

This script can be executed from a unix shell using sqlplus as follows:

$ sqlplus user/pass@instance @sample.sql Hello
...
old   1: SELECT '&1' FROM DUAL
new   1: SELECT 'Hello' FROM DUAL

'HELL
-----
Hello

Now, it is also possible that the parameter is not quoted inside the script:

SELECT &1 FROM DUAL;

If we execute this script in the same way as before, SQL*Plus simply inserts the parameter into the SELECT statement and it is finally treated as identifier:

$ sqlplus user/pass@instance @sample.sql Hello
...
old   1: SELECT &1 FROM DUAL
new   1: SELECT Hello FROM DUAL
SELECT Hello FROM DUAL
       *
ERROR at line 1:
ORA-00904: "HELLO": invalid identifier

To really pass the parameter as String, we need to properly escape it on the command line, using double quotes, single quotes and both of them need to be escaped:

$ sqlplus user/pass@instance @sample.sql \"\'Hello\'\"
...
old   1: SELECT &1 FROM DUAL
new   1: SELECT 'Hello' FROM DUAL

'HELL
-----
Hello

Note that using parameters this way should always be taken with care, so that no sql injection security issues are introduced!