Issue #1563: NullpointerException when execute a commit

Type: Bug ReoprtPriority: HighStatus: FixedReplies: 1
#1

Hello,

following exception occurs when using objectdb:


com.objectdb.o.UserException: Failed to commit transaction: Unexpected internal exception
at com.objectdb.o.MSG.d(MSG.java:75)
at com.objectdb.jpa.EMImpl.commit(EMImpl.java:304)
....
Caused by: com.objectdb.o.InternalException: Unexpected internal exception
at com.objectdb.o.JPE.h(JPE.java:168)
at com.objectdb.o.ERR.f(ERR.java:66)
at com.objectdb.o.IVP.l(IVP.java:148)
at com.objectdb.o.IVP.k(IVP.java:130)
at com.objectdb.o.ISP.size(ISP.java:163)
at com.objectdb.o.CLT.visitRefs(CLT.java:156)
at com.objectdb.o.TVS.j(TVS.java:169)
at com.objectdb.o.TVS.cascade(TVS.java:156)
at com.objectdb.o.STA.Q(STA.java:476)
at com.objectdb.o.STM.E(STM.java:407)
at com.objectdb.o.OBM.bO(OBM.java:910)
at com.objectdb.jdo.PMImpl.bO(PMImpl.java:2267)
at com.objectdb.o.OBM.bN(OBM.java:826)
at com.objectdb.o.OBM.bL(OBM.java:740)
at com.objectdb.jpa.EMImpl.commit(EMImpl.java:299)
... 45 more
Caused by: java.lang.NullPointerException
at com.objectdb.o.ISP.size(ISP.java:164)
at com.objectdb.o.CLT.visitRefs(CLT.java:156)
at com.objectdb.o.TVS.j(TVS.java:169)
at com.objectdb.o.TVS.cascade(TVS.java:156)
at com.objectdb.o.STA.Q(STA.java:476)
at com.objectdb.o.STM.E(STM.java:407)
at com.objectdb.o.OBM.bO(OBM.java:910)
at com.objectdb.jdo.PMImpl.bO(PMImpl.java:2267)
at com.objectdb.o.OBM.bN(OBM.java:826)
at com.objectdb.o.OBM.bM(OBM.java:776)
at com.objectdb.o.QRR.f(QRR.java:139)
at com.objectdb.o.QRR.a(QRR.java:618)
at com.objectdb.o.InvMemberQuery.e(InvMemberQuery.java:139)
at com.objectdb.o.UMR.v(UMR.java:508)
at com.objectdb.o.ENT.loadInverse(ENT.java:1472)
at com.objectdb.o.IVP.l(IVP.java:142)
... 57 more

 

Have you an idea what is the cause of this problem?

Following is the example code.

Thanks

 

entity classes:

public class PatternData extends FormalismData {

    ...  
}

public class FormalismData {

    ...

    private Set<ContractData> usedAsAssumptions;

    public Set<ContractData> getUsedAsAssumptions() {
        if (usedAsAssumptions == null) {
            usedAsAssumptions = new HashSet<ContractData>();
        }
        return usedAsAssumptions;
    }

    public void setUsedAsAssumptions(Set<ContractData> usedAsAssumptions) {
        this.usedAsAssumptions = usedAsAssumptions;
    }

    private Set<ContractData> usedAsCommitments;

    public Set<ContractData> getUsedAsCommitments() {
        if (usedAsCommitments == null) {
            usedAsCommitments = new HashSet<ContractData>();
        }
        return usedAsCommitments;
    }

    public void setUsedAsCommitments(Set<ContractData> usedAsCommitments) {
        this.usedAsCommitments = usedAsCommitments;
    }
  
}


public class ContractData {

    ...

    private List<FormalismData> assumptions = new ArrayList<FormalismData>();

    public List<FormalismData> getAssumptions() {
        return assumptions;
    }

    public void setAssumptions(List<FormalismData> assumptions) {
        this.assumptions = assumptions;
    }

    private FormalismData commitment;

    public FormalismData getCommitment() {
        return commitment;
    }

    public void setCommitment(FormalismData commitment) {
        this.commitment = commitment;
    }
}


orm.xml:

<entity class="test.PatternData">
  <attributes>
...
  </attributes>
</entity>
<entity class="test.ContractData">
  <attributes>
   <many-to-one name="commitment" target-entity="test.FormalismData">
    <cascade>
     <cascade-all />
    </cascade>
   </many-to-one>
   <many-to-many name="assumptions" target-entity="test.FormalismData">
    <cascade>
     <cascade-all />
    </cascade>
   </many-to-many>
  </attributes>
</entity>
<entity class="test.FormalismData">
  <attributes>
   <one-to-many name="usedAsCommitments" mapped-by="commitment" target-entity="test.ContractData">
    <cascade>
     <cascade-all />
    </cascade>
   </one-to-many>
   <many-to-many name="usedAsAssumptions" target-entity="test.ContractData" mapped-by="assumptions">
    <cascade>
     <cascade-all />
    </cascade>
   </many-to-many>
  </attributes>
</entity>

 

code:

...

PatternData pattern = new PatternData();
entitymanager.persist(pattern);
transation.commit(); // success

...

transation.begin();
ContractData contract = new ContractData();
entitymanager.persist(contract);
contract.setCommitment(pattern);
transation.commit(); // cause the NullpointerException

 

 

#2

Thank you for your report.

Please try build 2.5.7_07 that should fix this issue.

ObjectDB Support

Reply