Kategorie-Archiv: Oracle ADF

Posts containing information about Oracle ADF

Using log4j2 in an Oracle ADF 12c Application

Configure ADF12c application to work with log4j2

One of our customers had the requirement to use log4j 2 in his ADF 12c application. When executing his code

an UnsupportedOperationException was thrown.

To resolve this issue you can configure your ADF12c application to use a specific implementation of DocumentBuilderFactory. This is quite simple and straightforward. Just configure your weblogic specific deployment descriptor (weblogic-application.xml) to use

as application’s DocumentBuilderFactory implementation. This is what worked for us. Other implementations of DocumentBuilderFactory might be valid, too. To configure the DocumentBuilderFactory you can use JDeveloper tooling:

This will put the following lines into your weblogic-application.xml:

To dodge possible other unsupported operations, we also provided values for SAX Parser Factory and Transformer Factory:

  • SAX Parser Factory: com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
  • Transformer Factory: com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

The screenshot below shows our configuration:

 

Prerequisites

The following JARs have been added to project’s classpath:

  • log4j-api-2.1.jar
  • log4j-core-2.1.jar
  • log4j-web-2.1.jar

These files are contained within the log4j2 download package.

Follow ups

Without providing any configuration file log4j2 will log our messages on console. To configure another behavior just put a configuration file into your project’s src directory (e.g.  ./Model/src or ./ViewController/src).  The  configuration file itself can be written in XML, JSON, or YAML. For more information on the expected syntax have a look at log4j2’s official documentation.

 

Providing Input Parameters for Taskflows in UI Shell

When trying out to build your own UI Shell based application you possibly have used the pre-implemented source code for your launcherBean that can be found at http://www.oracle.com/technetwork/developer-tools/adf/uishell-093084.html.

This code works well, but if you want to pass parameters into a taskflow the Launcher class does not provide any interface. The solution is simple but powerful.

When analyzing UI Shell’s TabContext class you will find two appearances of a method called addTab:

As you can see in the signature of the second addTab-method, UI Shell provides the possibility to pass a Map<String, Object> that holds parameters for our task flow. Keeping that knowledge in mind we are able to modify the Launcher class provided by OTN in two steps:

1. Overload method _launchActivity

In order to overload the pre-implemented _launchActivity method edit Launcher.java and insert the following code snippet:

2. Simplify old _launchActivity method

For consistency reasons we should modify the “original” _launchActivity method in the following way:

An example of passing a parameter into a taskflow is shown below. Create a button within your navigation area. Define the following code snippet as an action listener method of that button (insert code into your launcher class).

So, what does this new method cause? When the button is clicked we generate a HashMap that contains the parameter inParameter with its value “Hello World!”. This map is used to pass the containing parameter into the taskflow via _launchActivity method.

Sample Taskflow

This paragraph describes how to build a sample taskflow. The taskflow itself contains a single view activity with a corresponding page fragment. To use the inParameter we want to pass, we have to define an input paramter in our taskflow. To do this open the taskflow and click somewhere, but not onto the view activity. The property inspector should show the task flow definition attributes now. Under section Parameters we can see the subsection Input Parameter Definitions. Click the green plus to add a new parameter. Name the parameter inParameter and define that its class is java.lang.String. The fields “value” and “required” should be empty. Have a look at the image below to see an overview of the desribed information in this paragraph. As you can see, the name of the task flow input parameter must match the key we passed in our parameters map via _launchActivity method.

 

As intended, we are able to use the input parameter within the taskflow by using the EL expression #{pageFlowScope.inParameter}.

Please note: I already posted this on ADF Juggernaut in march 2011.

Update: I have submitted a simple sample application regarding this topic to ADF EMG Samples repository. Search for “UIShellParameter.zip” or click here to download it!

JDeveloper Installation on Debian – “no space left on device” Issue

Hello world!

Yesterday I installed Linux Mint Debian Edition (LMDE) on my notebook. It seems to be a rock solid distribution, but as Clem announced in his blog post it has “some rough edges”. One rough edge I had been experiencing was an annoying “no space left on device” error when I tried to install Oracle JDeveloper on my brand new system. Believe it or not: The error cause is not a bug – it is a feature! This post is about fixing the installation issue caused by that feature. Although it talks about a JDeveloper installation the suggested ways can be a applied to other programs that cause the issue mentioned above.

Scenario

As described in the previous paragraph I tried to install Oracle JDeveloper 11.1.1.6.0 on my notebook:

After a few seconds the following window was popping up:

Cause Analysis

The error description “no space left on device” was a little bit confusing to me, because I just installed LMDE on a 500 GiB hard disk and I could not imagine that LMDE would have occupied the whole disk space. When checking the free disk space with

I recognized the high usage of the /tmp partition (96%, line 6):

Newer debian (linux) systems allow to use RAM as a “directory” for writing / reading temporary data. This increases speed of programs that need space for temporary data. For the most use cases the size of such a RAM-based temporary partition is adequate. An insurgent program that needs a huge amount of temporary space is the Oracle JDeveloper installer. It looks up the system’s temp directory in order to extract round about 2 GiB of data to that directory. So the cause of the occuring “no space left on device” error was the huge amount of data the installer tried to write to my limited RAM-based /tmp partition.

Solutions

There are (at least) three ways to solve the issue.

Solution 1 – Dynamically resize /tmp at runtime

Because /tmp is mounted as a tmpfs you can resize it dynamically at runtime. Just clear the content of /tmp and resize its space:

This is the recommended way, because it ensures a fast running installation process. For installing JDeveloper the size of 2560m (= 2.5 GiB) was adequate. Depending on your use case you might have to choose a higher value like 3g (= 3 GiB).

Solution 2 – Use custom directory instead of RAM for temporary data (java specific)

The JDeveloper installer is a java program. So it is possible to configure a custom temp directory via _JAVA_OPTIONS environment variable:

Runtime of this approach is a little bit slower than runtime of solution 1, but it works…

Solution 3 – Use disk space instead of RAM (system-wide and permanent => slows down programs that access /tmp)

Another solution is to prevent /tmp from being mounted as RAM based tmpfs. To achieve this perform the following two simple steps and you are done:

  • Edit /etc/default/rcS as superuser and replace RAMTMP=yes by RAMTMP=no
  • reboot

Works like solution 2, but is not java specific. In contrast to the first two solutions, it has a permanent effect. You should choose this option, if you are constantly experiencing the “no space left on device” error when running various programs.

 

Please note: A filled to overflowing /tmp partition is not the only matter that can cause a no “space left on device” error. If you are not able to identify a chock-full /tmp partition by using

try

to see, if you are running out of inodes. If you are able to identify a value near 100% follow the instructions on Ivan Kuznetsov’s blog.