Please disable your adblock and script blockers to view this page

Search this blog

Tuesday 3 September 2013

Avoiding JBO-27101: DeadEntityAccessException, Attempt to access dead entity -Oracle ADF

As Per Oracle docs- JBO-27101: DeadEntityAccessException

Cause: Trying to refer to an invalid/obsolete entity. This could occur if some business logic has held on to an entity reference which was removed and the transaction has been posted or committed. It could also occur if a reference entity has been removed from the cache and any ViewRow is attempting to access it.

Action: Use findByPrimaryKey to find a valid entity of the desired key instead of holding on to a reference to an entity instance.

oracle.jbo.DeadEntityAccessException: JBO-27101: Attempt to access dead entity in DepartmentsEO, key=oracle.jbo.Key[10 ]
 at oracle.jbo.server.EntityImpl.setAttributeValueInternal(
 at oracle.jbo.server.EntityImpl.setAttributeValue(
 at oracle.jbo.server.AttributeDefImpl.set(
 at oracle.jbo.server.EntityImpl.setAttributeInternal(
 at exception.model.entities.DepartmentsEOImpl.setManagerId(
 at exception.model.entities.DepartmentsEOImpl.doDML(
 at oracle.jbo.server.EntityImpl.postChanges(
 at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(
 at oracle.jbo.server.DBTransactionImpl.postChanges(
 at oracle.jbo.server.DBTransactionImpl.commitInternal(
 at oracle.jbo.server.DBTransactionImpl.commit(
 at oracle.adf.model.bc4j.DCJboDataControl.commitTransaction(
 at oracle.adf.model.binding.DCDataControl.callCommitTransaction(
 at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(
 at oracle.adf.model.binding.DCDataControl.invokeOperation(
 at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(
 at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(
 at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(
 at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
 at java.lang.reflect.Method.invoke(
 at com.sun.el.parser.AstValue.invoke(Unknown Source)
 at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)

This exception mainly occurs when developer/User removes a row from ViewObject and try to access it again to set any value or to commit transaction .
if entity(object of a row in table) is removed and then accessed from cache throws this exception
So Always check code that you have written to remove a row from entity and do check your doDML() method in EntityImpl class as it executes during commit after any DML Operation (Update, Delete).

Steps to reproduce DeadEntityAccessException-
  • here i am using default HR Schema (Departments table)
  • Create business components using Departments table

  • create a page and drag Departments viewObject from data control as a table on page and also drop delete and commit operation on page
  • Now go to EOImpl class of Departments Entity Object and just set any attribute's value in doDML(); method

  •     /**
         * Custom DML update/insert/delete logic here.
         * @param operation the operation type
         * @param e the transaction event
        protected void doDML(int operation, TransactionEvent e) {
            super.doDML(operation, e);
  • Now just run your application and delete any row then press commit, in this case doDML(); method try to set managerId in deleted row that is not in cache, in this case you will see DeadEntityAccessException

1 comment :