27 April 2011

Live Set and memory leaks

Some part of the below post are taken or remastered from Oracle JRockit: The Definitive Guide by Marcus Hirt. Buy the book for more :)


"Live set" definition

Live set is the java object that the application is using acively while running.

To be more technical...
Live set usually refers to the space in memory that live objects are occupying on the heap. Live objects are objects that either refered by other objects that are live or objects that are in the root set.  Live objects also refered as "in use". A live object might not be garbage collected (because it is considered to be used be the JVM!).  Root set is the set of objects that are reachable "from the beggining". This is the set of objects present in
·         registers and the
·         local stack frame in the thread context of the stopped for gargbage collection Java threads. (The threads that are stopped for garbage collection might have objects in the local stack frame of their thread context. These object are also part of the root set)

Example of Live Set

Live set is the objects that our application use. When for example we request a page, this pages's object are loaded in to memory, and to be more specific to the live set. If we leave the page, these objects should be marked for GC because there not used anymore. So later GC will run and free the memory of those objects. If there is an problem these object are not marked for GC and left in live set, but the application cannot use them anymore. So these objects are lost or "leaked" and the memory that they occupy is lost or "leaked" causing the memory leak.

Tuning tips

Live set and fragmentation is a good measure of how full the heap is and it is only calculated and updated on every garbage collection.
What to look for depends on the system. Ideally the system should be well utilized, but not saturated. A good rule of thumb for most setups would be to keep the Occupied Heap (Live Set + Fragmentation) to half or less than half of the max heap. This keeps the garbage collection ratio down.

Having a very large percentage of the heap filled with live objects will increase the garbage collector overhead, as GCs will have to be run more frequently. If the Live Set + Fragmentation dial remains steady on a high level and garbage collection performance is an issue, increasing the heap size will improve performance.

If the trend is for the Live Set + Fragmentation dial instead to steadily increase over time, there is probably a memory leak in the application. This basically means that after each garbage collection, there is less free memory left on the heap. It is very likely that we have a memory leak, and that, if we continue to let this application run, we will end up with an OutOfMemoryError. We can check memory leaks with  The Memory Leak Detector

Example

Below an obvious example of a memory leak.


The increasing execution of the GC (the less memory left the more often GC runs) is causing as performance problems. The Red areas are GC execution.





Dig more: 

21 April 2011

Oracle Interview Questions Part 1 by Vinay Kumar

Nice Post by Vinay

Below are the question answered:


Q: Lifecycle of a Web Page Request Using Oracle ADF and JSF
Q: What is Action Listener ?
Q: What are business Component In ADF.Describe them?
Q: What is Top Link?
Q: What is Managed Bean?
Q: What is Backing Bean?
Q: Difference between Backing Bean and Managed Bean?
Q: What do you mean by Bean Scope?
Q: What are the different kinds of Bean Scopes in JSF?
Q: How to declare the page navigation (navigation rules) in faces-config.xml file in ADF 10g?
Q: Setting the range of table
Q: Which component in ADF BC manages transaction ?
Q: Can an entity object be based on two Database Objects(tables/views) or two Webservices ?
Q: Where is that we write business rules/validations in ADF and why?
Q: What are the JSF life-cycle phases?
Q: Explain briefly the life-cycle phases of JSF?
Q: What is setActionListener?

19 April 2011

Set session timeout in Weblogic

Apparently it is not so obvious because there are 2 ways to set session timeout in weblogic:
  • web.xml: in minutes
  • weblogic.xml: in seconds
 If you set both bare in mind that web.xml takes precedence over weblogic.xml

Finally, bear in mind that the Weblogic console displays the weblogic.xml param.


Note: Session timeout  is the amount of time (in seconds) that a session can remain inactive before it is invalidated.

Dig more:

15 April 2011

TROUBLESHOOTING: oracle.security.jps.JpsRuntimeException: Cannot read from policy store.

If during development you get


<12 Apr 2011 10:49:36 μμ EEST>
          \logs\DefaultServer.log is opened. All server side log events will be written to this file.>
 
oracle.security.jps.JpsRuntimeException: Cannot read from policy store.
            at oracle.security.jps.internal.policystore.xml.XmlPolicyStore.buildFromFile(XmlPolicyStore.java:425)
            at oracle.security.jps.internal.policystore.xml.XmlPolicyStore.(XmlPolicyStore.java:224)
        ...
Caused by: oracle.security.jps.JpsRuntimeException: javax.xml.stream.XMLStreamException: End Document reached 
                                    prematurely.
            at oracle.security.jps.internal.core.datastore.xml.XmlDataStoreParser.getDataStoreEntryStax
                 (XmlDataStoreParser.java:166)
        ...
            ... 28 more
...
weblogic.security.SecurityInitializationException: The loading of OPSS java security policy provider failed due to 
               exception, see the exception stack trace or the server log file for root cause. If still see no obvious cause, enable the 
                debug flag -Djava.security.debug=jpspolicy to get more information. Error message: 
                oracle.security.jps.JpsException: [PolicyUtil] Exception while getting default policy Provider
          at weblogic.security.service.CommonSecurityServiceManagerDelegateImpl.loadOPSSPolicy
                                    (CommonSecurityServiceManagerDelegateImpl.java:1398)
        ...
Caused By: oracle.security.jps.JpsRuntimeException: oracle.security.jps.JpsException: [PolicyUtil] Exception while getting 
                default policy Provider
           at oracle.security.jps.internal.policystore.PolicyDelegationController.(PolicyDelegationController.java:291)
...       
Caused By: java.security.PrivilegedActionException: oracle.security.jps.JpsException: [PolicyUtil] Unable to obtain default 
               JPS Context!
            at java.security.AccessController.doPrivileged(Native Method)
...
Caused By: oracle.security.jps.JpsRuntimeException: Cannot read from policy store.
            at oracle.security.jps.internal.policystore.xml.XmlPolicyStore.buildFromFile(XmlPolicyStore.java:425)
...



Solution
Try to remove jazn-data.xml and system-jazn-data.xml from the DefaultDomain.
For example under my DefaultDomain I have all these:


Although jazn-data is part of your application, it is copied to the domain because there is where the security is stored.

Note: I have changed my default path of JDeveloper's system folder. The default is C:\Documents and Settings\username\Application Data\JDeveloper\system11.1.1.4.37.59.23

14 April 2011

Enable Precompilation of jspx pages in weblogic.

To enable locate the weblogic.xml and check the related option "Precompile JSPs"


or

add the following elements in weblogic.xml under the document root:



Pros
  • Errors in pages that cannot be identified with java compilation (javac) or ADF BC validation (ojdeploy) will be identified upon deployment and not during testing.
  • No more delay upon page request for the 1st time. Without precompilation the first time a page is requested, then the jspx is compiled into java.
Cons
  • Longer deployment time. eg it need a few mins more to compile all jspx into java files
In case of error you ll get upon deployment something like this:


Dig more:

12 April 2011

Techniques for Testing Performance/Scalability and Stress-Testing ADF Applications


A new Oracle White paper regarding Techniques for Testing Performance/Scalability and Stress-Testing ADF Applications.
You can download it here.



Src:

08 April 2011

oracle.jbo.domain.Date or oracle.jbo.domain.Date


Same package
Same version
Same location (both in Fusion Middleware)
But completely different classes.
First is located in adfm.jar
Second in  bc4jdomgnrc.jar

Btw, the 1st one is used in ADF.

06 April 2011

Business Component Validation Lifecycle

Last update: 7/4/2011
Nice article: (ADF-BC Business Rules/Validation @ EO/VO) by Kishore regarding Bussiness Rules and Validation.

I just put some additions in blue.

Distributing some of its post's key points:

BC Validation Lifecycle 



Levels of validations:

  • Attribute
    • Fires as soon as the attribute's value is changed and user moves out of that attribute.
  • Entity
  • Fires when the user moves from one record to another record.This is used for validations which are dependent on more than one attribute
    • Eg: Say the commission for an employee should not exceed 10% of his salary.In this case commission can not be validated at attribute level,because user might enter commission first and then salary next.But it can be validated at entity level.i.e; when the user moves from one employee record to another employee record.(One can assume salary is mandatory)
  • Transaction
    • Fires when all attribute and entity level validations are completed.A transaction level validation is executed at the end.An example is a master-detail validation where a master needs to have only one child as favorite among all child rows.
Every validation can have a validation execution condition which skips executing the validation when the condition is not met.


Validation entry points in EOImpl:

When a attribute or entity validation is invoked the super class handles this process by calling the following methods:
  • When an attribute is set setAttributeInternal(int) is called which invokes all the attribute level validations,this can be clearly seen because the first line in every set method will be setAttributeInternal which runs all the attribute validations and updates the entity attribute to the newValue.
  • For entity level validations the method invoked is validateEntity() which runs all the entity level validations.

The main entry points are setAttributeInternal(int) and validateEntity based on validation level.
Apart from these beforeCommit(TransactionEvent) afterCommit(TransactionEvent) doDML(int) postChanges() are some of the important methods in ADF life-cycle. 

I will just add also the methods of Custom implementation (if any) of DBTransactionImpl2.
Finally do not forget to set -Djbo.txn.handleafterpostexc=true.


When all validations are successful postChanges is invoked and all changes are posted to the database and finally commit is issued.

What happens when a value is changed and a commit is invoked?
In simple terms:

The application module->gets the DBTransaction and calls commit->DBTransaction issues a validate call to all its entities in its data model->Every vo/entity validates itself and finally the transaction gets commited.

For master-detail entities the master validate will invoke child validation  and the chain is invoked recursively till the last child vo.

03 April 2011

ADF Metadata Files

Below figure demonstrates the hierarchical relationship of the XML metadata files that you might work with in a Fusion web application that uses an ADF Business Components application module as a service interface to JSF web pages


The below figure illustrates the hierarchical relationship of the XML metadata files that you might work with in a web application that uses an ADF application module as a service interface to ADF Business Components. At runtime, the objects created from these files interact in this sequence:
  1. When the first request for an ADF databound web page occurs, the servlet registers the Oracle ADF servlet filter ADFBindingFilter named in the web.xml file.
  2. The binding filter creates an empty binding context.
  3. When a page is rendered, the binding filter asks the binding context to load a corresponding PageDef.xml for the page.
  4. The binding context creates the binding container by loading the  file as referenced by the  element in the DataBindings.cpx file.
  5. The adfm.xml file loads the DataBindings.cpx contents and finds the right PageDef.xml based on the  element reference to the  element.
  6. The binding container's prepareModel phase prepares and refreshes all relevant executables (most are marked deferred by default).
  7. An iterator binding gets executed by referencing the named method on the data control found through the data control factory named in the case of ADF Business Components in the bc4j.xcfg file.
  8. The binding container also creates the bindings defined in the  section of the pagenamePageDef.xml file for the mapped web page.
  9. The web page references to ADF bindings through EL using the expression #{bindings} are resolved by accessing the binding container of the page.
  10. The page pulls the available data from the bindings on the binding container.



Dig more:


You might also like:

Related Posts Plugin for WordPress, Blogger...