Pages

26 January 2011

Use Log4j in JDeveloper

Excellent post here on how to use log4j in JDeveloper.


Check Log4j Conversion Patterns and Overhead to see how you can tune the logging info of log4j to satisfy your needs and also the performance overhead they produce.


21 January 2011

Debug ADF Rich Faces

For debugging Rich Faces using Firebug check
"Advanced Javascript debugging with FireBug and analyzing your page with View Source Chart"


The following sections in the Developer's Guide may help you in understanding how the javascripts are generated, and also set up some options for debugging (org.apache.myfaces.trinidad.DEBUG_JAVASCRIPT f.ex.):

1.2.1.2 JavaScript Library Partitioning
http://download.oracle.com/docs/cd/E15523_01/web.1111/b31973/gs_intro.htm#BABJGCAI

A.9 Using JavaScript Library Partitioning
http://download.oracle.com/docs/cd/E15523_01/web.1111/b31973/ap_config.htm#BABCJIDJ

and other documents like:

"Oracle Application Development Framework Performance Tuning" in the "Oracle Fusion Middleware Performance and Tuning Guide"
http://download.oracle.com/docs/cd/E16764_01/core.1111/e10108/adf.htm#CIHHGADG


What is org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS?


According to "Configuring Apache Trinidad" documentation
 In "token"-based client-side state saving, chooses how many tokens should be preserved at any one time. The default value is 15. When this is exceeded, state will have effectively been "forgotten" for the least recently viewed pages, which can impact users that actively use the Back button or that have multiple windows open simultaneously. Developers building HTML applications that rely heavily on frames will likely need to increase this value.

Also there is an nice explanation found on OTN by Simon Lessard
As for client side vs. server side, using Trinidad, there's little difference. But let me do a small recap:

JSF 1.1
server = a single view saved on the server, extremely back button error prone
client = the whole view is saved on the client, increasing network latency by increased request and response size.

JSF 1.2
server = view is Serialized on the server and identified by a token on the client. Efficient and quite back button safe, unless the user click many times on back then the threshold get busted and ViewExpiredException is thrown.
client = the whole view is saved on the client, increasing network latency by increased request and response size.

ADF Faces
server = a single view saved on the server, extremely back button error prone.
client = view is Serialized on the server and identified by a token on the client. Way more efficient than default client saving, but then again there's a threshold like JSF 1.2 server state saving.

Trinidad 1.2.x
server = a single view saved on the server, extremely back button error prone.
client = depends on org.apache.myfaces.trinidad.CLIENT_STATE_METHOD:

org.apache.myfaces.trinidad.CLIENT_STATE_METHOD:
token (default) = same as server side as of JSF 1.2, but you can control the amount of token with org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS parameter;
all = default client state saving.

Finally, from Appendix A - ADF Faces Configuration of Oracle® Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework 11g Release,
you can see a wider aspect of state saving in ADF
A.2.3.1 State Saving
You can specify the following state-saving context parameters:
  • org.apache.myfaces.trinidad.CLIENT_STATE_METHODSpecifies the type of client-side state saving to use when client-side state saving is enabled by using javax.faces.STATE_SAVING_METHOD. The values for CLIENT_STATE_METHOD are:
    • token: (Default) Stores the page state in the session, but persists a token to the client. The simple token, which identifies a block of state stored back on the HttpSession object, is stored on the client. This enables ADF Faces to disambiguate the same page appearing multiple times. Failover is supported.
    • all: Stores all state information on the client in a (potentially large) hidden form field. It is useful for developers who do not want to use HttpSession.
    Performance Tip:
    Client-side state saving is recommended. However, because of the potential size of storing all state information, it is recommended that you set client-state saving to token.
  • org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS: Specifies how many tokens should be stored at any one time per user, when token-based client-side state saving is enabled. The default is 15. When the number of tokens is exceeded, the state is lost for the least recently viewed pages, which affects users who actively use the Back button or who have multiple windows opened at the same time. If you are building HTML applications that rely heavily on frames, you would want to increase this value.


20 January 2011

TROUBLESHOOTING: "Because of inactivity, your session has timed out and is no longer active..."

Last updated: 7/4/2011

Problem
The following error might occur will navigating to your app.


Solution
One of the reason might be that org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS value is not great enough.

Add the following param in your web.xml and setting according to yourneeds:


Memory consuption
What about memory consuption? See my related pos: Memory consumption of org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS

Theory
For some theory behind CLIENT_STATE_MAX_TOKENS check my related post "What is org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS?"





Dig more:

19 January 2011

ADF Faces Memory Scopes

Scopes in the context of pages(jspx)

Scopes in the context of fragments(jsff)


6 Types of Memory Scopes
There are six types of memory scopes in a Fusion web application:


  • Application scope: An application scope object is available for the duration of the application and is shared among users. This scope may be used to hold static objects that are the same for all users.
  • Session scope: The object is available for the duration of the session, which is user instance-specific. A use case for a session scope bean is a user info bean that stores information about a user, which is read from the database or an LDAP server, to avoid unnecessary queries.
  • Page flow scope: A pageFlow scope exists for each task flow instance and has a lifespan between request and session scope. The lifetime of the scope spans across all pages in a bounded task flow.
  • Request scope: The object is available from the time an HTTP request is made until a response is sent back to the client. From another perspective, a request scope starts with a request to be issued from one view to another for navigation cases that don't perform a redirect but a default server-side forward. The scope spans across all non-view activities that follow the view of interest to the next view activity.
  • Backing bean scope: The backing bean scope is comparable to the request scope, with the difference in that it exists for a specific client component. In general, all managed beans used in reusable components should be configured to backingBean scope. For example, bounded task flows that are designed to be regions on a page should use the backingBean scope if more than one instance of the task flow is expected to be on a single page.
  • View scope: The object is available until the view ID for the current view activity changes. This becomes handy when you use partial page rendering. If you have a dependent list box, you might send a server request to refresh the list box. When a response is returned, the request scope will be gone but the view scope will be still there. Therefore, view scope can be used to store data when partial rendering request comes back. The view scope exists not only for views that are rendered by JSPX pages, but also for views rendered by page fragments, as is the case in task flows that are built to execute in a region. The view scope of the parent page is not accessible from components added to a page fragement in a region, and the view scope of a view in a region is not accessible for the parent page.

Dig more:

18 January 2011

Using Diagnostic Messages for troubleshooting

You can enable Diagnostic messages when running your application (on WLS (WebLogic Server) or BC Tester).

Enable diagnostic messages post will tell you how to configure the BC and/or Weblogic Server to print these messages.

To find the available diagnostic message you can enable, take a look at oracle.jbo.common.logging.Diagnostic.properties file.
This file's  purpose is  for DEBUG build of Business Components for Java. This is the file used to determine the way that Diagnostic  calls in the code are handled: all of its the properties  can be overridden by specifying then as -D switches to the java VM.


The available properties are:

jbo.debugoutput=console
Valuesconsole|silent|classname|file
Which implementation of IDiagnostic to use: console|silent|classname classname is the fully qualified name of a user-defined class that implements the IDiagnostic interface
Also a 4th options is available. You can set it to be jbo.debugoutput=file.
In this case the diagnostic messages will be written to file. The location of the file is the system/user temp 
directory and will be printed (so as for you to be sure the -D switches are applied ) when you run your 
application (either from the BC Tester (when testing BC) or when running app on Weblogic).
eg.
Target URL -- http://127.0.0.1:7101/MyWebapps-context-root/faces/main
Diagnostics: (Properties (re)loaded) Routing diagnostics to File: C:\DOCUME~1\spiros\LOCALS~1\Temp\bc4j5308862451677235376.log


jbo.logging.show.function=false
Values:true|false
Setting to true will output the name of the class and method displaying the log.
Eg. <3>[11] (10) RowSetHelper.getListeners Getting listeners ready...
In the above example:
  •  <3>  - the message is issues at trace level 3
  •  [11] - this is trace line number 11
  •  (10) - 10 ms have elapsed since the last trace message
  •  RowSetHelper - class from which the trace message was issued
  •  getListeners - function from which the trace message was issued
  •  Getting Listeners ready ... - test of the trace message


jbo.logging.show.linecount=true
Values:true|false
Show a linecount as each diagnostic line is output (true|false)


jbo.logging.trace.threshold=3
Logging cutoff threshold: any trace messages with a level  higher than this threshold will be suppressed (to understand it better log4j has the reverse priority).
For a release build, system Diagnostic messages are at level 3
dditionally, in a Debug build, DebugDiagnostic messages are at level 6


jbo.debug.prefix=DBG
Prefix string to display on DebugDiagnostic lines.Debug build only


jbo.logging.show.timing=false
Show elapsed time info every call (true|false)


jbo.logging.show.level=false
Show level of trace statement




Dig more:



Enable Diagnostic Messages on your ADF Application

Last Upate: 1/4/2011
 
In order to troubleshoot the problem of your Fusion Web Application, you can enable the diagnostic messages on the WLS (WebLogic Server) that you application is running.

Enable Diagnostic messages in BC
To enable diagnostic message in BC check Turn on Diagnostic to Debug Oracle ADF BC Applications

Reposting:
  1. Select the project (e.g., "Model").
  2. Do right mouse click and select "Project Properties"
  3. On the property dialog, select "Run/Debug/Profile".
  4. Edit your Run Configuration (e.g., "Default")
  5. On the right pane, you should see "Java Options" input text field. Add the following Java system parameter: -Djbo.debugoutput=console



Enable Diagnostic messages in View
You can enable both on the embedded or standalone WLS.

  • The embedded WLS is the one that is running when you run your application from JDeveloper (during development)


  • A standalone WLS is when you run wls from the start script (usually in production systems). You can run the embedded as a standalone too.

(cmd for windows , sh for Unix)

In the following examples will be enabling only 2 diagnostic options:
  • -Djbo.debugoutput=file  
  • -Djbo.logging.show.function=true
You can find more on diagnostic messages related post.

Enabling diagnostic messages in embedded WLS 
You can enable diagnostic messages
  • Open your ViewController Project Properties
  •  run/debug/profile
  • Edit
  • In "Java Options" add the parameters for enabling dagnostic messages. e.g. -Djbo.debugoutput=file  -Djbo.logging.show.function=true



Moreover, you can perform this steps to a Model problem in case you want to have diagnotic messages when running Bussiness Components Tester.

Enabling diagnostic messages in standalone WLS
In the following example will be using the WLS that is shipped with JDeveloper as a standalone in a Windows machine.  
Go to WLS bin directory. In our case  %JDEV_SYSTEM_DIR%\DefaultDomain\bin\ 
eg
C:\JDeveloper\mywork\system11.1.1.3.37.56.60\DefaultDomain\bin\ 
(Note: Check related post to find out the JDEV_SYSTEM_DIR from log of the running WLS.)

Open file setDomainEnv.cmd On the top of the file after the comments enter the following line Then modify the following line (in the same line.)
to (in the same line.)



The is also an alternative way. You do not need to set -D params but edit the Diagnostic.properties file. Just take a look on the following quoted text:

Business Component diagnostics can be controlled by setting various jbo.xxx system properties. By default, the system property definitions reside in the file Diagnostic.properties in the .\oracle\jbo\common path on theCLASSPATH.
A default version of this file is supplied in the .\lib\jbomt.zip library. You can permanently change the default settings by extracting this file from the .zip archive, changing the values of the properties in the file, and making it available earlier in your project's library path. The file must appear before the library named "JBO Runtime" in the appropriate .\oracle\jbo\common subdirectory.
(I ll try to find time to give a more detailed and ready to  use example)


dig more:

14 January 2011

What ADF Error Messages mean (eg. JBO-xxxxx or ADFC-xxxxx etc. )

Last Update: 17/1/2011

Errors, that you can see in the log files of your app, source from middleware (ADF part) or DB. In the reference below a Source/Caution and an Action is provided to help resolve the problem

On the top I created a page "SEARCH ADF ERROR MESSAGES", that can help in locating the problem. It searches all the Error Message types referenced below.

Fusion Middleware Error Messages

In the link below are all the error message regarding the Fusion Middleware

where you ll find also 


JBO Error Messages
It is a subpart of Fusion Middleware Error Messages.
So, check the link above (JBO Error Messages)
Check also Business Components for Java Error Messages. There are some errors not mentioned in the above link


ORA Error reference
Regarding Oracle DB error messages check:

Note:
If you need an older version google for "Oracle<the BD version you want> Database Error Messages"
Also here you can find a search utility too.


BEA Error reference
This are the error produced from Weblogic (BEA was the company created Weblogic before Oracle buy BEA)
Oracle Fusion Middleware Oracle WebLogic Server Message Catalog 11g Release 1 (10.3.4)

dig more:

09 January 2011

Watch the data of a Row in the debugger

During development your logic in the EntityImpl of your Entity or the ViewRowImpl of your VO,  if you want to check all the values of the other attributes of the current row, there is no need to output them with log msgs or sops.  You have to just put a Breakpoint in the desired point in the above classes  and check the following paths in the Data pane of JDeveloper:

For EntityImpl:
  • this
    • mData
      • mStorage
        • an attribute per index

For ViewRowImpl 
  • this
    • mInner 
      • mRows 
        • [0] (assuming you want to see the data of the 1st) 
          • mData 
            • mStorage
              • an attribute per index
For example if we have
Then
For Entity:

For ViewRowImpl:



05 January 2011

The easiest way to check SOA Suite and BPM Suite 11g

Last update: 15/2/2011

Update: The following link seems not to be working any more. Check Pre-Built Developer Virtual Machines for new alternative.

Just use the Pre-built Virtual Machine for SOA Suite and BPM Suite 11g.
All necessary instructions are located in the link above.

Things that might trouble you are:

1.
Replace all contents of combine.com (if you are on Windows)  with
echo Combining parts into vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk ...
copy /B vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.001+vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.002+vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.003+vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.004+vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.005+vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.006+vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk.007 vbox-oel5u4-soabpm-11gr1ps2bp1-oracle.vmdk
as it is stated in the containing xml or download the new version in http://edelivery.oracle.com/otn/other/virtualbox/soavbox/combine.cmd .


2.
You might want to tune the memory assigned to virtual machine. Go to Settings and set it according to your needs. For booting the virtual machine less than 1.5Gigs but for working with SOA Suite you might need even more than assigned by default.

3.
After starting the virtual machine,  you ll see that Oracle XE boots at start up, but not WLS. You cannot boot WLS with
$/home/oracle/bin/start-wls-server.sh
related scripts are also there.

4.
All necessary passwords and given in the top link and in the Read me located at virtual machines desktop

5.
In order to access the services running in the virtual box from your host you must configure port forwarding in VirtualBox for each port of a service
eg for OracleXE that listens to 1521
VBoxManage modifyvm "vbox-oel5u4-soabpm-11gr1ps2-bp1-otn_1" --natpf1 "guestdb,tcp,,1521,,1521"
See my related link for more VirtualBox: Configure networking for running server on virtual guest

Finally, check here for more virtual machine images that might interest you.


Dig more

Create a Virtual machine with Fedora running Oracle XE

It is a good idea to build servers for testing in seperate virtual machines, in order to have a seperated environment. Here we ll create Fedora Virtual Machine with VirtualBox running Oracle XE
  1. Get your Fedora 14 VirtualBox image from http://virtualboxes.org/images/fedora/.
    Active user account(s) (username/password): root/tooroot, fedora/reverse
  2. Open "Virtual Media Manager" of VirtualBox and DnD in it the Fedora's VDI (VDI stands for something like VirtualBox Disk Image) that you just downloaded (after extracting it from rar)
  3. Create a Fedora Machine (if you name it FedoraSomething, eg Fedora14, will auto set the correct type)
  4. Set to use the existing Hard Disk that you configured above.
  5. Do not forget to set NAT using my related post VirtualBox: Configure networking for running server on virtual guest. In this case we are using the NAT way (we are going NATs :) ).
    In our case we want to hit 1522 in my host machine in order to access the 1521 in my guest. So we must run the command:
    VBoxManage modifyvm "Fedora14" --natpf1 "guestdb,tcp,,1522,,1521"

Install OracleXE
1.
Download Oracle XE using Firefox
http://www.oracle.com/technetwork/database/express-edition/downloads/102xelinsoft-102048.html
(Firefox will save it in ~/Downloads)

2.
From home dir
$ rpm -ivh ./Downloads/oracle-xe-univ-10.2.0.1-1.0.i386.rpm

3.
When the aboce finished you ll be prompted to
$ /etc/init.d/oracle-xe configure
in order to enter the following configuration information:
  1. A valid HTTP port for the Oracle Database XE graphical user interface (the default is 8080)
  2. A valid port for the Oracle database listener (the default is 1521)
  3. A password for the SYS and SYSTEM administrative user accounts
  4. Whether you want the database to start automatically when the computer starts. If you enter Yes, then the database starts immediately
I ve used the default values.

4.
Finally, set machine to run in Runlevel 3 in order to minimize mem consuption
Open termnal, login as su, and run
$init 3

4b.
If you want you can even better set default runlevel to be 3 and reduce memory of Virtual machine to be below 250MB.

To set default runlevel to 3
Go to  /etc/inittab file and set
id:3:initdefault:
eg.
# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

Then in VirtualBox settings set Fedora image to use 250MB RAM


Dig more:
http://serafeimk.blogspot.com/ (Special thanx to Serafim for his precious tips!)
http://virtualboxes.org/images/fedora/.
http://download.oracle.com/docs/cd/B25329_01/doc/install.102/b25144/toc.htm#CIHHJEHF