Home » Support » Forum » Accessiblity of attributes in entities in several OSGi-Bundles

Accessiblity of attributes in entities in several OSGi-Bundles

#1

Hello,

we have a problem with enhanced entities. It is very important to solve this issue.

There are three entities in two OSGi-Bundles and we execute importRequirements() in RequirementServiceImpl:

__________________________________________________________

Bundle A:

@Entity
class ModelElementImpl {

    @Basic
    private String name;
   
    public void setName() {
        this.name = name;
    }
    public String getName() {
        return name;
    }
}

@Entity
class MessageImpl {

    @OneToOne
    private ModelElementImpl e;
   
    @Basic
    private String desc;
   
    public void setDescription(String desc) {
        this.desc = desc;
    }
}

class MessageServiceImpl {

    public void addMessage(ModelElementImpl e) {

        MessageImpl m = new MessageImpl();
        m.setDescription(e.getName()); // throws the exception
    }
}

__________________________________________________________

Bundle B:

@Entity
class RequirementImpl extends ModelElementImpl {

}

class RequirementServiceImpl {

    public void importRequirements() {
        RequirementImpl requirement = new RequirementImpl();
        requirement.setName("req1");
        messageService.addMessage(requirement);
       
        entityManager.persist(requirement);
        ...
    }
}
__________________________________________________________

But when we used not enhanced entities, we have no problems.

The following exception is thrown when we execute the example:

Caused by: com.objectdb.o._EntityNotFoundException: Entity is not found: com.btc.ep.requirement.bl.internal.model.RequirementImpl#'A0C92E7F-BDDA-4902-A8CB-95C5034ADCA2'
at com.objectdb.o.JPE.g(JPE.java:94)
at com.objectdb.o.ERR.f(ERR.java:56)

at com.objectdb.o.OBC.onObjectDBError(OBC.java:1503)
at com.objectdb.o.ENT.ak(ENT.java:1640)
at com.objectdb.o.ENT.beforeAccess(ENT.java:1128)
at com.btc.ep.base.bl.impl.NamedElementImpl.__odbGet_name(NamedElementImpl.java:1)
at com.btc.ep.base.bl.impl.NamedElementImpl.getName(NamedElementImpl.java:40)
at com.btc.ep.base.bl.impl.NamedElementImpl.toString(NamedElementImpl.java:50)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuffer.append(Unknown Source)
at com.btc.ep.base.bl.internal.MessageServiceImpl.genString(MessageServiceImpl.java:157)
at com.btc.ep.base.bl.internal.MessageServiceImpl.addMessage(MessageServiceImpl.java:198)
at com.btc.ep.base.bl.internal.MessageServiceImpl.addMessage(MessageServiceImpl.java:220)
at com.btc.ep.base.bl.MessageService.info(MessageService.java:163)
at com.btc.ep.requirement.bl.internal.RequirementImportServiceImpl.addReq(RequirementImportServiceImpl.java:146)
#2

In another use case we have a similiar problem:

java.lang.NullPointerException
at com.objectdb.o.MST.aY(MST.java:592)
at com.objectdb.o.MST.U9(MST.java:558)
at com.objectdb.o.WRA.U9(WRA.java:279)
at com.objectdb.o.LDR.F(LDR.java:563)
at com.objectdb.o.LDR.E(LDR.java:470)
at com.objectdb.o.OBC.UO(OBC.java:1080)
at com.objectdb.o.OBC.aL(OBC.java:766)
at com.objectdb.o.ENT.beforeAccess(ENT.java:1120)
at com.btc.ep.base.bl.impl.NamedElementImpl.__odbGet_name(NamedElementImpl.java:1)
at com.btc.ep.base.bl.impl.NamedElementImpl.getName(NamedElementImpl.java:40)
at com.btc.ep.base.bl.impl.NamedElementImpl.toString(NamedElementImpl.java:50)
at java.lang.String.valueOf(Unknown Source)
at java.lang.StringBuffer.append(Unknown Source)
at com.btc.ep.base.bl.internal.MessageServiceImpl.genString(MessageServiceImpl.java:157)
at com.btc.ep.base.bl.internal.MessageServiceImpl.addMessage(MessageServiceImpl.java:201)
at com.btc.ep.base.bl.internal.MessageServiceImpl.addMessage(MessageServiceImpl.java:220)
at com.btc.ep.base.bl.MessageService.warning(MessageService.java:117)
#3

These exceptions may indicate an attempt to access a new entity object that was persisted in one transaction from another concurrent transaction that cannot yet see the operations of the first transaction.

The connection to OSGi (if any) is unclear, and possibly EntityNotFoundException is the correct ObjectDB response in this case.

The second exception (NullPointerException) may happen if that entity object is also the first object of its entity class. This is an ObjectDB bug that was first fixed following a previous forum thread by you, but your new post exposes another situation that was not handled yet. Build 2.6.1_06 should fix this now. However, an EntityNotFoundException will be thrown in this case now, similar to the first case.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login