5 Replies Latest reply on Jan 30, 2010 7:04 PM by Mitesh Gajjar

    Deleting a row from a Parent VO gives NullPointerException

    Mitesh Gajjar
      I am using JDev 11.1.1.2.0

      Deleting a row from a Parent VO gives NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)

      Here is my implementation:
      There are two Entity Objects(Named "Parent" and "Child").
      Both EO are NOT based on a database table. (These are populated from a method in the AM, the method calls a database API that returns an nested array and this array is used to populate the Parent and Child entities)
      All attributes in these entity objects are Non-persistent.

      The View Object "ParentEv" is based on "Parent" EO
      The View Object "ChildEv" is based on "Child" EO

      The View Objects "ParentEv" and "ChildEv" are linked by a view link.

      The Entities "Parent" and"Child" are linked by Entity Association ( as "Composition Association" with "Implement Cascade Delete" checked.)

      I am programatically deleting and populating the View Objects ParentEv and ChildEv from a method in the AM.

      The first time I execute the method in BC Tester, it works fine.
      The second time I execute the method it works fine.
      But on third execution, it gives the below error which seems to be NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)

      I am able to reproduce this in a test case scenario. It always works the first 2 times and fails when the method to delete and populate the VOs is executed a 3rd time.

      If we base the "Parent" and "Child" entities on some dummy database views, it works fine, the problem only occurs when the Entities are NOT based on any table.

      Can someone advise on what could be causing this issue?

      Thanks,
      Mitesh.
        • 1. Re: Deleting a row from a Parent VO gives NullPointerException
          Mitesh Gajjar
          Here's the full error:

          (oracle.jbo.JboException) JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null



          oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null
               at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:609)
               at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2134)
               at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:3021)
               at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:257)
               at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1625)
               at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2141)
               at oracle.jbo.jbotester.panel.MethodPanel$6.actionPerformed(MethodPanel.java:313)
               at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
               at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
               at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
               at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
               at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
               at java.awt.Component.processMouseEvent(Component.java:6263)
               at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
               at java.awt.Component.processEvent(Component.java:6028)
               at java.awt.Container.processEvent(Container.java:2041)
               at java.awt.Component.dispatchEventImpl(Component.java:4630)
               at java.awt.Container.dispatchEventImpl(Container.java:2099)
               at java.awt.Component.dispatchEvent(Component.java:4460)
               at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
               at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
               at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
               at java.awt.Container.dispatchEventImpl(Container.java:2085)
               at java.awt.Window.dispatchEventImpl(Window.java:2475)
               at java.awt.Component.dispatchEvent(Component.java:4460)
               at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
               at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
               at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
               at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
               at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
               at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
               at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
          Caused by: java.lang.NullPointerException
               at oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
               at oracle.jbo.server.EntityImpl.remove(EntityImpl.java:8363)
               at oracle.jbo.server.ViewRowImpl.doRemove(ViewRowImpl.java:3192)
               at oracle.jbo.server.ViewRowImpl.remove(ViewRowImpl.java:3237)
               at model.am.AppModuleImpl.populateMethod(AppModuleImpl.java:30)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:567)
               ... 31 more
          ## Detail 0 ##
          java.lang.NullPointerException
               at oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
               at oracle.jbo.server.EntityImpl.remove(EntityImpl.java:8363)
               at oracle.jbo.server.ViewRowImpl.doRemove(ViewRowImpl.java:3192)
               at oracle.jbo.server.ViewRowImpl.remove(ViewRowImpl.java:3237)
               at model.am.AppModuleImpl.populateMethod(AppModuleImpl.java:30)
               at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
               at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
               at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
               at java.lang.reflect.Method.invoke(Method.java:597)
               at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:567)
               at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2134)
               at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:3021)
               at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:257)
               at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1625)
               at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2141)
               at oracle.jbo.jbotester.panel.MethodPanel$6.actionPerformed(MethodPanel.java:313)
               at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
               at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
               at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
               at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
               at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
               at java.awt.Component.processMouseEvent(Component.java:6263)
               at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
               at java.awt.Component.processEvent(Component.java:6028)
               at java.awt.Container.processEvent(Container.java:2041)
               at java.awt.Component.dispatchEventImpl(Component.java:4630)
               at java.awt.Container.dispatchEventImpl(Container.java:2099)
               at java.awt.Component.dispatchEvent(Component.java:4460)
               at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
               at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
               at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
               at java.awt.Container.dispatchEventImpl(Container.java:2085)
               at java.awt.Window.dispatchEventImpl(Window.java:2475)
               at java.awt.Component.dispatchEvent(Component.java:4460)
               at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
               at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
               at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
               at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
               at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
               at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
               at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
          • 2. Re: Deleting a row from a Parent VO gives NullPointerException
            Mitesh Gajjar
            Here's the method that I use in my test case to populate the VOs.
              /**
               * This method populates the VOs ParentEv and ChildEv.
               * These VOs are based on EOs Paren and Child, respectively.
               * Before populating the VOs I am deleting any existing rows.
               * The first two times this method is executed, it works fine.
               * The third time this method executes it gives a nullpointerexception raised from
               * oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
               */
              public void populateMethod(){
                int rowCount = getParentEv().getRowCount();    
                for (int i = 0; i < rowCount; i++) {
                     Row row = getParentEv().last();
                     if(row!=null)
                       row.remove();
                }
                rowCount = getChildEv().getRowCount();
                for (int i = 0; i < rowCount; i++) {
                 Row row = getChildEv().last();
                 if(row!=null)
                   row.remove();
                }    
            
                int k = 0;
                for (int i = 1; i < 5; i++) {    
                  ParentEvRowImpl parentEvRow = (ParentEvRowImpl)getParentEv().createRow();
                  parentEvRow.setParentPk("Parent " + i);
                  parentEvRow.setParentDesc("Parent Desc " + i);
                  getParentEv().insertRow(parentEvRow);    
                  
                  for (int j = 1; j < 5; j++) {    
                 k++;
                 ChildEvRowImpl childEvRow = (ChildEvRowImpl)getChildEv().createRow();
                 childEvRow.setChildPk("Child " + k);
                 childEvRow.setChildDesc("Child Desc " + k);
                 getChildEv().insertRow(childEvRow);    
                  }
                }
              }
            ==============================================================================

            Here is the Parent.xml for the Parent EO:
            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
            <!---->
            <Entity
              xmlns="http://xmlns.oracle.com/bc4j"
              Name="Parent"
              Version="11.1.1.55.36"
              AliasName="Parent"
              BindingStyle="OracleName"
              UseGlueCode="false"
              RowClass="oracle.jbo.server.EntityImpl"
              DefClass="oracle.jbo.server.EntityDefImpl"
              CollClass="oracle.jbo.server.EntityCache">
              <DesignTime>
                <AttrArray Name="_publishEvents"/>
              </DesignTime>
              <Attribute
                Name="ParentPk"
                IsQueriable="false"
                IsPersistent="false"
                ColumnName="PARENTPK"
                SQLType="VARCHAR"
                Type="java.lang.String"
                ColumnType="$none$"
                PrimaryKey="true"/>
              <Attribute
                Name="ParentDesc"
                IsQueriable="false"
                IsPersistent="false"
                ColumnName="$none$"
                SQLType="VARCHAR"
                Type="java.lang.String"
                ColumnType="$none$"/>
              <AccessorAttribute
                Name="Child"
                Association="model.eo.ea.ChildParentAssoc"
                AssociationEnd="model.eo.ea.ChildParentAssoc.Child"
                AssociationOtherEnd="model.eo.ea.ChildParentAssoc.Parent"
                Type="oracle.jbo.RowIterator"
                IsUpdateable="false"/>
            </Entity>
            ==============================================================================

            Here is the Child.xml for the Child EO:
            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
            <!---->
            <Entity
              xmlns="http://xmlns.oracle.com/bc4j"
              Name="Child"
              Version="11.1.1.55.36"
              AliasName="Child"
              BindingStyle="OracleName"
              UseGlueCode="false">
              <DesignTime>
                <AttrArray Name="_publishEvents"/>
              </DesignTime>
              <Attribute
                Name="ChildPk"
                IsUpdateable="while_insert"
                IsQueriable="false"
                IsPersistent="false"
                IsNotNull="true"
                ColumnName="CHILDPK"
                SQLType="VARCHAR"
                Type="java.lang.String"
                ColumnType="$none$"
                PrimaryKey="true"/>
              <Attribute
                Name="ChildDesc"
                IsQueriable="false"
                IsPersistent="false"
                ColumnName="$none$"
                SQLType="VARCHAR"
                Type="java.lang.String"
                ColumnType="$none$"/>
              <Attribute
                Name="ParentPk"
                IsQueriable="false"
                IsPersistent="false"
                IsNotNull="true"
                ColumnName="$none$"
                SQLType="VARCHAR"
                Type="java.lang.String"
                ColumnType="$none$"/>
            </Entity>
            ==============================================================================

            Here is the ChildParentAssoc.xml for the Association between Parent and Child EOs:
            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE Association SYSTEM "jbo_03_01.dtd">
            <!---->
            <Association
              xmlns="http://xmlns.oracle.com/bc4j"
              Name="ChildParentAssoc"
              Version="11.1.1.55.36">
              <DesignTime>
                <Attr Name="_isCodegen" Value="true"/>
              </DesignTime>
              <AssociationEnd
                Name="Parent"
                Cardinality="1"
                Source="true"
                Owner="model.eo.Parent"
                DeleteContainee="true"
                LockLevel="NONE"
                ExposedAccessor="false">
                <DesignTime>
                  <Attr Name="_aggregation" Value="0"/>
                  <Attr Name="_finderName" Value="Parent"/>
                  <Attr Name="_isUpdateable" Value="true"/>
                  <Attr Name="_minCardinality" Value="1"/>
                </DesignTime>
                <AttrArray Name="Attributes">
                  <Item Value="model.eo.Parent.ParentPk"/>
                </AttrArray>
              </AssociationEnd>
              <AssociationEnd
                Name="Child"
                Cardinality="-1"
                Owner="model.eo.Child"
                HasOwner="true">
                <DesignTime>
                  <Attr Name="_aggregation" Value="0"/>
                  <Attr Name="_finderName" Value="Child"/>
                  <Attr Name="_isUpdateable" Value="true"/>
                </DesignTime>
                <AttrArray Name="Attributes">
                  <Item Value="model.eo.Child.ParentPk"/>
                </AttrArray>
              </AssociationEnd>
            </Association>
            ==============================================================================

            Here is the ParentEv.xml for the ParentEv VO:
            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
            <!---->
            <ViewObject
              xmlns="http://xmlns.oracle.com/bc4j"
              Name="ParentEv"
              Version="11.1.1.55.36"
              BindingStyle="OracleName"
              CustomQuery="true"
              RowClass="model.vo.ev.ParentEvRowImpl"
              ComponentClass="model.vo.ev.ParentEvImpl"
              PageIterMode="Full"
              UseGlueCode="false">
              <DesignTime>
                <Attr Name="_codeGenFlag2" Value="Access|Coll"/>
                <Attr Name="_isExpertMode" Value="true"/>
                <Attr Name="_isCodegen" Value="true"/>
              </DesignTime>
              <EntityUsage
                Name="Parent"
                Entity="model.eo.Parent"/>
              <ViewAttribute
                Name="ParentDesc"
                IsSelected="false"
                IsQueriable="false"
                IsPersistent="false"
                PrecisionRule="true"
                Precision="255"
                EntityAttrName="ParentDesc"
                EntityUsage="Parent"
                AliasName="PARENTDESC"/>
              <ViewAttribute
                Name="ParentPk"
                IsQueriable="false"
                IsPersistent="false"
                PrecisionRule="true"
                EntityAttrName="ParentPk"
                EntityUsage="Parent"/>
              <ViewLinkAccessor
                Name="ChildEv"
                ViewLink="model.vo.vl.ChildEvParentEvVl"
                Type="oracle.jbo.RowIterator"
                IsUpdateable="false"/>
            </ViewObject>
            ==============================================================================

            Here is the ChildEv.xml for the ChildEv VO:
            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
            <!---->
            <ViewObject
              xmlns="http://xmlns.oracle.com/bc4j"
              Name="ChildEv"
              Version="11.1.1.55.36"
              BindingStyle="OracleName"
              CustomQuery="true"
              RowClass="model.vo.ev.ChildEvRowImpl"
              ComponentClass="model.vo.ev.ChildEvImpl"
              PageIterMode="Full"
              UseGlueCode="false">
              <DesignTime>
                <Attr Name="_codeGenFlag2" Value="Access|Coll"/>
                <Attr Name="_isExpertMode" Value="true"/>
                <Attr Name="_isCodegen" Value="true"/>
              </DesignTime>
              <EntityUsage
                Name="Child"
                Entity="model.eo.Child"/>
              <ViewAttribute
                Name="ChildDesc"
                IsSelected="false"
                IsQueriable="false"
                IsPersistent="false"
                PrecisionRule="true"
                Precision="255"
                EntityAttrName="ChildDesc"
                EntityUsage="Child"
                AliasName="CHILDDESC"/>
              <ViewAttribute
                Name="ChildPk"
                IsUpdateable="while_insert"
                IsQueriable="false"
                IsPersistent="false"
                IsNotNull="true"
                PrecisionRule="true"
                EntityAttrName="ChildPk"
                EntityUsage="Child"/>
              <ViewAttribute
                Name="ParentPk"
                IsQueriable="false"
                IsPersistent="false"
                IsNotNull="true"
                PrecisionRule="true"
                EntityAttrName="ParentPk"
                EntityUsage="Child"/>
            </ViewObject>
            ==============================================================================

            Here is the ChildEvParentEvVl.xml for the view link between ParentEv and ChildEv VOs:
            <?xml version="1.0" encoding="UTF-8" ?>
            <!DOCTYPE ViewLink SYSTEM "jbo_03_01.dtd">
            <!---->
            <ViewLink
              xmlns="http://xmlns.oracle.com/bc4j"
              Name="ChildEvParentEvVl"
              Version="11.1.1.55.36">
              <DesignTime>
                <Attr Name="_isCodegen" Value="true"/>
              </DesignTime>
              <ViewLinkDefEnd
                Name="ParentEv"
                Cardinality="1"
                Owner="model.vo.ev.ParentEv"
                Source="true">
                <DesignTime>
                  <Attr Name="_finderName" Value="ParentEv"/>
                  <Attr Name="_isUpdateable" Value="true"/>
                </DesignTime>
                <AttrArray Name="Attributes">
                  <Item Value="model.vo.ev.ParentEv.ParentPk"/>
                </AttrArray>
              </ViewLinkDefEnd>
              <ViewLinkDefEnd
                Name="ChildEv"
                Cardinality="-1"
                Owner="model.vo.ev.ChildEv">
                <DesignTime>
                  <Attr Name="_finderName" Value="ChildEv"/>
                  <Attr Name="_isUpdateable" Value="true"/>
                </DesignTime>
                <AttrArray Name="Attributes">
                  <Item Value="model.vo.ev.ChildEv.ParentPk"/>
                </AttrArray>
              </ViewLinkDefEnd>
            </ViewLink>
            • 5. Re: Deleting a row from a Parent VO gives NullPointerException
              Mitesh Gajjar
              I logged a bug with oracle. Bug 9258747 - NONPERSISTENT ENTITY GIVES NULLPOINTEREXCEPTION ON ROW.REMOVE DELETING CHILD